1 /* 2 * Copyright (C) 2008 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 android.telephony; 18 19 import android.Manifest; 20 import android.annotation.NonNull; 21 import android.annotation.RequiresPermission; 22 import android.annotation.SystemApi; 23 import android.compat.annotation.UnsupportedAppUsage; 24 import android.os.Binder; 25 import android.os.Build; 26 import android.os.Handler; 27 import android.os.HandlerExecutor; 28 import android.os.Looper; 29 import android.telephony.Annotation.CallState; 30 import android.telephony.Annotation.DisconnectCauses; 31 import android.telephony.Annotation.PreciseDisconnectCauses; 32 import android.telephony.Annotation.RadioPowerState; 33 import android.telephony.Annotation.SimActivationState; 34 import android.telephony.Annotation.SrvccState; 35 import android.telephony.TelephonyManager.DataEnabledReason; 36 import android.telephony.emergency.EmergencyNumber; 37 import android.telephony.ims.ImsReasonInfo; 38 39 import com.android.internal.annotations.VisibleForTesting; 40 import com.android.internal.telephony.IPhoneStateListener; 41 42 import dalvik.system.VMRuntime; 43 44 import java.lang.ref.WeakReference; 45 import java.util.List; 46 import java.util.Map; 47 import java.util.concurrent.Executor; 48 49 /** 50 * A listener class for monitoring changes in specific telephony states 51 * on the device, including service state, signal strength, message 52 * waiting indicator (voicemail), and others. 53 * <p> 54 * Override the methods for the state that you wish to receive updates for, and 55 * pass your PhoneStateListener object, along with bitwise-or of the LISTEN_ 56 * flags to {@link TelephonyManager#listen TelephonyManager.listen()}. Methods are 57 * called when the state changes, as well as once on initial registration. 58 * <p> 59 * Note that access to some telephony information is 60 * permission-protected. Your application won't receive updates for protected 61 * information unless it has the appropriate permissions declared in 62 * its manifest file. Where permissions apply, they are noted in the 63 * appropriate LISTEN_ flags. 64 * 65 * @deprecated Use {@link TelephonyCallback} instead. 66 */ 67 @Deprecated 68 public class PhoneStateListener { 69 private static final String LOG_TAG = "PhoneStateListener"; 70 private static final boolean DBG = false; // STOPSHIP if true 71 72 /** 73 * Stop listening for updates. 74 * 75 * The PhoneStateListener is not tied to any subscription and unregistered for any update. 76 */ 77 public static final int LISTEN_NONE = 0; 78 79 /** 80 * Listen for changes to the network service state (cellular). 81 * 82 * @see #onServiceStateChanged 83 * @see ServiceState 84 * @deprecated Use {@link TelephonyCallback.ServiceStateListener} instead. 85 */ 86 @Deprecated 87 public static final int LISTEN_SERVICE_STATE = 0x00000001; 88 89 /** 90 * Listen for changes to the network signal strength (cellular). 91 * {@more} 92 * 93 * @see #onSignalStrengthChanged 94 * @deprecated Use {@link TelephonyCallback.SignalStrengthsListener} instead. 95 */ 96 @Deprecated 97 public static final int LISTEN_SIGNAL_STRENGTH = 0x00000002; 98 99 /** 100 * Listen for changes to the message-waiting indicator. 101 * {@more} 102 * Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE 103 * READ_PHONE_STATE} or that the calling app has carrier privileges (see 104 * {@link TelephonyManager#hasCarrierPrivileges}). 105 * <p> 106 * Example: The status bar uses this to determine when to display the 107 * voicemail icon. 108 * 109 * @see #onMessageWaitingIndicatorChanged 110 * @deprecated Use {@link TelephonyCallback.MessageWaitingIndicatorListener} instead. 111 */ 112 @Deprecated 113 @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) 114 public static final int LISTEN_MESSAGE_WAITING_INDICATOR = 0x00000004; 115 116 /** 117 * Listen for changes to the call-forwarding indicator. 118 * {@more} 119 * Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE 120 * READ_PHONE_STATE} or that the calling app has carrier privileges (see 121 * {@link TelephonyManager#hasCarrierPrivileges}). 122 * 123 * @see #onCallForwardingIndicatorChanged 124 * @deprecated Use {@link TelephonyCallback.CallForwardingIndicatorListener} instead. 125 */ 126 @Deprecated 127 @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) 128 public static final int LISTEN_CALL_FORWARDING_INDICATOR = 0x00000008; 129 130 /** 131 * Listen for changes to the device's cell location. Note that 132 * this will result in frequent callbacks to the listener. 133 * {@more} 134 * Requires Permission: {@link android.Manifest.permission#ACCESS_FINE_LOCATION 135 * ACCESS_FINE_LOCATION} 136 * <p> 137 * If you need regular location updates but want more control over 138 * the update interval or location precision, you can set up a listener 139 * through the {@link android.location.LocationManager location manager} 140 * instead. 141 * 142 * @see #onCellLocationChanged 143 * @deprecated Use {@link TelephonyCallback.CellLocationListener} instead. 144 */ 145 @Deprecated 146 @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) 147 public static final int LISTEN_CELL_LOCATION = 0x00000010; 148 149 /** 150 * Listen for changes to the device call state. 151 * {@more} 152 * 153 * @see #onCallStateChanged 154 * @deprecated Use {@link TelephonyCallback.CallStateListener} instead. 155 */ 156 @Deprecated 157 public static final int LISTEN_CALL_STATE = 0x00000020; 158 159 /** 160 * Listen for changes to the data connection state (cellular). 161 * 162 * @see #onDataConnectionStateChanged 163 * @deprecated Use {@link TelephonyCallback.DataConnectionStateListener} instead. 164 */ 165 @Deprecated 166 public static final int LISTEN_DATA_CONNECTION_STATE = 0x00000040; 167 168 /** 169 * Listen for changes to the direction of data traffic on the data 170 * connection (cellular). 171 * {@more} 172 * Example: The status bar uses this to display the appropriate 173 * data-traffic icon. 174 * 175 * @see #onDataActivity 176 * @deprecated Use {@link TelephonyCallback.DataActivityListener} instead. 177 */ 178 @Deprecated 179 public static final int LISTEN_DATA_ACTIVITY = 0x00000080; 180 181 /** 182 * Listen for changes to the network signal strengths (cellular). 183 * <p> 184 * Example: The status bar uses this to control the signal-strength 185 * icon. 186 * 187 * @see #onSignalStrengthsChanged 188 * @deprecated Use {@link TelephonyCallback.SignalStrengthsListener} instead. 189 */ 190 @Deprecated 191 public static final int LISTEN_SIGNAL_STRENGTHS = 0x00000100; 192 193 /** 194 * Listen for changes of the network signal strengths (cellular) always reported from modem, 195 * even in some situations such as the screen of the device is off. 196 * 197 * @see #onSignalStrengthsChanged 198 * 199 * @hide 200 * @deprecated Use TelephonyManager#setSignalStrengthUpdateRequest 201 * instead. 202 */ 203 @Deprecated 204 @RequiresPermission(android.Manifest.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH) 205 public static final int LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH = 0x00000200; 206 207 /** 208 * Listen for changes to observed cell info. 209 * 210 * Listening to this event requires the {@link Manifest.permission#READ_PHONE_STATE} and 211 * {@link Manifest.permission#ACCESS_FINE_LOCATION} 212 * permission. 213 * 214 * @see #onCellInfoChanged 215 * @deprecated Use {@link TelephonyCallback.CellInfoListener} instead. 216 */ 217 @Deprecated 218 @RequiresPermission(allOf = { 219 Manifest.permission.READ_PHONE_STATE, 220 Manifest.permission.ACCESS_FINE_LOCATION 221 }) 222 public static final int LISTEN_CELL_INFO = 0x00000400; 223 224 /** 225 * Listen for {@link android.telephony.Annotation.PreciseCallStates} of ringing, 226 * background and foreground calls. 227 * 228 * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} 229 * or the calling app has carrier privileges 230 * (see {@link TelephonyManager#hasCarrierPrivileges}). 231 * 232 * @hide 233 * @deprecated Use {@link TelephonyCallback.PreciseCallStateListener} instead. 234 */ 235 @Deprecated 236 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) 237 @SystemApi 238 public static final int LISTEN_PRECISE_CALL_STATE = 0x00000800; 239 240 /** 241 * Listen for {@link PreciseDataConnectionState} on the data connection (cellular). 242 * 243 * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} 244 * or the calling app has carrier privileges 245 * (see {@link TelephonyManager#hasCarrierPrivileges}). 246 * 247 * @see #onPreciseDataConnectionStateChanged 248 * @deprecated Use {@link TelephonyCallback.PreciseDataConnectionStateListener} instead. 249 */ 250 @Deprecated 251 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) 252 public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 0x00001000; 253 254 /** 255 * Listen for real time info for all data connections (cellular)). 256 * {@more} 257 * Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE 258 * READ_PRECISE_PHONE_STATE} 259 * @see #onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo) 260 * 261 * @deprecated Use {@link TelephonyManager#requestModemActivityInfo} instead. 262 * @hide 263 */ 264 @Deprecated 265 public static final int LISTEN_DATA_CONNECTION_REAL_TIME_INFO = 0x00002000; 266 267 /** 268 * Listen for changes to the SRVCC state of the active call. 269 * 270 * <p>Requires permission {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} 271 * 272 * @see #onSrvccStateChanged 273 * @hide 274 * @deprecated Use {@link TelephonyCallback.SrvccStateListener} instead. 275 */ 276 @Deprecated 277 @SystemApi 278 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) 279 public static final int LISTEN_SRVCC_STATE_CHANGED = 0x00004000; 280 281 /** 282 * Listen for OEM hook raw event 283 * 284 * @see #onOemHookRawEvent 285 * @hide 286 * @deprecated OEM needs a vendor-extension hal and their apps should use that instead 287 */ 288 @Deprecated 289 public static final int LISTEN_OEM_HOOK_RAW_EVENT = 0x00008000; 290 291 /** 292 * Listen for carrier network changes indicated by a carrier app. 293 * 294 * @see android.service.carrier.CarrierService#notifyCarrierNetworkChange(boolean) 295 * @hide 296 * @deprecated Use {@link TelephonyCallback.CarrierNetworkListener} instead. 297 */ 298 @Deprecated 299 public static final int LISTEN_CARRIER_NETWORK_CHANGE = 0x00010000; 300 301 /** 302 * Listen for changes to the sim voice activation state 303 * 304 * <p>Requires permission {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} 305 * 306 * @see TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATING 307 * @see TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATED 308 * @see TelephonyManager#SIM_ACTIVATION_STATE_DEACTIVATED 309 * @see TelephonyManager#SIM_ACTIVATION_STATE_RESTRICTED 310 * @see TelephonyManager#SIM_ACTIVATION_STATE_UNKNOWN 311 * {@more} 312 * Example: TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATED indicates voice service has been 313 * fully activated 314 * 315 * @see #onVoiceActivationStateChanged 316 * @hide 317 * @deprecated Use {@link TelephonyCallback.VoiceActivationStateListener} instead. 318 */ 319 @Deprecated 320 @SystemApi 321 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) 322 public static final int LISTEN_VOICE_ACTIVATION_STATE = 0x00020000; 323 324 /** 325 * Listen for changes to the sim data activation state 326 * @see TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATING 327 * @see TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATED 328 * @see TelephonyManager#SIM_ACTIVATION_STATE_DEACTIVATED 329 * @see TelephonyManager#SIM_ACTIVATION_STATE_RESTRICTED 330 * @see TelephonyManager#SIM_ACTIVATION_STATE_UNKNOWN 331 * 332 * Example: TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATED indicates data service has been 333 * fully activated 334 * 335 * @see #onDataActivationStateChanged 336 * @hide 337 * @deprecated Use {@link TelephonyCallback.DataActivationStateListener} instead. 338 */ 339 @Deprecated 340 public static final int LISTEN_DATA_ACTIVATION_STATE = 0x00040000; 341 342 /** 343 * Listen for changes to the user mobile data state 344 * 345 * @see #onUserMobileDataStateChanged 346 * @deprecated Use {@link TelephonyCallback.UserMobileDataStateListener} instead. 347 */ 348 @Deprecated 349 public static final int LISTEN_USER_MOBILE_DATA_STATE = 0x00080000; 350 351 /** 352 * Listen for display info changed event. 353 * 354 * For clients compiled on Android 11 SDK, requires permission: 355 * {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling app has carrier 356 * privileges (see {@link TelephonyManager#hasCarrierPrivileges}). 357 * For clients compiled on Android 12 SDK or newer, 358 * {@link android.Manifest.permission#READ_PHONE_STATE} or carrier privileges is not required 359 * anymore. 360 * 361 * @see #onDisplayInfoChanged 362 * @deprecated Use {@link TelephonyCallback.DisplayInfoListener} instead. 363 */ 364 @Deprecated 365 public static final int LISTEN_DISPLAY_INFO_CHANGED = 0x00100000; 366 367 /** 368 * Listen for changes to the phone capability. 369 * 370 * @see #onPhoneCapabilityChanged 371 * @hide 372 * @deprecated Use {@link TelephonyCallback.PhoneCapabilityListener} instead. 373 */ 374 @Deprecated 375 public static final int LISTEN_PHONE_CAPABILITY_CHANGE = 0x00200000; 376 377 /** 378 * Listen for changes to active data subId. Active data subscription is 379 * the current subscription used to setup Cellular Internet data. For example, 380 * it could be the current active opportunistic subscription in use, or the 381 * subscription user selected as default data subscription in DSDS mode. 382 * 383 * @see #onActiveDataSubscriptionIdChanged 384 * @deprecated Use {@link TelephonyCallback.ActiveDataSubscriptionIdListener} instead. 385 */ 386 @Deprecated 387 @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) 388 public static final int LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE = 0x00400000; 389 390 /** 391 * Listen for changes to the radio power state. 392 * 393 * @see #onRadioPowerStateChanged 394 * @hide 395 * @deprecated Use {@link TelephonyCallback.RadioPowerStateListener} instead. 396 */ 397 @Deprecated 398 @SystemApi 399 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) 400 public static final int LISTEN_RADIO_POWER_STATE_CHANGED = 0x00800000; 401 402 /** 403 * Listen for changes to emergency number list based on all active subscriptions. 404 * 405 * <p>Requires permission {@link android.Manifest.permission#READ_PHONE_STATE} or the calling 406 * app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}). 407 * 408 * @deprecated Use {@link TelephonyCallback.EmergencyNumberListListener} instead. 409 */ 410 @Deprecated 411 @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) 412 public static final int LISTEN_EMERGENCY_NUMBER_LIST = 0x01000000; 413 414 /** 415 * Listen for call disconnect causes which contains {@link DisconnectCause} and 416 * {@link PreciseDisconnectCause}. 417 * 418 * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} 419 * or the calling app has carrier privileges 420 * (see {@link TelephonyManager#hasCarrierPrivileges}). 421 * 422 * @deprecated Use {@link TelephonyCallback.CallDisconnectCauseListener} instead. 423 */ 424 @Deprecated 425 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) 426 public static final int LISTEN_CALL_DISCONNECT_CAUSES = 0x02000000; 427 428 /** 429 * Listen for changes to the call attributes of a currently active call. 430 * 431 * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} 432 * or the calling app has carrier privileges 433 * (see {@link TelephonyManager#hasCarrierPrivileges}). 434 * 435 * @see #onCallAttributesChanged 436 * @hide 437 * @deprecated Use {@link TelephonyCallback.CallAttributesListener} instead. 438 */ 439 @Deprecated 440 @SystemApi 441 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) 442 public static final int LISTEN_CALL_ATTRIBUTES_CHANGED = 0x04000000; 443 444 /** 445 * Listen for IMS call disconnect causes which contains 446 * {@link android.telephony.ims.ImsReasonInfo} 447 * 448 * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} 449 * or the calling app has carrier privileges 450 * (see {@link TelephonyManager#hasCarrierPrivileges}). 451 * 452 * @see #onImsCallDisconnectCauseChanged(ImsReasonInfo) 453 * @deprecated Use {@link TelephonyCallback.ImsCallDisconnectCauseListener} instead. 454 */ 455 @Deprecated 456 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) 457 public static final int LISTEN_IMS_CALL_DISCONNECT_CAUSES = 0x08000000; 458 459 /** 460 * Listen for the emergency number placed from an outgoing call. 461 * 462 * @see #onOutgoingEmergencyCall 463 * @hide 464 * @deprecated Use {@link TelephonyCallback.OutgoingEmergencyCallListener} instead. 465 */ 466 @Deprecated 467 @SystemApi 468 @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) 469 public static final int LISTEN_OUTGOING_EMERGENCY_CALL = 0x10000000; 470 471 /** 472 * Listen for the emergency number placed from an outgoing SMS. 473 * 474 * @see #onOutgoingEmergencySms 475 * @hide 476 * @deprecated Use {@link TelephonyCallback.OutgoingEmergencySmsListener} instead. 477 */ 478 @Deprecated 479 @SystemApi 480 @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) 481 public static final int LISTEN_OUTGOING_EMERGENCY_SMS = 0x20000000; 482 483 /** 484 * Listen for Registration Failures. 485 * 486 * Listen for indications that a registration procedure has failed in either the CS or PS 487 * domain. This indication does not necessarily indicate a change of service state, which should 488 * be tracked via {@link #LISTEN_SERVICE_STATE}. 489 * 490 * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} or 491 * the calling app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}). 492 * 493 * <p>Also requires the {@link Manifest.permission#ACCESS_FINE_LOCATION} permission, regardless 494 * of whether the calling app has carrier privileges. 495 * 496 * @see #onRegistrationFailed 497 * @deprecated Use {@link TelephonyCallback.RegistrationFailedListener} instead. 498 */ 499 @Deprecated 500 @RequiresPermission(allOf = { 501 Manifest.permission.READ_PRECISE_PHONE_STATE, 502 Manifest.permission.ACCESS_FINE_LOCATION 503 }) 504 public static final int LISTEN_REGISTRATION_FAILURE = 0x40000000; 505 506 /** 507 * Listen for Barring Information for the current registered / camped cell. 508 * 509 * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} or 510 * the calling app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}). 511 * 512 * <p>Also requires the {@link Manifest.permission#ACCESS_FINE_LOCATION} permission, regardless 513 * of whether the calling app has carrier privileges. 514 * 515 * @see #onBarringInfoChanged 516 * @deprecated Use {@link TelephonyCallback.BarringInfoListener} instead. 517 */ 518 @Deprecated 519 @RequiresPermission(allOf = { 520 Manifest.permission.READ_PRECISE_PHONE_STATE, 521 Manifest.permission.ACCESS_FINE_LOCATION 522 }) 523 public static final int LISTEN_BARRING_INFO = 0x80000000; 524 525 /* 526 * Subscription used to listen to the phone state changes 527 * @hide 528 */ 529 /** @hide */ 530 @UnsupportedAppUsage 531 protected Integer mSubId; 532 533 /** 534 * @hide 535 */ 536 @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) 537 @UnsupportedAppUsage( 538 maxTargetSdk = Build.VERSION_CODES.R, 539 publicAlternatives = "Use {@code TelephonyManager#registerTelephonyCallback(" + 540 "Executor, TelephonyCallback)} instead") 541 public final IPhoneStateListener callback; 542 543 /** 544 * Create a PhoneStateListener for the Phone with the default subscription. 545 * This class requires Looper.myLooper() not return null. 546 */ PhoneStateListener()547 public PhoneStateListener() { 548 this(null, Looper.myLooper()); 549 } 550 551 /** 552 * Create a PhoneStateListener for the Phone with the default subscription 553 * using a particular non-null Looper. 554 * @hide 555 */ 556 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) PhoneStateListener(Looper looper)557 public PhoneStateListener(Looper looper) { 558 this(null, looper); 559 } 560 561 /** 562 * Create a PhoneStateListener for the Phone using the specified subscription. 563 * This class requires Looper.myLooper() not return null. To supply your 564 * own non-null Looper use PhoneStateListener(int subId, Looper looper) below. 565 * @hide 566 */ 567 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) PhoneStateListener(Integer subId)568 public PhoneStateListener(Integer subId) { 569 this(subId, Looper.myLooper()); 570 if (subId != null && VMRuntime.getRuntime().getTargetSdkVersion() 571 >= Build.VERSION_CODES.Q) { 572 throw new IllegalArgumentException("PhoneStateListener with subId: " 573 + subId + " is not supported, use default constructor"); 574 } 575 } 576 /** 577 * Create a PhoneStateListener for the Phone using the specified subscription 578 * and non-null Looper. 579 * @hide 580 */ 581 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) PhoneStateListener(Integer subId, Looper looper)582 public PhoneStateListener(Integer subId, Looper looper) { 583 this(subId, new HandlerExecutor(new Handler(looper))); 584 if (subId != null && VMRuntime.getRuntime().getTargetSdkVersion() 585 >= Build.VERSION_CODES.Q) { 586 throw new IllegalArgumentException("PhoneStateListener with subId: " 587 + subId + " is not supported, use default constructor"); 588 } 589 } 590 591 /** 592 * Create a PhoneStateListener for the Phone using the specified Executor 593 * 594 * <p>Create a PhoneStateListener with a specified Executor for handling necessary callbacks. 595 * The Executor must not be null. 596 * 597 * @param executor a non-null Executor that will execute callbacks for the PhoneStateListener. 598 */ 599 @Deprecated PhoneStateListener(@onNull Executor executor)600 public PhoneStateListener(@NonNull Executor executor) { 601 this(null, executor); 602 } 603 PhoneStateListener(Integer subId, Executor e)604 private PhoneStateListener(Integer subId, Executor e) { 605 if (e == null) { 606 throw new IllegalArgumentException("PhoneStateListener Executor must be non-null"); 607 } 608 mSubId = subId; 609 callback = new IPhoneStateListenerStub(this, e); 610 } 611 612 /** 613 * Callback invoked when device service state changes on the registered subscription. 614 * Note, the registration subId comes from {@link TelephonyManager} object which registers 615 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 616 * If this TelephonyManager object was created with 617 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 618 * subId. Otherwise, this callback applies to 619 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 620 * 621 * The instance of {@link ServiceState} passed as an argument here will have various levels of 622 * location information stripped from it depending on the location permissions that your app 623 * holds. Only apps holding the {@link Manifest.permission#ACCESS_FINE_LOCATION} permission will 624 * receive all the information in {@link ServiceState}, otherwise the cellIdentity will be null 625 * if apps only holding the {@link Manifest.permission#ACCESS_COARSE_LOCATION} permission. 626 * Network operator name in long/short alphanumeric format and numeric id will be null if apps 627 * holding neither {@link android.Manifest.permission#ACCESS_FINE_LOCATION} nor 628 * {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}. 629 * 630 * @see ServiceState#STATE_EMERGENCY_ONLY 631 * @see ServiceState#STATE_IN_SERVICE 632 * @see ServiceState#STATE_OUT_OF_SERVICE 633 * @see ServiceState#STATE_POWER_OFF 634 * @deprecated Use {@link TelephonyCallback.ServiceStateListener} instead. 635 */ 636 @Deprecated onServiceStateChanged(ServiceState serviceState)637 public void onServiceStateChanged(ServiceState serviceState) { 638 // default implementation empty 639 } 640 641 /** 642 * Callback invoked when network signal strength changes on the registered subscription. 643 * Note, the registration subId comes from {@link TelephonyManager} object which registers 644 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 645 * If this TelephonyManager object was created with 646 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 647 * subId. Otherwise, this callback applies to 648 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 649 * 650 * @see ServiceState#STATE_EMERGENCY_ONLY 651 * @see ServiceState#STATE_IN_SERVICE 652 * @see ServiceState#STATE_OUT_OF_SERVICE 653 * @see ServiceState#STATE_POWER_OFF 654 * @deprecated Use {@link #onSignalStrengthsChanged(SignalStrength)} 655 */ 656 @Deprecated onSignalStrengthChanged(int asu)657 public void onSignalStrengthChanged(int asu) { 658 // default implementation empty 659 } 660 661 /** 662 * Callback invoked when the message-waiting indicator changes on the registered subscription. 663 * Note, the registration subId comes from {@link TelephonyManager} object which registers 664 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 665 * If this TelephonyManager object was created with 666 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 667 * subId. Otherwise, this callback applies to 668 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 669 * 670 * @deprecated Use {@link TelephonyCallback.MessageWaitingIndicatorListener} instead. 671 */ 672 @Deprecated 673 @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) onMessageWaitingIndicatorChanged(boolean mwi)674 public void onMessageWaitingIndicatorChanged(boolean mwi) { 675 // default implementation empty 676 } 677 678 /** 679 * Callback invoked when the call-forwarding indicator changes on the registered subscription. 680 * Note, the registration subId comes from {@link TelephonyManager} object which registers 681 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 682 * If this TelephonyManager object was created with 683 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 684 * subId. Otherwise, this callback applies to 685 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 686 * 687 * @deprecated Use {@link TelephonyCallback.CallForwardingIndicatorListener} instead. 688 */ 689 @Deprecated 690 @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) onCallForwardingIndicatorChanged(boolean cfi)691 public void onCallForwardingIndicatorChanged(boolean cfi) { 692 // default implementation empty 693 } 694 695 /** 696 * Callback invoked when device cell location changes on the registered subscription. 697 * Note, the registration subId comes from {@link TelephonyManager} object which registers 698 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 699 * If this TelephonyManager object was created with 700 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 701 * subId. Otherwise, this callback applies to 702 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 703 * 704 * @deprecated Use {@link TelephonyCallback.CellLocationListener} instead. 705 */ 706 @Deprecated 707 @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) onCellLocationChanged(CellLocation location)708 public void onCellLocationChanged(CellLocation location) { 709 // default implementation empty 710 } 711 712 /** 713 * Callback invoked when device call state changes. 714 * <p> 715 * Reports the state of Telephony (mobile) calls on the device for the registered subscription. 716 * <p> 717 * Note: the registration subId comes from {@link TelephonyManager} object which registers 718 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 719 * If this TelephonyManager object was created with 720 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 721 * subId. Otherwise, this callback applies to 722 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 723 * <p> 724 * Note: The state returned here may differ from that returned by 725 * {@link TelephonyManager#getCallState()}. Receivers of this callback should be aware that 726 * calling {@link TelephonyManager#getCallState()} from within this callback may return a 727 * different state than the callback reports. 728 * 729 * Requires Permission: 730 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} for applications 731 * targeting API level 31+. 732 * 733 * @param state call state 734 * @param phoneNumber call phone number. If application does not have 735 * {@link android.Manifest.permission#READ_CALL_LOG READ_CALL_LOG} permission or carrier 736 * privileges (see {@link TelephonyManager#hasCarrierPrivileges}), an empty string will be 737 * passed as an argument. 738 * 739 * @deprecated Use {@link TelephonyCallback.CallStateListener} instead. 740 */ 741 @Deprecated 742 @RequiresPermission(value = android.Manifest.permission.READ_PHONE_STATE, conditional = true) onCallStateChanged(@allState int state, String phoneNumber)743 public void onCallStateChanged(@CallState int state, String phoneNumber) { 744 // default implementation empty 745 } 746 747 /** 748 * Callback invoked when connection state changes on the registered subscription. 749 * Note, the registration subId comes from {@link TelephonyManager} object which registers 750 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 751 * If this TelephonyManager object was created with 752 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 753 * subId. Otherwise, this callback applies to 754 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 755 * 756 * @see TelephonyManager#DATA_DISCONNECTED 757 * @see TelephonyManager#DATA_CONNECTING 758 * @see TelephonyManager#DATA_CONNECTED 759 * @see TelephonyManager#DATA_SUSPENDED 760 * @deprecated Use {@link TelephonyCallback.DataConnectionStateListener} instead. 761 */ 762 @Deprecated onDataConnectionStateChanged(int state)763 public void onDataConnectionStateChanged(int state) { 764 // default implementation empty 765 } 766 767 /** 768 * same as above, but with the network type. Both called. 769 * 770 * @deprecated Use {@link TelephonyCallback.DataConnectionStateListener} instead. 771 */ 772 @Deprecated onDataConnectionStateChanged(int state, int networkType)773 public void onDataConnectionStateChanged(int state, int networkType) { 774 // default implementation empty 775 } 776 777 /** 778 * Callback invoked when data activity state changes on the registered subscription. 779 * Note, the registration subId comes from {@link TelephonyManager} object which registers 780 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 781 * If this TelephonyManager object was created with 782 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 783 * subId. Otherwise, this callback applies to 784 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 785 * 786 * @see TelephonyManager#DATA_ACTIVITY_NONE 787 * @see TelephonyManager#DATA_ACTIVITY_IN 788 * @see TelephonyManager#DATA_ACTIVITY_OUT 789 * @see TelephonyManager#DATA_ACTIVITY_INOUT 790 * @see TelephonyManager#DATA_ACTIVITY_DORMANT 791 * @deprecated Use {@link TelephonyCallback.DataActivityListener} instead. 792 */ 793 @Deprecated onDataActivity(int direction)794 public void onDataActivity(int direction) { 795 // default implementation empty 796 } 797 798 /** 799 * Callback invoked when network signal strengths changes on the registered subscription. 800 * Note, the registration subId comes from {@link TelephonyManager} object which registers 801 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 802 * If this TelephonyManager object was created with 803 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 804 * subId. Otherwise, this callback applies to 805 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 806 * 807 * @deprecated Use {@link TelephonyCallback.SignalStrengthsListener} instead. 808 */ 809 @Deprecated onSignalStrengthsChanged(SignalStrength signalStrength)810 public void onSignalStrengthsChanged(SignalStrength signalStrength) { 811 // default implementation empty 812 } 813 814 /** 815 * Callback invoked when a observed cell info has changed or new cells have been added 816 * or removed on the registered subscription. 817 * Note, the registration subId s from {@link TelephonyManager} object which registers 818 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 819 * If this TelephonyManager object was created with 820 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 821 * subId. Otherwise, this callback applies to 822 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 823 * 824 * @param cellInfo is the list of currently visible cells. 825 * @deprecated Use {@link TelephonyCallback.CellInfoListener} instead. 826 */ 827 @RequiresPermission(allOf = { 828 Manifest.permission.READ_PHONE_STATE, 829 Manifest.permission.ACCESS_FINE_LOCATION 830 }) 831 @Deprecated onCellInfoChanged(List<CellInfo> cellInfo)832 public void onCellInfoChanged(List<CellInfo> cellInfo) { 833 // default implementation empty 834 } 835 836 /** 837 * Callback invoked when precise device call state changes on the registered subscription. 838 * Note, the registration subId comes from {@link TelephonyManager} object which registers 839 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 840 * If this TelephonyManager object was created with 841 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 842 * subId. Otherwise, this callback applies to 843 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 844 * 845 * @param callState {@link PreciseCallState} 846 * @hide 847 * @deprecated Use {@link TelephonyCallback.PreciseCallStateListener} instead. 848 */ 849 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) 850 @SystemApi 851 @Deprecated onPreciseCallStateChanged(@onNull PreciseCallState callState)852 public void onPreciseCallStateChanged(@NonNull PreciseCallState callState) { 853 // default implementation empty 854 } 855 856 /** 857 * Callback invoked when call disconnect cause changes on the registered subscription. 858 * Note, the registration subId comes from {@link TelephonyManager} object which registers 859 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 860 * If this TelephonyManager object was created with 861 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 862 * subId. Otherwise, this callback applies to 863 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 864 * 865 * @param disconnectCause {@link DisconnectCause}. 866 * @param preciseDisconnectCause {@link PreciseDisconnectCause}. 867 * @deprecated Use {@link TelephonyCallback.CallDisconnectCauseListener} instead. 868 */ 869 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) 870 @Deprecated onCallDisconnectCauseChanged(@isconnectCauses int disconnectCause, @PreciseDisconnectCauses int preciseDisconnectCause)871 public void onCallDisconnectCauseChanged(@DisconnectCauses int disconnectCause, 872 @PreciseDisconnectCauses int preciseDisconnectCause) { 873 // default implementation empty 874 } 875 876 /** 877 * Callback invoked when Ims call disconnect cause changes on the registered subscription. 878 * Note, the registration subId comes from {@link TelephonyManager} object which registers 879 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 880 * If this TelephonyManager object was created with 881 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 882 * subId. Otherwise, this callback applies to 883 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 884 * 885 * @param imsReasonInfo {@link ImsReasonInfo} contains details on why IMS call failed. 886 * @deprecated Use {@link TelephonyCallback.ImsCallDisconnectCauseListener} instead. 887 */ 888 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) 889 @Deprecated onImsCallDisconnectCauseChanged(@onNull ImsReasonInfo imsReasonInfo)890 public void onImsCallDisconnectCauseChanged(@NonNull ImsReasonInfo imsReasonInfo) { 891 // default implementation empty 892 } 893 894 /** 895 * Callback providing update about the default/internet data connection on the registered 896 * subscription. 897 * 898 * Note, the registration subId comes from {@link TelephonyManager} object which registers 899 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 900 * If this TelephonyManager object was created with 901 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 902 * subId. Otherwise, this callback applies to 903 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 904 * 905 * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} 906 * or the calling app has carrier privileges 907 * (see {@link TelephonyManager#hasCarrierPrivileges}). 908 * 909 * @param dataConnectionState {@link PreciseDataConnectionState} 910 * @deprecated Use {@link TelephonyCallback.PreciseDataConnectionStateListener} instead. 911 */ 912 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) 913 @Deprecated onPreciseDataConnectionStateChanged( @onNull PreciseDataConnectionState dataConnectionState)914 public void onPreciseDataConnectionStateChanged( 915 @NonNull PreciseDataConnectionState dataConnectionState) { 916 // default implementation empty 917 } 918 919 /** 920 * Callback invoked when data connection real time info changes on the registered subscription. 921 * Note, the registration subId comes from {@link TelephonyManager} object which registers 922 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 923 * If this TelephonyManager object was created with 924 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 925 * subId. Otherwise, this callback applies to 926 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 927 * 928 * @hide 929 * @deprecated Use {@link TelephonyManager#requestModemActivityInfo} 930 */ 931 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 932 @Deprecated onDataConnectionRealTimeInfoChanged( DataConnectionRealTimeInfo dcRtInfo)933 public void onDataConnectionRealTimeInfoChanged( 934 DataConnectionRealTimeInfo dcRtInfo) { 935 // default implementation empty 936 } 937 938 /** 939 * Callback invoked when there has been a change in the Single Radio Voice Call Continuity 940 * (SRVCC) state for the currently active call on the registered subscription. 941 * 942 * Note, the registration subId comes from {@link TelephonyManager} object which registers 943 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 944 * If this TelephonyManager object was created with 945 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 946 * subId. Otherwise, this callback applies to 947 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 948 * 949 * @hide 950 * @deprecated Use {@link TelephonyCallback.SrvccStateListener} instead. 951 */ 952 @SystemApi 953 @Deprecated 954 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) onSrvccStateChanged(@rvccState int srvccState)955 public void onSrvccStateChanged(@SrvccState int srvccState) { 956 // default implementation empty 957 } 958 959 /** 960 * Callback invoked when the SIM voice activation state has changed on the registered 961 * subscription. 962 * Note, the registration subId comes from {@link TelephonyManager} object which registers 963 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 964 * If this TelephonyManager object was created with 965 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 966 * subId. Otherwise, this callback applies to 967 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 968 * 969 * @param state is the current SIM voice activation state 970 * @hide 971 * @deprecated Use {@link TelephonyCallback.VoiceActivationStateListener} instead. 972 */ 973 @SystemApi 974 @Deprecated 975 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) onVoiceActivationStateChanged(@imActivationState int state)976 public void onVoiceActivationStateChanged(@SimActivationState int state) { 977 // default implementation empty 978 } 979 980 /** 981 * Callback invoked when the SIM data activation state has changed on the registered 982 * subscription. 983 * Note, the registration subId comes from {@link TelephonyManager} object which registers 984 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 985 * If this TelephonyManager object was created with 986 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 987 * subId. Otherwise, this callback applies to 988 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 989 * 990 * @param state is the current SIM data activation state 991 * @hide 992 * @deprecated Use {@link TelephonyCallback.DataActivationStateListener} instead. 993 */ 994 @Deprecated onDataActivationStateChanged(@imActivationState int state)995 public void onDataActivationStateChanged(@SimActivationState int state) { 996 // default implementation empty 997 } 998 999 /** 1000 * Callback invoked when the user mobile data state has changed on the registered subscription. 1001 * Note, the registration subId comes from {@link TelephonyManager} object which registers 1002 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 1003 * If this TelephonyManager object was created with 1004 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 1005 * subId. Otherwise, this callback applies to 1006 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 1007 * 1008 * @param enabled indicates whether the current user mobile data state is enabled or disabled. 1009 * @deprecated Use {@link TelephonyCallback.UserMobileDataStateListener} instead. 1010 */ 1011 @Deprecated onUserMobileDataStateChanged(boolean enabled)1012 public void onUserMobileDataStateChanged(boolean enabled) { 1013 // default implementation empty 1014 } 1015 1016 /** 1017 * Callback invoked when the display info has changed on the registered subscription. 1018 * <p> The {@link TelephonyDisplayInfo} contains status information shown to the user based on 1019 * carrier policy. 1020 * 1021 * For clients compiled on Android 11 SDK, requires permission: 1022 * {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling app has carrier 1023 * privileges (see {@link TelephonyManager#hasCarrierPrivileges}). 1024 * For clients compiled on Android 12 SDK or newer, 1025 * {@link android.Manifest.permission#READ_PHONE_STATE} or carrier privileges is not required 1026 * anymore. 1027 * 1028 * @param telephonyDisplayInfo The display information. 1029 * @deprecated Use {@link TelephonyCallback.DisplayInfoListener} instead. 1030 */ 1031 @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) 1032 @Deprecated onDisplayInfoChanged(@onNull TelephonyDisplayInfo telephonyDisplayInfo)1033 public void onDisplayInfoChanged(@NonNull TelephonyDisplayInfo telephonyDisplayInfo) { 1034 // default implementation empty 1035 } 1036 1037 /** 1038 * Callback invoked when the current emergency number list has changed on the registered 1039 * subscription. 1040 * 1041 * Note, the registered subscription is associated with {@link TelephonyManager} object 1042 * on which {@link TelephonyManager#listen(PhoneStateListener, int)} was called. 1043 * If this TelephonyManager object was created with 1044 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 1045 * given subId. Otherwise, this callback applies to 1046 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 1047 * 1048 * @param emergencyNumberList Map associating all active subscriptions on the device with the 1049 * list of emergency numbers originating from that subscription. 1050 * If there are no active subscriptions, the map will contain a 1051 * single entry with 1052 * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} as 1053 * the key and a list of emergency numbers as the value. If no 1054 * emergency number information is available, the value will be null. 1055 * @deprecated Use {@link TelephonyCallback.EmergencyNumberListListener} instead. 1056 */ 1057 @Deprecated 1058 @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) onEmergencyNumberListChanged( @onNull Map<Integer, List<EmergencyNumber>> emergencyNumberList)1059 public void onEmergencyNumberListChanged( 1060 @NonNull Map<Integer, List<EmergencyNumber>> emergencyNumberList) { 1061 // default implementation empty 1062 } 1063 1064 /** 1065 * Callback invoked when an outgoing call is placed to an emergency number. 1066 * 1067 * This method will be called when an emergency call is placed on any subscription (including 1068 * the no-SIM case), regardless of which subscription this listener was registered on. 1069 * 1070 * @param placedEmergencyNumber The {@link EmergencyNumber} the emergency call was placed to. 1071 * @deprecated Use {@link #onOutgoingEmergencyCall(EmergencyNumber, int)}. 1072 * @hide 1073 */ 1074 @SystemApi 1075 @Deprecated 1076 @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) onOutgoingEmergencyCall(@onNull EmergencyNumber placedEmergencyNumber)1077 public void onOutgoingEmergencyCall(@NonNull EmergencyNumber placedEmergencyNumber) { 1078 // default implementation empty 1079 } 1080 1081 /** 1082 * Callback invoked when an outgoing call is placed to an emergency number. 1083 * 1084 * This method will be called when an emergency call is placed on any subscription (including 1085 * the no-SIM case), regardless of which subscription this listener was registered on. 1086 * 1087 * The default implementation of this method calls 1088 * {@link #onOutgoingEmergencyCall(EmergencyNumber)} for backwards compatibility purposes. Do 1089 * not call {@code super(...)} from within your implementation unless you want 1090 * {@link #onOutgoingEmergencyCall(EmergencyNumber)} to be called as well. 1091 * 1092 * @param placedEmergencyNumber The {@link EmergencyNumber} the emergency call was placed to. 1093 * @param subscriptionId The subscription ID used to place the emergency call. If the 1094 * emergency call was placed without a valid subscription (e.g. when there 1095 * are no SIM cards in the device), this will be equal to 1096 * {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}. 1097 * @hide 1098 * @deprecated Use {@link TelephonyCallback.OutgoingEmergencyCallListener} instead. 1099 */ 1100 @SystemApi 1101 @Deprecated 1102 @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) onOutgoingEmergencyCall(@onNull EmergencyNumber placedEmergencyNumber, int subscriptionId)1103 public void onOutgoingEmergencyCall(@NonNull EmergencyNumber placedEmergencyNumber, 1104 int subscriptionId) { 1105 // Default implementation for backwards compatibility 1106 onOutgoingEmergencyCall(placedEmergencyNumber); 1107 } 1108 1109 /** 1110 * Callback invoked when an outgoing SMS is placed to an emergency number. 1111 * 1112 * This method will be called when an emergency sms is sent on any subscription. 1113 * @param sentEmergencyNumber the emergency number {@link EmergencyNumber} the SMS is sent to. 1114 * 1115 * @deprecated Use {@link #onOutgoingEmergencySms(EmergencyNumber, int)}. 1116 * @hide 1117 * @deprecated Use {@link TelephonyCallback.OutgoingEmergencySmsListener} instead. 1118 */ 1119 @SystemApi 1120 @Deprecated 1121 @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) onOutgoingEmergencySms(@onNull EmergencyNumber sentEmergencyNumber)1122 public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber) { 1123 // default implementation empty 1124 } 1125 1126 /** 1127 * Smsback invoked when an outgoing sms is sent to an emergency number. 1128 * 1129 * This method will be called when an emergency sms is sent on any subscription, 1130 * regardless of which subscription this listener was registered on. 1131 * 1132 * The default implementation of this method calls 1133 * {@link #onOutgoingEmergencySms(EmergencyNumber)} for backwards compatibility purposes. Do 1134 * not call {@code super(...)} from within your implementation unless you want 1135 * {@link #onOutgoingEmergencySms(EmergencyNumber)} to be called as well. 1136 * 1137 * @param sentEmergencyNumber The {@link EmergencyNumber} the emergency sms was sent to. 1138 * @param subscriptionId The subscription ID used to send the emergency sms. 1139 * @hide 1140 * @deprecated Use {@link TelephonyCallback.OutgoingEmergencySmsListener} instead. 1141 */ 1142 @SystemApi 1143 @Deprecated onOutgoingEmergencySms(@onNull EmergencyNumber sentEmergencyNumber, int subscriptionId)1144 public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber, 1145 int subscriptionId) { 1146 // Default implementation for backwards compatibility 1147 onOutgoingEmergencySms(sentEmergencyNumber); 1148 } 1149 1150 /** 1151 * Callback invoked when OEM hook raw event is received on the registered subscription. 1152 * Note, the registration subId comes from {@link TelephonyManager} object which registers 1153 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 1154 * If this TelephonyManager object was created with 1155 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 1156 * subId. Otherwise, this callback applies to 1157 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 1158 * 1159 * Requires the READ_PRIVILEGED_PHONE_STATE permission. 1160 * @param rawData is the byte array of the OEM hook raw data. 1161 * @hide 1162 * @deprecated OEM needs a vendor-extension hal and their apps should use that instead 1163 */ 1164 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 1165 @Deprecated onOemHookRawEvent(byte[] rawData)1166 public void onOemHookRawEvent(byte[] rawData) { 1167 // default implementation empty 1168 } 1169 1170 /** 1171 * Callback invoked when phone capability changes. 1172 * Note, this callback triggers regardless of registered subscription. 1173 * 1174 * @param capability the new phone capability 1175 * @hide 1176 * @deprecated Use {@link TelephonyCallback.PhoneCapabilityListener} instead. 1177 */ 1178 @Deprecated onPhoneCapabilityChanged(@onNull PhoneCapability capability)1179 public void onPhoneCapabilityChanged(@NonNull PhoneCapability capability) { 1180 // default implementation empty 1181 } 1182 1183 /** 1184 * Callback invoked when active data subId changes. 1185 * Note, this callback triggers regardless of registered subscription. 1186 * 1187 * Requires the READ_PHONE_STATE permission. 1188 * @param subId current subscription used to setup Cellular Internet data. 1189 * For example, it could be the current active opportunistic subscription in use, 1190 * or the subscription user selected as default data subscription in DSDS mode. 1191 * @deprecated Use {@link TelephonyCallback.ActiveDataSubscriptionIdListener} instead. 1192 */ 1193 @Deprecated 1194 @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) onActiveDataSubscriptionIdChanged(int subId)1195 public void onActiveDataSubscriptionIdChanged(int subId) { 1196 // default implementation empty 1197 } 1198 1199 /** 1200 * Callback invoked when the call attributes changes on the registered subscription. 1201 * Note, the registration subId comes from {@link TelephonyManager} object which registers 1202 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 1203 * If this TelephonyManager object was created with 1204 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 1205 * subId. Otherwise, this callback applies to 1206 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 1207 * 1208 * Requires the READ_PRECISE_PHONE_STATE permission. 1209 * @param callAttributes the call attributes 1210 * @hide 1211 * @deprecated Use {@link TelephonyCallback.CallAttributesListener} instead. 1212 */ 1213 @SystemApi 1214 @Deprecated 1215 @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) onCallAttributesChanged(@onNull CallAttributes callAttributes)1216 public void onCallAttributesChanged(@NonNull CallAttributes callAttributes) { 1217 // default implementation empty 1218 } 1219 1220 /** 1221 * Callback invoked when modem radio power state changes on the registered subscription. 1222 * Note, the registration subId comes from {@link TelephonyManager} object which registers 1223 * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. 1224 * If this TelephonyManager object was created with 1225 * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the 1226 * subId. Otherwise, this callback applies to 1227 * {@link SubscriptionManager#getDefaultSubscriptionId()}. 1228 * 1229 * Requires permission {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} 1230 * 1231 * @param state the modem radio power state 1232 * @hide 1233 * @deprecated Use {@link TelephonyCallback.RadioPowerStateListener} instead. 1234 */ 1235 @SystemApi 1236 @Deprecated 1237 @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) onRadioPowerStateChanged(@adioPowerState int state)1238 public void onRadioPowerStateChanged(@RadioPowerState int state) { 1239 // default implementation empty 1240 } 1241 1242 /** 1243 * Callback invoked when telephony has received notice from a carrier 1244 * app that a network action that could result in connectivity loss 1245 * has been requested by an app using 1246 * {@link android.telephony.TelephonyManager#notifyCarrierNetworkChange(boolean)} 1247 * 1248 * Note, this callback is pinned to the registered subscription and will be invoked when 1249 * the notifying carrier app has carrier privilege rule on the registered 1250 * subscription. {@link android.telephony.TelephonyManager#hasCarrierPrivileges} 1251 * 1252 * @param active Whether the carrier network change is or shortly 1253 * will be active. This value is true to indicate 1254 * showing alternative UI and false to stop. 1255 * @hide 1256 * @deprecated Use {@link TelephonyCallback.CarrierNetworkListener} instead. 1257 */ 1258 @Deprecated onCarrierNetworkChange(boolean active)1259 public void onCarrierNetworkChange(boolean active) { 1260 // default implementation empty 1261 } 1262 1263 /** 1264 * Report that Registration or a Location/Routing/Tracking Area update has failed. 1265 * 1266 * <p>Indicate whenever a registration procedure, including a location, routing, or tracking 1267 * area update fails. This includes procedures that do not necessarily result in a change of 1268 * the modem's registration status. If the modem's registration status changes, that is 1269 * reflected in the onNetworkStateChanged() and subsequent get{Voice/Data}RegistrationState(). 1270 * 1271 * <p>Because registration failures are ephemeral, this callback is not sticky. 1272 * Registrants will not receive the most recent past value when registering. 1273 * 1274 * @param cellIdentity the CellIdentity, which must include the globally unique identifier 1275 * for the cell (for example, all components of the CGI or ECGI). 1276 * @param chosenPlmn a 5 or 6 digit alphanumeric PLMN (MCC|MNC) among those broadcast by the 1277 * cell that was chosen for the failed registration attempt. 1278 * @param domain DOMAIN_CS, DOMAIN_PS or both in case of a combined procedure. 1279 * @param causeCode the primary failure cause code of the procedure. 1280 * For GSM/UMTS (MM), values are in TS 24.008 Sec 10.5.95 1281 * For GSM/UMTS (GMM), values are in TS 24.008 Sec 10.5.147 1282 * For LTE (EMM), cause codes are TS 24.301 Sec 9.9.3.9 1283 * For NR (5GMM), cause codes are TS 24.501 Sec 9.11.3.2 1284 * Integer.MAX_VALUE if this value is unused. 1285 * @param additionalCauseCode the cause code of any secondary/combined procedure if appropriate. 1286 * For UMTS, if a combined attach succeeds for PS only, then the GMM cause code shall be 1287 * included as an additionalCauseCode. For LTE (ESM), cause codes are in 1288 * TS 24.301 9.9.4.4. Integer.MAX_VALUE if this value is unused. 1289 * @deprecated Use {@link TelephonyCallback.RegistrationFailedListener} instead. 1290 */ 1291 @Deprecated 1292 @RequiresPermission(allOf = { 1293 Manifest.permission.READ_PRECISE_PHONE_STATE, 1294 Manifest.permission.ACCESS_FINE_LOCATION 1295 }) onRegistrationFailed(@onNull CellIdentity cellIdentity, @NonNull String chosenPlmn, int domain, int causeCode, int additionalCauseCode)1296 public void onRegistrationFailed(@NonNull CellIdentity cellIdentity, @NonNull String chosenPlmn, 1297 int domain, int causeCode, int additionalCauseCode) { 1298 // default implementation empty 1299 } 1300 1301 /** 1302 * Report updated barring information for the current camped/registered cell. 1303 * 1304 * <p>Barring info is provided for all services applicable to the current camped/registered 1305 * cell, for the registered PLMN and current access class/access category. 1306 * 1307 * @param barringInfo for all services on the current cell. 1308 * @see android.telephony.BarringInfo 1309 * @deprecated Use {@link TelephonyCallback.BarringInfoListener} instead. 1310 */ 1311 @Deprecated 1312 @RequiresPermission(allOf = { 1313 Manifest.permission.READ_PRECISE_PHONE_STATE, 1314 Manifest.permission.ACCESS_FINE_LOCATION 1315 }) onBarringInfoChanged(@onNull BarringInfo barringInfo)1316 public void onBarringInfoChanged(@NonNull BarringInfo barringInfo) { 1317 // default implementation empty 1318 } 1319 1320 1321 1322 /** 1323 * The callback methods need to be called on the handler thread where 1324 * this object was created. If the binder did that for us it'd be nice. 1325 * 1326 * Using a static class and weak reference here to avoid memory leak caused by the 1327 * IPhoneStateListener.Stub callback retaining references to the outside PhoneStateListeners: 1328 * even caller has been destroyed and "un-registered" the PhoneStateListener, it is still not 1329 * eligible for GC given the references coming from: 1330 * Native Stack --> PhoneStateListener --> Context (Activity). 1331 * memory of caller's context will be collected after GC from service side get triggered 1332 */ 1333 private static class IPhoneStateListenerStub extends IPhoneStateListener.Stub { 1334 private WeakReference<PhoneStateListener> mPhoneStateListenerWeakRef; 1335 private Executor mExecutor; 1336 IPhoneStateListenerStub(PhoneStateListener phoneStateListener, Executor executor)1337 IPhoneStateListenerStub(PhoneStateListener phoneStateListener, Executor executor) { 1338 mPhoneStateListenerWeakRef = new WeakReference<PhoneStateListener>(phoneStateListener); 1339 mExecutor = executor; 1340 } 1341 onServiceStateChanged(ServiceState serviceState)1342 public void onServiceStateChanged(ServiceState serviceState) { 1343 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1344 if (psl == null) return; 1345 1346 Binder.withCleanCallingIdentity( 1347 () -> mExecutor.execute(() -> psl.onServiceStateChanged(serviceState))); 1348 } 1349 onSignalStrengthChanged(int asu)1350 public void onSignalStrengthChanged(int asu) { 1351 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1352 if (psl == null) return; 1353 1354 Binder.withCleanCallingIdentity( 1355 () -> mExecutor.execute(() -> psl.onSignalStrengthChanged(asu))); 1356 } 1357 onMessageWaitingIndicatorChanged(boolean mwi)1358 public void onMessageWaitingIndicatorChanged(boolean mwi) { 1359 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1360 if (psl == null) return; 1361 1362 Binder.withCleanCallingIdentity( 1363 () -> mExecutor.execute(() -> psl.onMessageWaitingIndicatorChanged(mwi))); 1364 } 1365 onCallForwardingIndicatorChanged(boolean cfi)1366 public void onCallForwardingIndicatorChanged(boolean cfi) { 1367 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1368 if (psl == null) return; 1369 1370 Binder.withCleanCallingIdentity( 1371 () -> mExecutor.execute(() -> psl.onCallForwardingIndicatorChanged(cfi))); 1372 } 1373 onCellLocationChanged(CellIdentity cellIdentity)1374 public void onCellLocationChanged(CellIdentity cellIdentity) { 1375 // There is no system/public API to create an CellIdentity in system server, 1376 // so the server pass a null to indicate an empty initial location. 1377 CellLocation location = 1378 cellIdentity == null ? CellLocation.getEmpty() : cellIdentity.asCellLocation(); 1379 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1380 if (psl == null) return; 1381 1382 Binder.withCleanCallingIdentity( 1383 () -> mExecutor.execute(() -> psl.onCellLocationChanged(location))); 1384 } 1385 onLegacyCallStateChanged(int state, String incomingNumber)1386 public void onLegacyCallStateChanged(int state, String incomingNumber) { 1387 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1388 if (psl == null) return; 1389 1390 Binder.withCleanCallingIdentity( 1391 () -> mExecutor.execute(() -> psl.onCallStateChanged(state, incomingNumber))); 1392 } 1393 onCallStateChanged(int state)1394 public void onCallStateChanged(int state) { 1395 // Only used for the new TelephonyCallback class 1396 } 1397 onDataConnectionStateChanged(int state, int networkType)1398 public void onDataConnectionStateChanged(int state, int networkType) { 1399 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1400 if (psl == null) return; 1401 1402 if (state == TelephonyManager.DATA_DISCONNECTING 1403 && VMRuntime.getRuntime().getTargetSdkVersion() < Build.VERSION_CODES.R) { 1404 Binder.withCleanCallingIdentity(() -> mExecutor.execute( 1405 () -> { 1406 psl.onDataConnectionStateChanged( 1407 TelephonyManager.DATA_CONNECTED, networkType); 1408 psl.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED); 1409 })); 1410 } else { 1411 Binder.withCleanCallingIdentity(() -> mExecutor.execute( 1412 () -> { 1413 psl.onDataConnectionStateChanged(state, networkType); 1414 psl.onDataConnectionStateChanged(state); 1415 })); 1416 } 1417 } 1418 onDataActivity(int direction)1419 public void onDataActivity(int direction) { 1420 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1421 if (psl == null) return; 1422 1423 Binder.withCleanCallingIdentity( 1424 () -> mExecutor.execute(() -> psl.onDataActivity(direction))); 1425 } 1426 onSignalStrengthsChanged(SignalStrength signalStrength)1427 public void onSignalStrengthsChanged(SignalStrength signalStrength) { 1428 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1429 if (psl == null) return; 1430 1431 Binder.withCleanCallingIdentity( 1432 () -> mExecutor.execute(() -> psl.onSignalStrengthsChanged(signalStrength))); 1433 } 1434 onCellInfoChanged(List<CellInfo> cellInfo)1435 public void onCellInfoChanged(List<CellInfo> cellInfo) { 1436 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1437 if (psl == null) return; 1438 1439 Binder.withCleanCallingIdentity( 1440 () -> mExecutor.execute(() -> psl.onCellInfoChanged(cellInfo))); 1441 } 1442 onPreciseCallStateChanged(PreciseCallState callState)1443 public void onPreciseCallStateChanged(PreciseCallState callState) { 1444 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1445 if (psl == null) return; 1446 1447 Binder.withCleanCallingIdentity( 1448 () -> mExecutor.execute(() -> psl.onPreciseCallStateChanged(callState))); 1449 } 1450 onCallDisconnectCauseChanged(int disconnectCause, int preciseDisconnectCause)1451 public void onCallDisconnectCauseChanged(int disconnectCause, int preciseDisconnectCause) { 1452 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1453 if (psl == null) return; 1454 1455 Binder.withCleanCallingIdentity( 1456 () -> mExecutor.execute(() -> psl.onCallDisconnectCauseChanged( 1457 disconnectCause, preciseDisconnectCause))); 1458 } 1459 onPreciseDataConnectionStateChanged( PreciseDataConnectionState dataConnectionState)1460 public void onPreciseDataConnectionStateChanged( 1461 PreciseDataConnectionState dataConnectionState) { 1462 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1463 if (psl == null) return; 1464 1465 Binder.withCleanCallingIdentity( 1466 () -> mExecutor.execute( 1467 () -> psl.onPreciseDataConnectionStateChanged(dataConnectionState))); 1468 } 1469 onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo)1470 public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) { 1471 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1472 if (psl == null) return; 1473 1474 Binder.withCleanCallingIdentity( 1475 () -> mExecutor.execute( 1476 () -> psl.onDataConnectionRealTimeInfoChanged(dcRtInfo))); 1477 } 1478 onSrvccStateChanged(int state)1479 public void onSrvccStateChanged(int state) { 1480 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1481 if (psl == null) return; 1482 1483 Binder.withCleanCallingIdentity( 1484 () -> mExecutor.execute(() -> psl.onSrvccStateChanged(state))); 1485 } 1486 onVoiceActivationStateChanged(int activationState)1487 public void onVoiceActivationStateChanged(int activationState) { 1488 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1489 if (psl == null) return; 1490 1491 Binder.withCleanCallingIdentity( 1492 () -> mExecutor.execute( 1493 () -> psl.onVoiceActivationStateChanged(activationState))); 1494 } 1495 onDataActivationStateChanged(int activationState)1496 public void onDataActivationStateChanged(int activationState) { 1497 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1498 if (psl == null) return; 1499 1500 Binder.withCleanCallingIdentity( 1501 () -> mExecutor.execute( 1502 () -> psl.onDataActivationStateChanged(activationState))); 1503 } 1504 onUserMobileDataStateChanged(boolean enabled)1505 public void onUserMobileDataStateChanged(boolean enabled) { 1506 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1507 if (psl == null) return; 1508 1509 Binder.withCleanCallingIdentity( 1510 () -> mExecutor.execute( 1511 () -> psl.onUserMobileDataStateChanged(enabled))); 1512 } 1513 onDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo)1514 public void onDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo) { 1515 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1516 if (psl == null) return; 1517 1518 Binder.withCleanCallingIdentity( 1519 () -> mExecutor.execute( 1520 () -> psl.onDisplayInfoChanged(telephonyDisplayInfo))); 1521 } 1522 onOemHookRawEvent(byte[] rawData)1523 public void onOemHookRawEvent(byte[] rawData) { 1524 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1525 if (psl == null) return; 1526 1527 Binder.withCleanCallingIdentity( 1528 () -> mExecutor.execute(() -> psl.onOemHookRawEvent(rawData))); 1529 } 1530 onCarrierNetworkChange(boolean active)1531 public void onCarrierNetworkChange(boolean active) { 1532 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1533 if (psl == null) return; 1534 1535 Binder.withCleanCallingIdentity( 1536 () -> mExecutor.execute(() -> psl.onCarrierNetworkChange(active))); 1537 } 1538 onEmergencyNumberListChanged(Map emergencyNumberList)1539 public void onEmergencyNumberListChanged(Map emergencyNumberList) { 1540 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1541 if (psl == null) return; 1542 1543 Binder.withCleanCallingIdentity( 1544 () -> mExecutor.execute( 1545 () -> psl.onEmergencyNumberListChanged(emergencyNumberList))); 1546 } 1547 onOutgoingEmergencyCall(@onNull EmergencyNumber placedEmergencyNumber, int subscriptionId)1548 public void onOutgoingEmergencyCall(@NonNull EmergencyNumber placedEmergencyNumber, 1549 int subscriptionId) { 1550 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1551 if (psl == null) return; 1552 1553 Binder.withCleanCallingIdentity( 1554 () -> mExecutor.execute( 1555 () -> psl.onOutgoingEmergencyCall(placedEmergencyNumber, 1556 subscriptionId))); 1557 } 1558 onOutgoingEmergencySms(@onNull EmergencyNumber sentEmergencyNumber, int subscriptionId)1559 public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber, 1560 int subscriptionId) { 1561 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1562 if (psl == null) return; 1563 1564 Binder.withCleanCallingIdentity( 1565 () -> mExecutor.execute( 1566 () -> psl.onOutgoingEmergencySms(sentEmergencyNumber, subscriptionId))); 1567 } 1568 onPhoneCapabilityChanged(PhoneCapability capability)1569 public void onPhoneCapabilityChanged(PhoneCapability capability) { 1570 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1571 if (psl == null) return; 1572 1573 Binder.withCleanCallingIdentity( 1574 () -> mExecutor.execute(() -> psl.onPhoneCapabilityChanged(capability))); 1575 } 1576 onRadioPowerStateChanged(@adioPowerState int state)1577 public void onRadioPowerStateChanged(@RadioPowerState int state) { 1578 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1579 if (psl == null) return; 1580 1581 Binder.withCleanCallingIdentity( 1582 () -> mExecutor.execute(() -> psl.onRadioPowerStateChanged(state))); 1583 } 1584 onCallAttributesChanged(CallAttributes callAttributes)1585 public void onCallAttributesChanged(CallAttributes callAttributes) { 1586 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1587 if (psl == null) return; 1588 1589 Binder.withCleanCallingIdentity( 1590 () -> mExecutor.execute(() -> psl.onCallAttributesChanged(callAttributes))); 1591 } 1592 onActiveDataSubIdChanged(int subId)1593 public void onActiveDataSubIdChanged(int subId) { 1594 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1595 if (psl == null) return; 1596 1597 Binder.withCleanCallingIdentity( 1598 () -> mExecutor.execute(() -> psl.onActiveDataSubscriptionIdChanged(subId))); 1599 } 1600 onImsCallDisconnectCauseChanged(ImsReasonInfo disconnectCause)1601 public void onImsCallDisconnectCauseChanged(ImsReasonInfo disconnectCause) { 1602 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1603 if (psl == null) return; 1604 1605 Binder.withCleanCallingIdentity( 1606 () -> mExecutor.execute( 1607 () -> psl.onImsCallDisconnectCauseChanged(disconnectCause))); 1608 } 1609 onRegistrationFailed(@onNull CellIdentity cellIdentity, @NonNull String chosenPlmn, int domain, int causeCode, int additionalCauseCode)1610 public void onRegistrationFailed(@NonNull CellIdentity cellIdentity, 1611 @NonNull String chosenPlmn, int domain, int causeCode, int additionalCauseCode) { 1612 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1613 if (psl == null) return; 1614 1615 Binder.withCleanCallingIdentity( 1616 () -> mExecutor.execute(() -> psl.onRegistrationFailed( 1617 cellIdentity, chosenPlmn, domain, causeCode, additionalCauseCode))); 1618 // default implementation empty 1619 } 1620 onBarringInfoChanged(BarringInfo barringInfo)1621 public void onBarringInfoChanged(BarringInfo barringInfo) { 1622 PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); 1623 if (psl == null) return; 1624 1625 Binder.withCleanCallingIdentity( 1626 () -> mExecutor.execute(() -> psl.onBarringInfoChanged(barringInfo))); 1627 } 1628 onPhysicalChannelConfigChanged(List<PhysicalChannelConfig> configs)1629 public void onPhysicalChannelConfigChanged(List<PhysicalChannelConfig> configs) { 1630 // default implementation empty 1631 } 1632 onDataEnabledChanged(boolean enabled, @DataEnabledReason int reason)1633 public void onDataEnabledChanged(boolean enabled, @DataEnabledReason int reason) { 1634 // default implementation empty 1635 } 1636 onAllowedNetworkTypesChanged(int reason, long allowedNetworkType)1637 public void onAllowedNetworkTypesChanged(int reason, long allowedNetworkType) { 1638 // default implementation empty 1639 } 1640 onLinkCapacityEstimateChanged( List<LinkCapacityEstimate> linkCapacityEstimateList)1641 public void onLinkCapacityEstimateChanged( 1642 List<LinkCapacityEstimate> linkCapacityEstimateList) { 1643 // default implementation empty 1644 } 1645 } 1646 log(String s)1647 private void log(String s) { 1648 Rlog.d(LOG_TAG, s); 1649 } 1650 } 1651