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