1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.telephony; 18 19 20 import android.content.Context; 21 import android.os.Message; 22 import android.os.RegistrantList; 23 import android.os.Registrant; 24 import android.os.Handler; 25 import android.os.AsyncResult; 26 import android.telephony.TelephonyManager; 27 28 /** 29 * {@hide} 30 */ 31 public abstract class BaseCommands implements CommandsInterface { 32 //***** Instance Variables 33 protected Context mContext; 34 protected RadioState mState = RadioState.RADIO_UNAVAILABLE; 35 protected Object mStateMonitor = new Object(); 36 37 protected RegistrantList mRadioStateChangedRegistrants = new RegistrantList(); 38 protected RegistrantList mOnRegistrants = new RegistrantList(); 39 protected RegistrantList mAvailRegistrants = new RegistrantList(); 40 protected RegistrantList mOffOrNotAvailRegistrants = new RegistrantList(); 41 protected RegistrantList mNotAvailRegistrants = new RegistrantList(); 42 protected RegistrantList mCallStateRegistrants = new RegistrantList(); 43 protected RegistrantList mVoiceNetworkStateRegistrants = new RegistrantList(); 44 protected RegistrantList mDataNetworkStateRegistrants = new RegistrantList(); 45 protected RegistrantList mVoiceRadioTechChangedRegistrants = new RegistrantList(); 46 protected RegistrantList mImsNetworkStateChangedRegistrants = new RegistrantList(); 47 protected RegistrantList mIccStatusChangedRegistrants = new RegistrantList(); 48 protected RegistrantList mVoicePrivacyOnRegistrants = new RegistrantList(); 49 protected RegistrantList mVoicePrivacyOffRegistrants = new RegistrantList(); 50 protected Registrant mUnsolOemHookRawRegistrant; 51 protected RegistrantList mOtaProvisionRegistrants = new RegistrantList(); 52 protected RegistrantList mCallWaitingInfoRegistrants = new RegistrantList(); 53 protected RegistrantList mDisplayInfoRegistrants = new RegistrantList(); 54 protected RegistrantList mSignalInfoRegistrants = new RegistrantList(); 55 protected RegistrantList mNumberInfoRegistrants = new RegistrantList(); 56 protected RegistrantList mRedirNumInfoRegistrants = new RegistrantList(); 57 protected RegistrantList mLineControlInfoRegistrants = new RegistrantList(); 58 protected RegistrantList mT53ClirInfoRegistrants = new RegistrantList(); 59 protected RegistrantList mT53AudCntrlInfoRegistrants = new RegistrantList(); 60 protected RegistrantList mRingbackToneRegistrants = new RegistrantList(); 61 protected RegistrantList mResendIncallMuteRegistrants = new RegistrantList(); 62 protected RegistrantList mCdmaSubscriptionChangedRegistrants = new RegistrantList(); 63 protected RegistrantList mCdmaPrlChangedRegistrants = new RegistrantList(); 64 protected RegistrantList mExitEmergencyCallbackModeRegistrants = new RegistrantList(); 65 protected RegistrantList mRilConnectedRegistrants = new RegistrantList(); 66 protected RegistrantList mIccRefreshRegistrants = new RegistrantList(); 67 protected RegistrantList mRilCellInfoListRegistrants = new RegistrantList(); 68 protected RegistrantList mSubscriptionStatusRegistrants = new RegistrantList(); 69 protected RegistrantList mSrvccStateRegistrants = new RegistrantList(); 70 protected RegistrantList mHardwareConfigChangeRegistrants = new RegistrantList(); 71 72 protected Registrant mGsmSmsRegistrant; 73 protected Registrant mCdmaSmsRegistrant; 74 protected Registrant mNITZTimeRegistrant; 75 protected Registrant mSignalStrengthRegistrant; 76 protected Registrant mUSSDRegistrant; 77 protected Registrant mSmsOnSimRegistrant; 78 protected Registrant mSmsStatusRegistrant; 79 protected Registrant mSsnRegistrant; 80 protected Registrant mCatSessionEndRegistrant; 81 protected Registrant mCatProCmdRegistrant; 82 protected Registrant mCatEventRegistrant; 83 protected Registrant mCatCallSetUpRegistrant; 84 protected Registrant mIccSmsFullRegistrant; 85 protected Registrant mEmergencyCallbackModeRegistrant; 86 protected Registrant mRingRegistrant; 87 protected Registrant mRestrictedStateRegistrant; 88 protected Registrant mGsmBroadcastSmsRegistrant; 89 90 // Preferred network type received from PhoneFactory. 91 // This is used when establishing a connection to the 92 // vendor ril so it starts up in the correct mode. 93 protected int mPreferredNetworkType; 94 // CDMA subscription received from PhoneFactory 95 protected int mCdmaSubscription; 96 // Type of Phone, GSM or CDMA. Set by CDMAPhone or GSMPhone. 97 protected int mPhoneType; 98 // RIL Version 99 protected int mRilVersion = -1; 100 101 public BaseCommands(Context context) { 102 mContext = context; // May be null (if so we won't log statistics) 103 } 104 105 //***** CommandsInterface implementation 106 107 @Override 108 public RadioState getRadioState() { 109 return mState; 110 } 111 112 @Override 113 public void registerForRadioStateChanged(Handler h, int what, Object obj) { 114 Registrant r = new Registrant (h, what, obj); 115 116 synchronized (mStateMonitor) { 117 mRadioStateChangedRegistrants.add(r); 118 r.notifyRegistrant(); 119 } 120 } 121 122 @Override 123 public void unregisterForRadioStateChanged(Handler h) { 124 synchronized (mStateMonitor) { 125 mRadioStateChangedRegistrants.remove(h); 126 } 127 } 128 129 public void registerForImsNetworkStateChanged(Handler h, int what, Object obj) { 130 Registrant r = new Registrant (h, what, obj); 131 mImsNetworkStateChangedRegistrants.add(r); 132 } 133 134 public void unregisterForImsNetworkStateChanged(Handler h) { 135 mImsNetworkStateChangedRegistrants.remove(h); 136 } 137 138 @Override 139 public void registerForOn(Handler h, int what, Object obj) { 140 Registrant r = new Registrant (h, what, obj); 141 142 synchronized (mStateMonitor) { 143 mOnRegistrants.add(r); 144 145 if (mState.isOn()) { 146 r.notifyRegistrant(new AsyncResult(null, null, null)); 147 } 148 } 149 } 150 @Override 151 public void unregisterForOn(Handler h) { 152 synchronized (mStateMonitor) { 153 mOnRegistrants.remove(h); 154 } 155 } 156 157 158 @Override 159 public void registerForAvailable(Handler h, int what, Object obj) { 160 Registrant r = new Registrant (h, what, obj); 161 162 synchronized (mStateMonitor) { 163 mAvailRegistrants.add(r); 164 165 if (mState.isAvailable()) { 166 r.notifyRegistrant(new AsyncResult(null, null, null)); 167 } 168 } 169 } 170 171 @Override 172 public void unregisterForAvailable(Handler h) { 173 synchronized(mStateMonitor) { 174 mAvailRegistrants.remove(h); 175 } 176 } 177 178 @Override 179 public void registerForNotAvailable(Handler h, int what, Object obj) { 180 Registrant r = new Registrant (h, what, obj); 181 182 synchronized (mStateMonitor) { 183 mNotAvailRegistrants.add(r); 184 185 if (!mState.isAvailable()) { 186 r.notifyRegistrant(new AsyncResult(null, null, null)); 187 } 188 } 189 } 190 191 @Override 192 public void unregisterForNotAvailable(Handler h) { 193 synchronized (mStateMonitor) { 194 mNotAvailRegistrants.remove(h); 195 } 196 } 197 198 @Override 199 public void registerForOffOrNotAvailable(Handler h, int what, Object obj) { 200 Registrant r = new Registrant (h, what, obj); 201 202 synchronized (mStateMonitor) { 203 mOffOrNotAvailRegistrants.add(r); 204 205 if (mState == RadioState.RADIO_OFF || !mState.isAvailable()) { 206 r.notifyRegistrant(new AsyncResult(null, null, null)); 207 } 208 } 209 } 210 @Override 211 public void unregisterForOffOrNotAvailable(Handler h) { 212 synchronized(mStateMonitor) { 213 mOffOrNotAvailRegistrants.remove(h); 214 } 215 } 216 217 @Override 218 public void registerForCallStateChanged(Handler h, int what, Object obj) { 219 Registrant r = new Registrant (h, what, obj); 220 221 mCallStateRegistrants.add(r); 222 } 223 224 @Override 225 public void unregisterForCallStateChanged(Handler h) { 226 mCallStateRegistrants.remove(h); 227 } 228 229 @Override 230 public void registerForVoiceNetworkStateChanged(Handler h, int what, Object obj) { 231 Registrant r = new Registrant (h, what, obj); 232 233 mVoiceNetworkStateRegistrants.add(r); 234 } 235 236 @Override 237 public void unregisterForVoiceNetworkStateChanged(Handler h) { 238 mVoiceNetworkStateRegistrants.remove(h); 239 } 240 241 @Override 242 public void registerForDataNetworkStateChanged(Handler h, int what, Object obj) { 243 Registrant r = new Registrant (h, what, obj); 244 245 mDataNetworkStateRegistrants.add(r); 246 } 247 248 @Override 249 public void unregisterForDataNetworkStateChanged(Handler h) { 250 mDataNetworkStateRegistrants.remove(h); 251 } 252 253 @Override 254 public void registerForVoiceRadioTechChanged(Handler h, int what, Object obj) { 255 Registrant r = new Registrant (h, what, obj); 256 mVoiceRadioTechChangedRegistrants.add(r); 257 } 258 259 @Override 260 public void unregisterForVoiceRadioTechChanged(Handler h) { 261 mVoiceRadioTechChangedRegistrants.remove(h); 262 } 263 264 @Override 265 public void registerForIccStatusChanged(Handler h, int what, Object obj) { 266 Registrant r = new Registrant (h, what, obj); 267 mIccStatusChangedRegistrants.add(r); 268 } 269 270 @Override 271 public void unregisterForIccStatusChanged(Handler h) { 272 mIccStatusChangedRegistrants.remove(h); 273 } 274 275 @Override 276 public void setOnNewGsmSms(Handler h, int what, Object obj) { 277 mGsmSmsRegistrant = new Registrant (h, what, obj); 278 } 279 280 @Override 281 public void unSetOnNewGsmSms(Handler h) { 282 if (mGsmSmsRegistrant != null && mGsmSmsRegistrant.getHandler() == h) { 283 mGsmSmsRegistrant.clear(); 284 mGsmSmsRegistrant = null; 285 } 286 } 287 288 @Override 289 public void setOnNewCdmaSms(Handler h, int what, Object obj) { 290 mCdmaSmsRegistrant = new Registrant (h, what, obj); 291 } 292 293 @Override 294 public void unSetOnNewCdmaSms(Handler h) { 295 if (mCdmaSmsRegistrant != null && mCdmaSmsRegistrant.getHandler() == h) { 296 mCdmaSmsRegistrant.clear(); 297 mCdmaSmsRegistrant = null; 298 } 299 } 300 301 @Override 302 public void setOnNewGsmBroadcastSms(Handler h, int what, Object obj) { 303 mGsmBroadcastSmsRegistrant = new Registrant (h, what, obj); 304 } 305 306 @Override 307 public void unSetOnNewGsmBroadcastSms(Handler h) { 308 if (mGsmBroadcastSmsRegistrant != null && mGsmBroadcastSmsRegistrant.getHandler() == h) { 309 mGsmBroadcastSmsRegistrant.clear(); 310 mGsmBroadcastSmsRegistrant = null; 311 } 312 } 313 314 @Override 315 public void setOnSmsOnSim(Handler h, int what, Object obj) { 316 mSmsOnSimRegistrant = new Registrant (h, what, obj); 317 } 318 319 @Override 320 public void unSetOnSmsOnSim(Handler h) { 321 if (mSmsOnSimRegistrant != null && mSmsOnSimRegistrant.getHandler() == h) { 322 mSmsOnSimRegistrant.clear(); 323 mSmsOnSimRegistrant = null; 324 } 325 } 326 327 @Override 328 public void setOnSmsStatus(Handler h, int what, Object obj) { 329 mSmsStatusRegistrant = new Registrant (h, what, obj); 330 } 331 332 @Override 333 public void unSetOnSmsStatus(Handler h) { 334 if (mSmsStatusRegistrant != null && mSmsStatusRegistrant.getHandler() == h) { 335 mSmsStatusRegistrant.clear(); 336 mSmsStatusRegistrant = null; 337 } 338 } 339 340 @Override 341 public void setOnSignalStrengthUpdate(Handler h, int what, Object obj) { 342 mSignalStrengthRegistrant = new Registrant (h, what, obj); 343 } 344 345 @Override 346 public void unSetOnSignalStrengthUpdate(Handler h) { 347 if (mSignalStrengthRegistrant != null && mSignalStrengthRegistrant.getHandler() == h) { 348 mSignalStrengthRegistrant.clear(); 349 mSignalStrengthRegistrant = null; 350 } 351 } 352 353 @Override 354 public void setOnNITZTime(Handler h, int what, Object obj) { 355 mNITZTimeRegistrant = new Registrant (h, what, obj); 356 } 357 358 @Override 359 public void unSetOnNITZTime(Handler h) { 360 if (mNITZTimeRegistrant != null && mNITZTimeRegistrant.getHandler() == h) { 361 mNITZTimeRegistrant.clear(); 362 mNITZTimeRegistrant = null; 363 } 364 } 365 366 @Override 367 public void setOnUSSD(Handler h, int what, Object obj) { 368 mUSSDRegistrant = new Registrant (h, what, obj); 369 } 370 371 @Override 372 public void unSetOnUSSD(Handler h) { 373 if (mUSSDRegistrant != null && mUSSDRegistrant.getHandler() == h) { 374 mUSSDRegistrant.clear(); 375 mUSSDRegistrant = null; 376 } 377 } 378 379 @Override 380 public void setOnSuppServiceNotification(Handler h, int what, Object obj) { 381 mSsnRegistrant = new Registrant (h, what, obj); 382 } 383 384 @Override 385 public void unSetOnSuppServiceNotification(Handler h) { 386 if (mSsnRegistrant != null && mSsnRegistrant.getHandler() == h) { 387 mSsnRegistrant.clear(); 388 mSsnRegistrant = null; 389 } 390 } 391 392 @Override 393 public void setOnCatSessionEnd(Handler h, int what, Object obj) { 394 mCatSessionEndRegistrant = new Registrant (h, what, obj); 395 } 396 397 @Override 398 public void unSetOnCatSessionEnd(Handler h) { 399 if (mCatSessionEndRegistrant != null && mCatSessionEndRegistrant.getHandler() == h) { 400 mCatSessionEndRegistrant.clear(); 401 mCatSessionEndRegistrant = null; 402 } 403 } 404 405 @Override 406 public void setOnCatProactiveCmd(Handler h, int what, Object obj) { 407 mCatProCmdRegistrant = new Registrant (h, what, obj); 408 } 409 410 @Override 411 public void unSetOnCatProactiveCmd(Handler h) { 412 if (mCatProCmdRegistrant != null && mCatProCmdRegistrant.getHandler() == h) { 413 mCatProCmdRegistrant.clear(); 414 mCatProCmdRegistrant = null; 415 } 416 } 417 418 @Override 419 public void setOnCatEvent(Handler h, int what, Object obj) { 420 mCatEventRegistrant = new Registrant (h, what, obj); 421 } 422 423 @Override 424 public void unSetOnCatEvent(Handler h) { 425 if (mCatEventRegistrant != null && mCatEventRegistrant.getHandler() == h) { 426 mCatEventRegistrant.clear(); 427 mCatEventRegistrant = null; 428 } 429 } 430 431 @Override 432 public void setOnCatCallSetUp(Handler h, int what, Object obj) { 433 mCatCallSetUpRegistrant = new Registrant (h, what, obj); 434 } 435 436 @Override 437 public void unSetOnCatCallSetUp(Handler h) { 438 if (mCatCallSetUpRegistrant != null && mCatCallSetUpRegistrant.getHandler() == h) { 439 mCatCallSetUpRegistrant.clear(); 440 mCatCallSetUpRegistrant = null; 441 } 442 } 443 444 @Override 445 public void setOnIccSmsFull(Handler h, int what, Object obj) { 446 mIccSmsFullRegistrant = new Registrant (h, what, obj); 447 } 448 449 @Override 450 public void unSetOnIccSmsFull(Handler h) { 451 if (mIccSmsFullRegistrant != null && mIccSmsFullRegistrant.getHandler() == h) { 452 mIccSmsFullRegistrant.clear(); 453 mIccSmsFullRegistrant = null; 454 } 455 } 456 457 @Override 458 public void registerForIccRefresh(Handler h, int what, Object obj) { 459 Registrant r = new Registrant (h, what, obj); 460 mIccRefreshRegistrants.add(r); 461 } 462 @Override 463 public void setOnIccRefresh(Handler h, int what, Object obj) { 464 registerForIccRefresh(h, what, obj); 465 } 466 467 @Override 468 public void setEmergencyCallbackMode(Handler h, int what, Object obj) { 469 mEmergencyCallbackModeRegistrant = new Registrant (h, what, obj); 470 } 471 472 @Override 473 public void unregisterForIccRefresh(Handler h) { 474 mIccRefreshRegistrants.remove(h); 475 } 476 @Override 477 public void unsetOnIccRefresh(Handler h) { 478 unregisterForIccRefresh(h); 479 } 480 481 @Override 482 public void setOnCallRing(Handler h, int what, Object obj) { 483 mRingRegistrant = new Registrant (h, what, obj); 484 } 485 486 @Override 487 public void unSetOnCallRing(Handler h) { 488 if (mRingRegistrant != null && mRingRegistrant.getHandler() == h) { 489 mRingRegistrant.clear(); 490 mRingRegistrant = null; 491 } 492 } 493 494 @Override 495 public void registerForInCallVoicePrivacyOn(Handler h, int what, Object obj) { 496 Registrant r = new Registrant (h, what, obj); 497 mVoicePrivacyOnRegistrants.add(r); 498 } 499 500 @Override 501 public void unregisterForInCallVoicePrivacyOn(Handler h){ 502 mVoicePrivacyOnRegistrants.remove(h); 503 } 504 505 @Override 506 public void registerForInCallVoicePrivacyOff(Handler h, int what, Object obj) { 507 Registrant r = new Registrant (h, what, obj); 508 mVoicePrivacyOffRegistrants.add(r); 509 } 510 511 @Override 512 public void unregisterForInCallVoicePrivacyOff(Handler h){ 513 mVoicePrivacyOffRegistrants.remove(h); 514 } 515 516 @Override 517 public void setOnRestrictedStateChanged(Handler h, int what, Object obj) { 518 mRestrictedStateRegistrant = new Registrant (h, what, obj); 519 } 520 521 @Override 522 public void unSetOnRestrictedStateChanged(Handler h) { 523 if (mRestrictedStateRegistrant != null && mRestrictedStateRegistrant.getHandler() != h) { 524 mRestrictedStateRegistrant.clear(); 525 mRestrictedStateRegistrant = null; 526 } 527 } 528 529 @Override 530 public void registerForDisplayInfo(Handler h, int what, Object obj) { 531 Registrant r = new Registrant (h, what, obj); 532 mDisplayInfoRegistrants.add(r); 533 } 534 535 @Override 536 public void unregisterForDisplayInfo(Handler h) { 537 mDisplayInfoRegistrants.remove(h); 538 } 539 540 @Override 541 public void registerForCallWaitingInfo(Handler h, int what, Object obj) { 542 Registrant r = new Registrant (h, what, obj); 543 mCallWaitingInfoRegistrants.add(r); 544 } 545 546 @Override 547 public void unregisterForCallWaitingInfo(Handler h) { 548 mCallWaitingInfoRegistrants.remove(h); 549 } 550 551 @Override 552 public void registerForSignalInfo(Handler h, int what, Object obj) { 553 Registrant r = new Registrant (h, what, obj); 554 mSignalInfoRegistrants.add(r); 555 } 556 557 public void setOnUnsolOemHookRaw(Handler h, int what, Object obj) { 558 mUnsolOemHookRawRegistrant = new Registrant (h, what, obj); 559 } 560 561 public void unSetOnUnsolOemHookRaw(Handler h) { 562 if (mUnsolOemHookRawRegistrant != null && mUnsolOemHookRawRegistrant.getHandler() == h) { 563 mUnsolOemHookRawRegistrant.clear(); 564 mUnsolOemHookRawRegistrant = null; 565 } 566 } 567 568 @Override 569 public void unregisterForSignalInfo(Handler h) { 570 mSignalInfoRegistrants.remove(h); 571 } 572 573 @Override 574 public void registerForCdmaOtaProvision(Handler h,int what, Object obj){ 575 Registrant r = new Registrant (h, what, obj); 576 mOtaProvisionRegistrants.add(r); 577 } 578 579 @Override 580 public void unregisterForCdmaOtaProvision(Handler h){ 581 mOtaProvisionRegistrants.remove(h); 582 } 583 584 @Override 585 public void registerForNumberInfo(Handler h,int what, Object obj) { 586 Registrant r = new Registrant (h, what, obj); 587 mNumberInfoRegistrants.add(r); 588 } 589 590 @Override 591 public void unregisterForNumberInfo(Handler h){ 592 mNumberInfoRegistrants.remove(h); 593 } 594 595 @Override 596 public void registerForRedirectedNumberInfo(Handler h,int what, Object obj) { 597 Registrant r = new Registrant (h, what, obj); 598 mRedirNumInfoRegistrants.add(r); 599 } 600 601 @Override 602 public void unregisterForRedirectedNumberInfo(Handler h) { 603 mRedirNumInfoRegistrants.remove(h); 604 } 605 606 @Override 607 public void registerForLineControlInfo(Handler h, int what, Object obj) { 608 Registrant r = new Registrant (h, what, obj); 609 mLineControlInfoRegistrants.add(r); 610 } 611 612 @Override 613 public void unregisterForLineControlInfo(Handler h) { 614 mLineControlInfoRegistrants.remove(h); 615 } 616 617 @Override 618 public void registerFoT53ClirlInfo(Handler h,int what, Object obj) { 619 Registrant r = new Registrant (h, what, obj); 620 mT53ClirInfoRegistrants.add(r); 621 } 622 623 @Override 624 public void unregisterForT53ClirInfo(Handler h) { 625 mT53ClirInfoRegistrants.remove(h); 626 } 627 628 @Override 629 public void registerForT53AudioControlInfo(Handler h,int what, Object obj) { 630 Registrant r = new Registrant (h, what, obj); 631 mT53AudCntrlInfoRegistrants.add(r); 632 } 633 634 @Override 635 public void unregisterForT53AudioControlInfo(Handler h) { 636 mT53AudCntrlInfoRegistrants.remove(h); 637 } 638 639 @Override 640 public void registerForRingbackTone(Handler h, int what, Object obj) { 641 Registrant r = new Registrant (h, what, obj); 642 mRingbackToneRegistrants.add(r); 643 } 644 645 @Override 646 public void unregisterForRingbackTone(Handler h) { 647 mRingbackToneRegistrants.remove(h); 648 } 649 650 @Override 651 public void registerForResendIncallMute(Handler h, int what, Object obj) { 652 Registrant r = new Registrant (h, what, obj); 653 mResendIncallMuteRegistrants.add(r); 654 } 655 656 @Override 657 public void unregisterForResendIncallMute(Handler h) { 658 mResendIncallMuteRegistrants.remove(h); 659 } 660 661 @Override 662 public void registerForCdmaSubscriptionChanged(Handler h, int what, Object obj) { 663 Registrant r = new Registrant (h, what, obj); 664 mCdmaSubscriptionChangedRegistrants.add(r); 665 } 666 667 @Override 668 public void unregisterForCdmaSubscriptionChanged(Handler h) { 669 mCdmaSubscriptionChangedRegistrants.remove(h); 670 } 671 672 @Override 673 public void registerForCdmaPrlChanged(Handler h, int what, Object obj) { 674 Registrant r = new Registrant (h, what, obj); 675 mCdmaPrlChangedRegistrants.add(r); 676 } 677 678 @Override 679 public void unregisterForCdmaPrlChanged(Handler h) { 680 mCdmaPrlChangedRegistrants.remove(h); 681 } 682 683 @Override 684 public void registerForExitEmergencyCallbackMode(Handler h, int what, Object obj) { 685 Registrant r = new Registrant (h, what, obj); 686 mExitEmergencyCallbackModeRegistrants.add(r); 687 } 688 689 @Override 690 public void unregisterForExitEmergencyCallbackMode(Handler h) { 691 mExitEmergencyCallbackModeRegistrants.remove(h); 692 } 693 694 @Override 695 public void registerForHardwareConfigChanged(Handler h, int what, Object obj) { 696 Registrant r = new Registrant (h, what, obj); 697 mHardwareConfigChangeRegistrants.add(r); 698 } 699 700 @Override 701 public void unregisterForHardwareConfigChanged(Handler h) { 702 mHardwareConfigChangeRegistrants.remove(h); 703 } 704 705 /** 706 * {@inheritDoc} 707 */ 708 @Override 709 public void registerForRilConnected(Handler h, int what, Object obj) { 710 Registrant r = new Registrant (h, what, obj); 711 mRilConnectedRegistrants.add(r); 712 if (mRilVersion != -1) { 713 r.notifyRegistrant(new AsyncResult(null, new Integer(mRilVersion), null)); 714 } 715 } 716 717 @Override 718 public void unregisterForRilConnected(Handler h) { 719 mRilConnectedRegistrants.remove(h); 720 } 721 722 public void registerForSubscriptionStatusChanged(Handler h, int what, Object obj) { 723 Registrant r = new Registrant (h, what, obj); 724 mSubscriptionStatusRegistrants.add(r); 725 } 726 727 public void unregisterForSubscriptionStatusChanged(Handler h) { 728 mSubscriptionStatusRegistrants.remove(h); 729 } 730 731 //***** Protected Methods 732 /** 733 * Store new RadioState and send notification based on the changes 734 * 735 * This function is called only by RIL.java when receiving unsolicited 736 * RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED 737 * 738 * RadioState has 3 values : RADIO_OFF, RADIO_UNAVAILABLE, RADIO_ON. 739 * 740 * @param newState new RadioState decoded from RIL_UNSOL_RADIO_STATE_CHANGED 741 */ 742 protected void setRadioState(RadioState newState) { 743 RadioState oldState; 744 745 synchronized (mStateMonitor) { 746 oldState = mState; 747 mState = newState; 748 749 if (oldState == mState) { 750 // no state transition 751 return; 752 } 753 754 mRadioStateChangedRegistrants.notifyRegistrants(); 755 756 if (mState.isAvailable() && !oldState.isAvailable()) { 757 mAvailRegistrants.notifyRegistrants(); 758 onRadioAvailable(); 759 } 760 761 if (!mState.isAvailable() && oldState.isAvailable()) { 762 mNotAvailRegistrants.notifyRegistrants(); 763 } 764 765 if (mState.isOn() && !oldState.isOn()) { 766 mOnRegistrants.notifyRegistrants(); 767 } 768 769 if ((!mState.isOn() || !mState.isAvailable()) 770 && !((!oldState.isOn() || !oldState.isAvailable())) 771 ) { 772 mOffOrNotAvailRegistrants.notifyRegistrants(); 773 } 774 } 775 } 776 777 protected void onRadioAvailable() { 778 } 779 780 /** 781 * {@inheritDoc} 782 */ 783 @Override 784 public int getLteOnCdmaMode() { 785 return TelephonyManager.getLteOnCdmaModeStatic(); 786 } 787 788 /** 789 * {@inheritDoc} 790 */ 791 @Override 792 public void registerForCellInfoList(Handler h, int what, Object obj) { 793 Registrant r = new Registrant (h, what, obj); 794 mRilCellInfoListRegistrants.add(r); 795 } 796 @Override 797 public void unregisterForCellInfoList(Handler h) { 798 mRilCellInfoListRegistrants.remove(h); 799 } 800 801 @Override 802 public void registerForSrvccStateChanged(Handler h, int what, Object obj) { 803 Registrant r = new Registrant (h, what, obj); 804 805 mSrvccStateRegistrants.add(r); 806 } 807 808 @Override 809 public void unregisterForSrvccStateChanged(Handler h) { 810 mSrvccStateRegistrants.remove(h); 811 } 812 813 @Override 814 public void testingEmergencyCall() {} 815 816 @Override 817 public int getRilVersion() { 818 return mRilVersion; 819 } 820 821 public void setUiccSubscription(int slotId, int appIndex, int subId, int subStatus, 822 Message response) { 823 } 824 825 public void setDataAllowed(boolean allowed, Message response) { 826 } 827 828 @Override 829 public void requestShutdown(Message result) { 830 } 831 } 832