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