1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.telephony; 18 19 import static android.telephony.TelephonyManager.HAL_SERVICE_RADIO; 20 21 import android.annotation.NonNull; 22 import android.annotation.Nullable; 23 import android.app.BroadcastOptions; 24 import android.compat.annotation.UnsupportedAppUsage; 25 import android.content.Context; 26 import android.content.Intent; 27 import android.content.SharedPreferences; 28 import android.content.res.Configuration; 29 import android.hardware.radio.modem.ImeiInfo; 30 import android.net.Uri; 31 import android.os.AsyncResult; 32 import android.os.Build; 33 import android.os.Handler; 34 import android.os.Looper; 35 import android.os.Message; 36 import android.os.PersistableBundle; 37 import android.os.Registrant; 38 import android.os.RegistrantList; 39 import android.os.SystemClock; 40 import android.os.SystemProperties; 41 import android.os.UserHandle; 42 import android.os.UserManager; 43 import android.os.WorkSource; 44 import android.preference.PreferenceManager; 45 import android.sysprop.TelephonyProperties; 46 import android.telecom.VideoProfile; 47 import android.telephony.AccessNetworkConstants; 48 import android.telephony.Annotation.SrvccState; 49 import android.telephony.CarrierConfigManager; 50 import android.telephony.CarrierRestrictionRules; 51 import android.telephony.CellBroadcastIdRange; 52 import android.telephony.CellIdentity; 53 import android.telephony.CellInfo; 54 import android.telephony.ClientRequestStats; 55 import android.telephony.DomainSelectionService; 56 import android.telephony.ImsiEncryptionInfo; 57 import android.telephony.LinkCapacityEstimate; 58 import android.telephony.NetworkRegistrationInfo; 59 import android.telephony.PhoneStateListener; 60 import android.telephony.PhysicalChannelConfig; 61 import android.telephony.PreciseDataConnectionState; 62 import android.telephony.RadioAccessFamily; 63 import android.telephony.RadioAccessSpecifier; 64 import android.telephony.ServiceState; 65 import android.telephony.SignalStrength; 66 import android.telephony.SubscriptionInfo; 67 import android.telephony.SubscriptionManager; 68 import android.telephony.TelephonyDisplayInfo; 69 import android.telephony.TelephonyManager; 70 import android.telephony.TelephonyManager.HalService; 71 import android.telephony.emergency.EmergencyNumber; 72 import android.telephony.ims.RegistrationManager; 73 import android.telephony.ims.feature.MmTelFeature; 74 import android.telephony.ims.stub.ImsRegistrationImplBase; 75 import android.telephony.satellite.SatelliteDatagram; 76 import android.text.TextUtils; 77 import android.util.LocalLog; 78 import android.util.Log; 79 import android.util.Xml; 80 81 import com.android.ims.ImsCall; 82 import com.android.ims.ImsConfig; 83 import com.android.ims.ImsException; 84 import com.android.ims.ImsManager; 85 import com.android.internal.R; 86 import com.android.internal.annotations.VisibleForTesting; 87 import com.android.internal.telephony.data.AccessNetworksManager; 88 import com.android.internal.telephony.data.DataNetworkController; 89 import com.android.internal.telephony.data.DataSettingsManager; 90 import com.android.internal.telephony.data.LinkBandwidthEstimator; 91 import com.android.internal.telephony.domainselection.DomainSelectionResolver; 92 import com.android.internal.telephony.emergency.EmergencyConstants; 93 import com.android.internal.telephony.emergency.EmergencyNumberTracker; 94 import com.android.internal.telephony.emergency.EmergencyStateTracker; 95 import com.android.internal.telephony.imsphone.ImsCallInfo; 96 import com.android.internal.telephony.imsphone.ImsPhone; 97 import com.android.internal.telephony.imsphone.ImsPhoneCall; 98 import com.android.internal.telephony.metrics.SmsStats; 99 import com.android.internal.telephony.metrics.VoiceCallSessionStats; 100 import com.android.internal.telephony.subscription.SubscriptionInfoInternal; 101 import com.android.internal.telephony.subscription.SubscriptionManagerService; 102 import com.android.internal.telephony.test.SimulatedRadioControl; 103 import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType; 104 import com.android.internal.telephony.uicc.IccFileHandler; 105 import com.android.internal.telephony.uicc.IccRecords; 106 import com.android.internal.telephony.uicc.IsimRecords; 107 import com.android.internal.telephony.uicc.UiccCard; 108 import com.android.internal.telephony.uicc.UiccCardApplication; 109 import com.android.internal.telephony.uicc.UiccController; 110 import com.android.internal.telephony.uicc.UiccPort; 111 import com.android.internal.telephony.uicc.UsimServiceTable; 112 import com.android.internal.telephony.util.TelephonyUtils; 113 import com.android.internal.util.XmlUtils; 114 import com.android.telephony.Rlog; 115 116 import org.xmlpull.v1.XmlPullParser; 117 import org.xmlpull.v1.XmlPullParserException; 118 119 import java.io.File; 120 import java.io.FileDescriptor; 121 import java.io.FileNotFoundException; 122 import java.io.FileReader; 123 import java.io.IOException; 124 import java.io.PrintWriter; 125 import java.util.ArrayList; 126 import java.util.Collections; 127 import java.util.HashMap; 128 import java.util.HashSet; 129 import java.util.List; 130 import java.util.Locale; 131 import java.util.Map; 132 import java.util.Set; 133 import java.util.concurrent.atomic.AtomicReference; 134 import java.util.function.Consumer; 135 import java.util.stream.Collectors; 136 137 /** 138 * (<em>Not for SDK use</em>) 139 * A base implementation for the com.android.internal.telephony.Phone interface. 140 * 141 * Note that implementations of Phone.java are expected to be used 142 * from a single application thread. This should be the same thread that 143 * originally called PhoneFactory to obtain the interface. 144 * 145 * {@hide} 146 * 147 */ 148 149 public abstract class Phone extends Handler implements PhoneInternalInterface { 150 private static final String LOG_TAG = "Phone"; 151 152 protected final static Object lockForRadioTechnologyChange = new Object(); 153 154 protected final int USSD_MAX_QUEUE = 10; 155 156 // Key used to read and write the saved network selection numeric value 157 public static final String NETWORK_SELECTION_KEY = "network_selection_key"; 158 // Key used to read and write the saved network selection operator name 159 public static final String NETWORK_SELECTION_NAME_KEY = "network_selection_name_key"; 160 // Key used to read and write the saved network selection operator short name 161 public static final String NETWORK_SELECTION_SHORT_KEY = "network_selection_short_key"; 162 163 164 // Key used to read/write "disable data connection on boot" pref (used for testing) 165 public static final String DATA_DISABLED_ON_BOOT_KEY = "disabled_on_boot_key"; 166 167 // Key used to read/write data_roaming_is_user_setting pref 168 public static final String DATA_ROAMING_IS_USER_SETTING_KEY = 169 "data_roaming_is_user_setting_key"; 170 171 // Default value when there has been no last emergency SMS time recorded yet. 172 private static final int EMERGENCY_SMS_NO_TIME_RECORDED = -1; 173 // The max timer value that the platform can be in emergency SMS mode (5 minutes). 174 private static final int EMERGENCY_SMS_TIMER_MAX_MS = 300000; 175 176 /* Event Constants */ 177 protected static final int EVENT_RADIO_AVAILABLE = 1; 178 /** Supplementary Service Notification received. */ 179 protected static final int EVENT_SSN = 2; 180 protected static final int EVENT_SIM_RECORDS_LOADED = 3; 181 private static final int EVENT_MMI_DONE = 4; 182 protected static final int EVENT_RADIO_ON = 5; 183 protected static final int EVENT_GET_BASEBAND_VERSION_DONE = 6; 184 protected static final int EVENT_USSD = 7; 185 @VisibleForTesting 186 public static final int EVENT_RADIO_OFF_OR_NOT_AVAILABLE = 8; 187 private static final int EVENT_GET_SIM_STATUS_DONE = 11; 188 protected static final int EVENT_SET_CALL_FORWARD_DONE = 12; 189 protected static final int EVENT_GET_CALL_FORWARD_DONE = 13; 190 protected static final int EVENT_CALL_RING = 14; 191 private static final int EVENT_CALL_RING_CONTINUE = 15; 192 193 // Used to intercept the carrier selection calls so that 194 // we can save the values. 195 private static final int EVENT_SET_NETWORK_MANUAL_COMPLETE = 16; 196 private static final int EVENT_SET_NETWORK_AUTOMATIC_COMPLETE = 17; 197 protected static final int EVENT_SET_CLIR_COMPLETE = 18; 198 protected static final int EVENT_REGISTERED_TO_NETWORK = 19; 199 protected static final int EVENT_SET_VM_NUMBER_DONE = 20; 200 // Events for CDMA support 201 protected static final int EVENT_GET_DEVICE_IDENTITY_DONE = 21; 202 protected static final int EVENT_RUIM_RECORDS_LOADED = 22; 203 protected static final int EVENT_NV_READY = 23; 204 private static final int EVENT_SET_ENHANCED_VP = 24; 205 @VisibleForTesting 206 public static final int EVENT_EMERGENCY_CALLBACK_MODE_ENTER = 25; 207 protected static final int EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE = 26; 208 protected static final int EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED = 27; 209 // other 210 protected static final int EVENT_SET_NETWORK_AUTOMATIC = 28; 211 protected static final int EVENT_ICC_RECORD_EVENTS = 29; 212 @VisibleForTesting 213 protected static final int EVENT_ICC_CHANGED = 30; 214 // Single Radio Voice Call Continuity 215 @VisibleForTesting 216 protected static final int EVENT_SRVCC_STATE_CHANGED = 31; 217 private static final int EVENT_INITIATE_SILENT_REDIAL = 32; 218 private static final int EVENT_RADIO_NOT_AVAILABLE = 33; 219 private static final int EVENT_UNSOL_OEM_HOOK_RAW = 34; 220 protected static final int EVENT_GET_RADIO_CAPABILITY = 35; 221 protected static final int EVENT_SS = 36; 222 private static final int EVENT_CONFIG_LCE = 37; 223 private static final int EVENT_CHECK_FOR_NETWORK_AUTOMATIC = 38; 224 protected static final int EVENT_VOICE_RADIO_TECH_CHANGED = 39; 225 protected static final int EVENT_REQUEST_VOICE_RADIO_TECH_DONE = 40; 226 protected static final int EVENT_RIL_CONNECTED = 41; 227 protected static final int EVENT_UPDATE_PHONE_OBJECT = 42; 228 protected static final int EVENT_CARRIER_CONFIG_CHANGED = 43; 229 // Carrier's CDMA prefer mode setting 230 protected static final int EVENT_SET_ROAMING_PREFERENCE_DONE = 44; 231 protected static final int EVENT_MODEM_RESET = 45; 232 protected static final int EVENT_VRS_OR_RAT_CHANGED = 46; 233 // Radio state change 234 protected static final int EVENT_RADIO_STATE_CHANGED = 47; 235 protected static final int EVENT_SET_CARRIER_DATA_ENABLED = 48; 236 protected static final int EVENT_GET_AVAILABLE_NETWORKS_DONE = 51; 237 238 protected static final int EVENT_UICC_APPS_ENABLEMENT_STATUS_CHANGED = 53; 239 protected static final int EVENT_UICC_APPS_ENABLEMENT_SETTING_CHANGED = 54; 240 protected static final int EVENT_GET_UICC_APPS_ENABLEMENT_DONE = 55; 241 protected static final int EVENT_REAPPLY_UICC_APPS_ENABLEMENT_DONE = 56; 242 protected static final int EVENT_REGISTRATION_FAILED = 57; 243 protected static final int EVENT_BARRING_INFO_CHANGED = 58; 244 protected static final int EVENT_LINK_CAPACITY_CHANGED = 59; 245 protected static final int EVENT_RESET_CARRIER_KEY_IMSI_ENCRYPTION = 60; 246 protected static final int EVENT_SET_VONR_ENABLED_DONE = 61; 247 protected static final int EVENT_SUBSCRIPTIONS_CHANGED = 62; 248 protected static final int EVENT_GET_USAGE_SETTING_DONE = 63; 249 protected static final int EVENT_SET_USAGE_SETTING_DONE = 64; 250 protected static final int EVENT_IMS_DEREGISTRATION_TRIGGERED = 65; 251 protected static final int EVENT_SET_NULL_CIPHER_AND_INTEGRITY_DONE = 66; 252 protected static final int EVENT_GET_DEVICE_IMEI_DONE = 67; 253 protected static final int EVENT_TRIGGER_NOTIFY_ANBR = 68; 254 255 protected static final int EVENT_LAST = EVENT_TRIGGER_NOTIFY_ANBR; 256 257 // For shared prefs. 258 private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_"; 259 private static final String GSM_NON_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_non_roaming_list_"; 260 private static final String CDMA_ROAMING_LIST_OVERRIDE_PREFIX = "cdma_roaming_list_"; 261 private static final String CDMA_NON_ROAMING_LIST_OVERRIDE_PREFIX = "cdma_non_roaming_list_"; 262 263 // Key used to read/write current CLIR setting 264 public static final String CLIR_KEY = "clir_sub_key"; 265 266 // Key used for storing voice mail count 267 private static final String VM_COUNT = "vm_count_key"; 268 // Key used to read/write the ID for storing the voice mail 269 private static final String VM_ID = "vm_id_key"; 270 271 // Key used for storing call forwarding status 272 public static final String CF_STATUS = "cf_status_key"; 273 // Key used to read/write the ID for storing the call forwarding status 274 public static final String CF_ID = "cf_id_key"; 275 276 // Key used to read/write "disable DNS server check" pref (used for testing) 277 private static final String DNS_SERVER_CHECK_DISABLED_KEY = "dns_server_check_disabled_key"; 278 279 // Integer used to let the calling application know that the we are ignoring auto mode switch. 280 private static final int ALREADY_IN_AUTO_SELECTION = 1; 281 282 public static final String PREF_NULL_CIPHER_AND_INTEGRITY_ENABLED = 283 "pref_null_cipher_and_integrity_enabled"; 284 private final TelephonyAdminReceiver m2gAdminUpdater; 285 286 /** 287 * This method is invoked when the Phone exits Emergency Callback Mode. 288 */ handleExitEmergencyCallbackMode()289 protected void handleExitEmergencyCallbackMode() { 290 } 291 292 /** 293 * Small container class used to hold information relevant to 294 * the carrier selection process. operatorNumeric can be "" 295 * if we are looking for automatic selection. operatorAlphaLong is the 296 * corresponding operator name. 297 */ 298 protected static class NetworkSelectMessage { 299 public Message message; 300 public String operatorNumeric; 301 public String operatorAlphaLong; 302 public String operatorAlphaShort; 303 } 304 305 public static class SilentRedialParam { 306 public String dialString; 307 public int causeCode; 308 public DialArgs dialArgs; 309 SilentRedialParam(String dialString, int causeCode, DialArgs dialArgs)310 public SilentRedialParam(String dialString, int causeCode, DialArgs dialArgs) { 311 this.dialString = dialString; 312 this.causeCode = causeCode; 313 this.dialArgs = dialArgs; 314 } 315 } 316 317 /* Instance Variables */ 318 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 319 public CommandsInterface mCi; 320 protected int mVmCount = 0; 321 private boolean mDnsCheckDisabled; 322 protected DataNetworkController mDataNetworkController; 323 /* Used for dispatching signals to configured carrier apps */ 324 protected CarrierSignalAgent mCarrierSignalAgent; 325 /* Used for dispatching carrier action from carrier apps */ 326 protected CarrierActionAgent mCarrierActionAgent; 327 private boolean mDoesRilSendMultipleCallRing; 328 private int mCallRingContinueToken; 329 private int mCallRingDelay; 330 private boolean mIsVoiceCapable = true; 331 private final AppSmsManager mAppSmsManager; 332 private SimActivationTracker mSimActivationTracker; 333 // Keep track of whether or not the phone is in Emergency Callback Mode for Phone and 334 // subclasses 335 protected boolean mIsPhoneInEcmState = false; 336 // Keep track of the case where ECM was cancelled to place another outgoing emergency call. 337 // We will need to restart it after the emergency call ends. 338 protected boolean mEcmCanceledForEmergency = false; 339 private volatile long mTimeLastEmergencySmsSentMs = EMERGENCY_SMS_NO_TIME_RECORDED; 340 341 // Variable to cache the video capability. When RAT changes, we lose this info and are unable 342 // to recover from the state. We cache it and notify listeners when they register. 343 protected boolean mIsVideoCapable = false; 344 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 345 protected UiccController mUiccController = null; 346 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 347 protected final AtomicReference<IccRecords> mIccRecords = new AtomicReference<IccRecords>(); 348 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 349 public SmsStorageMonitor mSmsStorageMonitor; 350 public SmsUsageMonitor mSmsUsageMonitor; 351 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 352 protected AtomicReference<UiccCardApplication> mUiccApplication = 353 new AtomicReference<UiccCardApplication>(); 354 private TelephonyTester mTelephonyTester; 355 private String mName; 356 private final String mActionDetached; 357 private final String mActionAttached; 358 protected DeviceStateMonitor mDeviceStateMonitor; 359 protected DisplayInfoController mDisplayInfoController; 360 protected AccessNetworksManager mAccessNetworksManager; 361 // Used for identify the carrier of current subscription 362 protected CarrierResolver mCarrierResolver; 363 protected SignalStrengthController mSignalStrengthController; 364 365 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 366 protected int mPhoneId; 367 368 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 369 protected Phone mImsPhone = null; 370 371 private final AtomicReference<RadioCapability> mRadioCapability = 372 new AtomicReference<RadioCapability>(); 373 374 private static final int DEFAULT_REPORT_INTERVAL_MS = 200; 375 private static final boolean LCE_PULL_MODE = true; 376 private int mLceStatus = RILConstants.LCE_NOT_AVAILABLE; 377 protected TelephonyComponentFactory mTelephonyComponentFactory; 378 379 private int mPreferredUsageSetting = SubscriptionManager.USAGE_SETTING_UNKNOWN; 380 private int mUsageSettingFromModem = SubscriptionManager.USAGE_SETTING_UNKNOWN; 381 private boolean mIsUsageSettingSupported = true; 382 383 //IMS 384 /** 385 * {@link CallStateException} message text used to indicate that an IMS call has failed because 386 * it needs to be retried using GSM or CDMA (e.g. CS fallback). 387 * TODO: Replace this with a proper exception; {@link CallStateException} doesn't make sense. 388 */ 389 public static final String CS_FALLBACK = "cs_fallback"; 390 391 // Used for retry over cs for supplementary services 392 public static final String CS_FALLBACK_SS = "cs_fallback_ss"; 393 394 /** 395 * @deprecated Use {@link android.telephony.ims.ImsManager#EXTRA_WFC_REGISTRATION_FAILURE_TITLE} 396 * instead. 397 */ 398 @Deprecated 399 public static final String EXTRA_KEY_ALERT_TITLE = 400 android.telephony.ims.ImsManager.EXTRA_WFC_REGISTRATION_FAILURE_TITLE; 401 /** 402 * @deprecated Use 403 * {@link android.telephony.ims.ImsManager#EXTRA_WFC_REGISTRATION_FAILURE_MESSAGE} instead. 404 */ 405 @Deprecated 406 public static final String EXTRA_KEY_ALERT_MESSAGE = 407 android.telephony.ims.ImsManager.EXTRA_WFC_REGISTRATION_FAILURE_MESSAGE; 408 public static final String EXTRA_KEY_ALERT_SHOW = "alertShow"; 409 public static final String EXTRA_KEY_NOTIFICATION_MESSAGE = "notificationMessage"; 410 411 protected final RegistrantList mPreciseCallStateRegistrants = new RegistrantList(); 412 413 private final RegistrantList mHandoverRegistrants = new RegistrantList(); 414 415 private final RegistrantList mNewRingingConnectionRegistrants = new RegistrantList(); 416 417 private final RegistrantList mIncomingRingRegistrants = new RegistrantList(); 418 419 protected final RegistrantList mDisconnectRegistrants = new RegistrantList(); 420 421 private final RegistrantList mServiceStateRegistrants = new RegistrantList(); 422 423 protected final RegistrantList mMmiCompleteRegistrants = new RegistrantList(); 424 425 @UnsupportedAppUsage 426 protected final RegistrantList mMmiRegistrants = new RegistrantList(); 427 428 protected final RegistrantList mUnknownConnectionRegistrants = new RegistrantList(); 429 430 protected final RegistrantList mSuppServiceFailedRegistrants = new RegistrantList(); 431 432 protected final RegistrantList mRadioOffOrNotAvailableRegistrants = new RegistrantList(); 433 434 protected final RegistrantList mSimRecordsLoadedRegistrants = new RegistrantList(); 435 436 private final RegistrantList mVideoCapabilityChangedRegistrants = new RegistrantList(); 437 438 protected final RegistrantList mEmergencyCallToggledRegistrants = new RegistrantList(); 439 440 private final RegistrantList mCellInfoRegistrants = new RegistrantList(); 441 442 private final RegistrantList mRedialRegistrants = new RegistrantList(); 443 444 private final RegistrantList mPhysicalChannelConfigRegistrants = new RegistrantList(); 445 446 private final RegistrantList mOtaspRegistrants = new RegistrantList(); 447 448 private final RegistrantList mPreferredNetworkTypeRegistrants = new RegistrantList(); 449 450 protected Registrant mPostDialHandler; 451 452 protected final LocalLog mLocalLog; 453 454 private Looper mLooper; /* to insure registrants are in correct thread*/ 455 456 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 457 protected final Context mContext; 458 459 protected SubscriptionManagerService mSubscriptionManagerService; 460 461 /** 462 * PhoneNotifier is an abstraction for all system-wide 463 * state change notification. DefaultPhoneNotifier is 464 * used here unless running we're inside a unit test. 465 */ 466 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 467 protected PhoneNotifier mNotifier; 468 469 protected SimulatedRadioControl mSimulatedRadioControl; 470 471 private Map<Integer, Long> mAllowedNetworkTypesForReasons = new HashMap<>(); 472 private static final String ALLOWED_NETWORK_TYPES_TEXT_USER = "user"; 473 private static final String ALLOWED_NETWORK_TYPES_TEXT_POWER = "power"; 474 private static final String ALLOWED_NETWORK_TYPES_TEXT_CARRIER = "carrier"; 475 private static final String ALLOWED_NETWORK_TYPES_TEXT_ENABLE_2G = "enable_2g"; 476 private static final int INVALID_ALLOWED_NETWORK_TYPES = -1; 477 protected boolean mIsCarrierNrSupported = false; 478 protected boolean mIsAllowedNetworkTypesLoadedFromDb = false; 479 private boolean mUnitTestMode; 480 481 protected VoiceCallSessionStats mVoiceCallSessionStats; 482 protected SmsStats mSmsStats; 483 484 protected LinkBandwidthEstimator mLinkBandwidthEstimator; 485 486 public static final int IMEI_TYPE_UNKNOWN = -1; 487 public static final int IMEI_TYPE_PRIMARY = ImeiInfo.ImeiType.PRIMARY; 488 public static final int IMEI_TYPE_SECONDARY = ImeiInfo.ImeiType.SECONDARY; 489 getIccRecords()490 public IccRecords getIccRecords() { 491 return mIccRecords.get(); 492 } 493 494 /** 495 * Returns a string identifier for this phone interface for parties 496 * outside the phone app process. 497 * @return The string name. 498 */ 499 @UnsupportedAppUsage getPhoneName()500 public String getPhoneName() { 501 return mName; 502 } 503 setPhoneName(String name)504 protected void setPhoneName(String name) { 505 mName = name; 506 } 507 508 /** 509 * Retrieves Nai for phones. Returns null if Nai is not set. 510 */ 511 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getNai()512 public String getNai(){ 513 return null; 514 } 515 516 /** 517 * Return the ActionDetached string. When this action is received by components 518 * they are to simulate detaching from the network. 519 * 520 * @return com.android.internal.telephony.{mName}.action_detached 521 * {mName} is GSM, CDMA ... 522 */ getActionDetached()523 public String getActionDetached() { 524 return mActionDetached; 525 } 526 527 /** 528 * Return the ActionAttached string. When this action is received by components 529 * they are to simulate attaching to the network. 530 * 531 * @return com.android.internal.telephony.{mName}.action_detached 532 * {mName} is GSM, CDMA ... 533 */ getActionAttached()534 public String getActionAttached() { 535 return mActionAttached; 536 } 537 538 /** 539 * Set a system property, unless we're in unit test mode 540 */ 541 // CAF_MSIM TODO this need to be replated with TelephonyManager API ? 542 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getSystemProperty(String property, String defValue)543 public String getSystemProperty(String property, String defValue) { 544 if(getUnitTestMode()) { 545 return null; 546 } 547 return SystemProperties.get(property, defValue); 548 } 549 550 /** 551 * Constructs a Phone in normal (non-unit test) mode. 552 * 553 * @param notifier An instance of DefaultPhoneNotifier, 554 * @param context Context object from hosting application 555 * unless unit testing. 556 * @param ci is CommandsInterface 557 * @param unitTestMode when true, prevents notifications 558 * of state change events 559 */ Phone(String name, PhoneNotifier notifier, Context context, CommandsInterface ci, boolean unitTestMode)560 protected Phone(String name, PhoneNotifier notifier, Context context, CommandsInterface ci, 561 boolean unitTestMode) { 562 this(name, notifier, context, ci, unitTestMode, SubscriptionManager.DEFAULT_PHONE_INDEX, 563 TelephonyComponentFactory.getInstance()); 564 } 565 566 /** 567 * Constructs a Phone in normal (non-unit test) mode. 568 * 569 * @param notifier An instance of DefaultPhoneNotifier, 570 * @param context Context object from hosting application 571 * unless unit testing. 572 * @param ci is CommandsInterface 573 * @param unitTestMode when true, prevents notifications 574 * of state change events 575 * @param phoneId the phone-id of this phone. 576 */ Phone(String name, PhoneNotifier notifier, Context context, CommandsInterface ci, boolean unitTestMode, int phoneId, TelephonyComponentFactory telephonyComponentFactory)577 protected Phone(String name, PhoneNotifier notifier, Context context, CommandsInterface ci, 578 boolean unitTestMode, int phoneId, 579 TelephonyComponentFactory telephonyComponentFactory) { 580 mPhoneId = phoneId; 581 mName = name; 582 mNotifier = notifier; 583 mContext = context; 584 mLooper = Looper.myLooper(); 585 mCi = ci; 586 mActionDetached = this.getClass().getPackage().getName() + ".action_detached"; 587 mActionAttached = this.getClass().getPackage().getName() + ".action_attached"; 588 mAppSmsManager = telephonyComponentFactory.inject(AppSmsManager.class.getName()) 589 .makeAppSmsManager(context); 590 mLocalLog = new LocalLog(64); 591 592 setUnitTestMode(unitTestMode); 593 594 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 595 mDnsCheckDisabled = sp.getBoolean(DNS_SERVER_CHECK_DISABLED_KEY, false); 596 mCi.setOnCallRing(this, EVENT_CALL_RING, null); 597 598 /* "Voice capable" means that this device supports circuit-switched 599 * (i.e. voice) phone calls over the telephony network, and is allowed 600 * to display the in-call UI while a cellular voice call is active. 601 * This will be false on "data only" devices which can't make voice 602 * calls and don't support any in-call UI. 603 */ 604 mIsVoiceCapable = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)) 605 .isVoiceCapable(); 606 607 /** 608 * Some RIL's don't always send RIL_UNSOL_CALL_RING so it needs 609 * to be generated locally. Ideally all ring tones should be loops 610 * and this wouldn't be necessary. But to minimize changes to upper 611 * layers it is requested that it be generated by lower layers. 612 * 613 * By default old phones won't have the property set but do generate 614 * the RIL_UNSOL_CALL_RING so the default if there is no property is 615 * true. 616 */ 617 mDoesRilSendMultipleCallRing = TelephonyProperties.ril_sends_multiple_call_ring() 618 .orElse(true); 619 Rlog.d(LOG_TAG, "mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing); 620 621 mCallRingDelay = TelephonyProperties.call_ring_delay().orElse(3000); 622 Rlog.d(LOG_TAG, "mCallRingDelay=" + mCallRingDelay); 623 624 // Initialize SMS stats 625 mSmsStats = new SmsStats(this); 626 627 mSubscriptionManagerService = SubscriptionManagerService.getInstance(); 628 m2gAdminUpdater = new TelephonyAdminReceiver(context, this); 629 630 if (getPhoneType() == PhoneConstants.PHONE_TYPE_IMS) { 631 return; 632 } 633 634 if (TelephonyUtils.IS_DEBUGGABLE) { 635 mTelephonyTester = new TelephonyTester(this); 636 } 637 638 // Initialize device storage and outgoing SMS usage monitors for SMSDispatchers. 639 mTelephonyComponentFactory = telephonyComponentFactory; 640 mSmsStorageMonitor = mTelephonyComponentFactory.inject(SmsStorageMonitor.class.getName()) 641 .makeSmsStorageMonitor(this); 642 mSmsUsageMonitor = mTelephonyComponentFactory.inject(SmsUsageMonitor.class.getName()) 643 .makeSmsUsageMonitor(context); 644 mUiccController = UiccController.getInstance(); 645 mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null); 646 mSimActivationTracker = mTelephonyComponentFactory 647 .inject(SimActivationTracker.class.getName()) 648 .makeSimActivationTracker(this); 649 if (getPhoneType() != PhoneConstants.PHONE_TYPE_SIP) { 650 mCi.registerForSrvccStateChanged(this, EVENT_SRVCC_STATE_CHANGED, null); 651 } 652 mCi.startLceService(DEFAULT_REPORT_INTERVAL_MS, LCE_PULL_MODE, 653 obtainMessage(EVENT_CONFIG_LCE)); 654 } 655 656 /** 657 * Start setup of ImsPhone, which will start trying to connect to the ImsResolver. Will not be 658 * called if this device does not support FEATURE_IMS_TELEPHONY. 659 */ createImsPhone()660 public void createImsPhone() { 661 if (getPhoneType() == PhoneConstants.PHONE_TYPE_SIP) { 662 return; 663 } 664 665 synchronized(Phone.lockForRadioTechnologyChange) { 666 if (mImsPhone == null) { 667 mImsPhone = PhoneFactory.makeImsPhone(mNotifier, this); 668 CallManager.getInstance().registerPhone(mImsPhone); 669 mImsPhone.registerForSilentRedial( 670 this, EVENT_INITIATE_SILENT_REDIAL, null); 671 } 672 } 673 } 674 675 /** 676 * Checks if device should convert CDMA Caller ID restriction related MMI codes to 677 * equivalent 3GPP MMI Codes that provide same functionality when device is roaming. 678 * This method should only return true on multi-mode devices when carrier requires this 679 * conversion to be done on the device. 680 * 681 * @return true when carrier config 682 * "KEY_CONVERT_CDMA_CALLER_ID_MMI_CODES_WHILE_ROAMING_ON_3GPP_BOOL" is set to true 683 */ supportsConversionOfCdmaCallerIdMmiCodesWhileRoaming()684 public boolean supportsConversionOfCdmaCallerIdMmiCodesWhileRoaming() { 685 CarrierConfigManager configManager = (CarrierConfigManager) 686 getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); 687 PersistableBundle b = configManager.getConfigForSubId(getSubId()); 688 if (b != null) { 689 return b.getBoolean( 690 CarrierConfigManager 691 .KEY_CONVERT_CDMA_CALLER_ID_MMI_CODES_WHILE_ROAMING_ON_3GPP_BOOL, 692 false); 693 } else { 694 // Default value set in CarrierConfigManager 695 return false; 696 } 697 } 698 699 /** 700 * Check if sending CLIR activation("*31#") and deactivation("#31#") code only without dialing 701 * number is prevented. 702 * 703 * @return {@code true} when carrier config 704 * "KEY_PREVENT_CLIR_ACTIVATION_AND_DEACTIVATION_CODE_BOOL" is set to {@code true} 705 */ isClirActivationAndDeactivationPrevented()706 public boolean isClirActivationAndDeactivationPrevented() { 707 CarrierConfigManager configManager = (CarrierConfigManager) 708 getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); 709 PersistableBundle b = configManager.getConfigForSubId(getSubId()); 710 if (b == null) { 711 b = CarrierConfigManager.getDefaultConfig(); 712 } 713 return b.getBoolean( 714 CarrierConfigManager.KEY_PREVENT_CLIR_ACTIVATION_AND_DEACTIVATION_CODE_BOOL); 715 } 716 717 /** 718 * Determines if the carrier prefers to use an in service sim for a normal routed emergency 719 * call. 720 * @return true when carrier config 721 * {@link CarrierConfigManager#KEY_PREFER_IN_SERVICE_SIM_FOR_NORMAL_ROUTED_EMERGENCY_CALLS_BOOL} 722 * is true. 723 */ shouldPreferInServiceSimForNormalRoutedEmergencyCall()724 public boolean shouldPreferInServiceSimForNormalRoutedEmergencyCall() { 725 CarrierConfigManager configManager = (CarrierConfigManager) 726 getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); 727 PersistableBundle b = configManager.getConfigForSubId(getSubId(), CarrierConfigManager 728 .KEY_PREFER_IN_SERVICE_SIM_FOR_NORMAL_ROUTED_EMERGENCY_CALLS_BOOL); 729 if (b != null) { 730 return b.getBoolean(CarrierConfigManager 731 .KEY_PREFER_IN_SERVICE_SIM_FOR_NORMAL_ROUTED_EMERGENCY_CALLS_BOOL, 732 false); 733 } else { 734 // Default value set in CarrierConfigManager 735 return false; 736 } 737 } 738 739 /** 740 * When overridden the derived class needs to call 741 * super.handleMessage(msg) so this method has a 742 * a chance to process the message. 743 * 744 * @param msg 745 */ 746 @Override handleMessage(Message msg)747 public void handleMessage(Message msg) { 748 AsyncResult ar; 749 750 // messages to be handled whether or not the phone is being destroyed 751 // should only include messages which are being re-directed and do not use 752 // resources of the phone being destroyed 753 switch (msg.what) { 754 // handle the select network completion callbacks. 755 case EVENT_SET_NETWORK_MANUAL_COMPLETE: 756 case EVENT_SET_NETWORK_AUTOMATIC_COMPLETE: 757 handleSetSelectNetwork((AsyncResult) msg.obj); 758 return; 759 } 760 761 switch(msg.what) { 762 case EVENT_CALL_RING: 763 Rlog.d(LOG_TAG, "Event EVENT_CALL_RING Received state=" + getState()); 764 ar = (AsyncResult)msg.obj; 765 if (ar.exception == null) { 766 PhoneConstants.State state = getState(); 767 if ((!mDoesRilSendMultipleCallRing) 768 && ((state == PhoneConstants.State.RINGING) || 769 (state == PhoneConstants.State.IDLE))) { 770 mCallRingContinueToken += 1; 771 sendIncomingCallRingNotification(mCallRingContinueToken); 772 } else { 773 notifyIncomingRing(); 774 } 775 } 776 break; 777 778 case EVENT_CALL_RING_CONTINUE: 779 Rlog.d(LOG_TAG, "Event EVENT_CALL_RING_CONTINUE Received state=" + getState()); 780 if (getState() == PhoneConstants.State.RINGING) { 781 sendIncomingCallRingNotification(msg.arg1); 782 } 783 break; 784 785 case EVENT_ICC_CHANGED: 786 onUpdateIccAvailability(); 787 break; 788 789 case EVENT_INITIATE_SILENT_REDIAL: 790 // This is an ImsPhone -> GsmCdmaPhone redial 791 // See ImsPhone#initiateSilentRedial 792 Rlog.d(LOG_TAG, "Event EVENT_INITIATE_SILENT_REDIAL Received"); 793 ar = (AsyncResult) msg.obj; 794 if ((ar.exception == null) && (ar.result != null)) { 795 SilentRedialParam result = (SilentRedialParam) ar.result; 796 String dialString = result.dialString; 797 int causeCode = result.causeCode; 798 DialArgs dialArgs = result.dialArgs; 799 if (TextUtils.isEmpty(dialString)) return; 800 try { 801 Connection cn = dialInternal(dialString, dialArgs); 802 // The ImsPhoneConnection that is owned by the ImsPhone is currently the 803 // one with a callback registered to TelephonyConnection. Notify the 804 // redial happened over that Phone so that it can be replaced with the 805 // new GSM/CDMA Connection. 806 Rlog.d(LOG_TAG, "Notify redial connection changed cn: " + cn); 807 if (mImsPhone != null) { 808 // Don't care it is null or not. 809 mImsPhone.notifyRedialConnectionChanged(cn); 810 } 811 } catch (CallStateException e) { 812 Rlog.e(LOG_TAG, "silent redial failed: " + e); 813 if (mImsPhone != null) { 814 mImsPhone.notifyRedialConnectionChanged(null); 815 } 816 } 817 } 818 break; 819 820 case EVENT_SRVCC_STATE_CHANGED: 821 ar = (AsyncResult)msg.obj; 822 if (ar.exception == null) { 823 handleSrvccStateChanged((int[]) ar.result); 824 } else { 825 Rlog.e(LOG_TAG, "Srvcc exception: " + ar.exception); 826 } 827 break; 828 829 case EVENT_UNSOL_OEM_HOOK_RAW: 830 // deprecated, ignore 831 break; 832 833 case EVENT_CONFIG_LCE: 834 ar = (AsyncResult) msg.obj; 835 if (ar.exception != null) { 836 Rlog.d(LOG_TAG, "config LCE service failed: " + ar.exception); 837 } else { 838 final ArrayList<Integer> statusInfo = (ArrayList<Integer>)ar.result; 839 mLceStatus = statusInfo.get(0); 840 } 841 break; 842 843 case EVENT_CHECK_FOR_NETWORK_AUTOMATIC: { 844 onCheckForNetworkSelectionModeAutomatic(msg); 845 break; 846 } 847 848 case EVENT_GET_USAGE_SETTING_DONE: 849 ar = (AsyncResult) msg.obj; 850 if (ar.exception == null) { 851 try { 852 mUsageSettingFromModem = ((int[]) ar.result)[0]; 853 } catch (NullPointerException | ClassCastException e) { 854 Rlog.e(LOG_TAG, "Invalid response for usage setting " + ar.result); 855 break; 856 } 857 858 logd("Received mUsageSettingFromModem=" + mUsageSettingFromModem); 859 if (mUsageSettingFromModem != mPreferredUsageSetting) { 860 mCi.setUsageSetting(obtainMessage(EVENT_SET_USAGE_SETTING_DONE), 861 mPreferredUsageSetting); 862 } 863 } else { 864 try { 865 CommandException ce = (CommandException) ar.exception; 866 if (ce.getCommandError() == CommandException.Error.REQUEST_NOT_SUPPORTED) { 867 mIsUsageSettingSupported = false; 868 } 869 Rlog.w(LOG_TAG, "Unexpected failure to retrieve usage setting " + ce); 870 } catch (ClassCastException unused) { 871 Rlog.e(LOG_TAG, "Invalid Exception for usage setting " + ar.exception); 872 break; // technically extraneous, but good hygiene 873 } 874 } 875 break; 876 case EVENT_SET_USAGE_SETTING_DONE: 877 ar = (AsyncResult) msg.obj; 878 if (ar.exception != null) { 879 try { 880 CommandException ce = (CommandException) ar.exception; 881 if (ce.getCommandError() == CommandException.Error.REQUEST_NOT_SUPPORTED) { 882 mIsUsageSettingSupported = false; 883 } 884 Rlog.w(LOG_TAG, "Unexpected failure to set usage setting " + ce); 885 } catch (ClassCastException unused) { 886 Rlog.e(LOG_TAG, "Invalid Exception for usage setting " + ar.exception); 887 break; // technically extraneous, but good hygiene 888 } 889 } 890 break; 891 default: 892 throw new RuntimeException("unexpected event not handled"); 893 } 894 } 895 getHandoverConnection()896 public ArrayList<Connection> getHandoverConnection() { 897 return null; 898 } 899 900 /** 901 * Notifies the change of the SRVCC state. 902 * @param state the new SRVCC state. 903 */ notifySrvccState(@rvccState int state)904 public void notifySrvccState(@SrvccState int state) { 905 } 906 registerForSilentRedial(Handler h, int what, Object obj)907 public void registerForSilentRedial(Handler h, int what, Object obj) { 908 } 909 unregisterForSilentRedial(Handler h)910 public void unregisterForSilentRedial(Handler h) { 911 } 912 registerForVolteSilentRedial(Handler h, int what, Object obj)913 public void registerForVolteSilentRedial(Handler h, int what, Object obj) { 914 } 915 unregisterForVolteSilentRedial(Handler h)916 public void unregisterForVolteSilentRedial(Handler h) { 917 } 918 handleSrvccStateChanged(int[] ret)919 private void handleSrvccStateChanged(int[] ret) { 920 Rlog.d(LOG_TAG, "handleSrvccStateChanged"); 921 922 ArrayList<Connection> conn = null; 923 Phone imsPhone = mImsPhone; 924 Call.SrvccState srvccState = Call.SrvccState.NONE; 925 if (ret != null && ret.length != 0) { 926 int state = ret[0]; 927 if (imsPhone != null) { 928 imsPhone.notifySrvccState(state); 929 } 930 switch(state) { 931 case TelephonyManager.SRVCC_STATE_HANDOVER_STARTED: 932 srvccState = Call.SrvccState.STARTED; 933 if (imsPhone != null) { 934 conn = imsPhone.getHandoverConnection(); 935 migrateFrom(imsPhone); 936 } else { 937 Rlog.d(LOG_TAG, "HANDOVER_STARTED: mImsPhone null"); 938 } 939 break; 940 case TelephonyManager.SRVCC_STATE_HANDOVER_COMPLETED: 941 srvccState = Call.SrvccState.COMPLETED; 942 break; 943 case TelephonyManager.SRVCC_STATE_HANDOVER_FAILED: 944 case TelephonyManager.SRVCC_STATE_HANDOVER_CANCELED: 945 srvccState = Call.SrvccState.FAILED; 946 break; 947 948 default: 949 //ignore invalid state 950 return; 951 } 952 953 getCallTracker().notifySrvccState(srvccState, conn); 954 955 notifySrvccStateChanged(state); 956 } 957 } 958 959 /** 960 * Gets the context for the phone, as set at initialization time. 961 */ 962 @UnsupportedAppUsage getContext()963 public Context getContext() { 964 return mContext; 965 } 966 967 // Will be called when icc changed onUpdateIccAvailability()968 protected abstract void onUpdateIccAvailability(); 969 970 /** 971 * Disables the DNS check (i.e., allows "0.0.0.0"). 972 * Useful for lab testing environment. 973 * @param b true disables the check, false enables. 974 */ disableDnsCheck(boolean b)975 public void disableDnsCheck(boolean b) { 976 mDnsCheckDisabled = b; 977 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 978 SharedPreferences.Editor editor = sp.edit(); 979 editor.putBoolean(DNS_SERVER_CHECK_DISABLED_KEY, b); 980 editor.apply(); 981 } 982 983 /** 984 * Returns true if the DNS check is currently disabled. 985 */ isDnsCheckDisabled()986 public boolean isDnsCheckDisabled() { 987 return mDnsCheckDisabled; 988 } 989 990 /** 991 * Register for getting notifications for change in the Call State {@link Call.State} 992 * This is called PreciseCallState because the call state is more precise than the 993 * {@link PhoneConstants.State} which can be obtained using the {@link PhoneStateListener} 994 * 995 * Resulting events will have an AsyncResult in <code>Message.obj</code>. 996 * AsyncResult.userData will be set to the obj argument here. 997 * The <em>h</em> parameter is held only by a weak reference. 998 */ 999 @UnsupportedAppUsage registerForPreciseCallStateChanged(Handler h, int what, Object obj)1000 public void registerForPreciseCallStateChanged(Handler h, int what, Object obj) { 1001 checkCorrectThread(h); 1002 1003 mPreciseCallStateRegistrants.addUnique(h, what, obj); 1004 } 1005 1006 /** 1007 * Unregisters for voice call state change notifications. 1008 * Extraneous calls are tolerated silently. 1009 */ 1010 @UnsupportedAppUsage unregisterForPreciseCallStateChanged(Handler h)1011 public void unregisterForPreciseCallStateChanged(Handler h) { 1012 mPreciseCallStateRegistrants.remove(h); 1013 } 1014 1015 /** 1016 * Notifies when a Handover happens due to SRVCC or Silent Redial 1017 */ registerForHandoverStateChanged(Handler h, int what, Object obj)1018 public void registerForHandoverStateChanged(Handler h, int what, Object obj) { 1019 checkCorrectThread(h); 1020 mHandoverRegistrants.addUnique(h, what, obj); 1021 } 1022 1023 /** 1024 * Unregisters for handover state notifications 1025 */ unregisterForHandoverStateChanged(Handler h)1026 public void unregisterForHandoverStateChanged(Handler h) { 1027 mHandoverRegistrants.remove(h); 1028 } 1029 1030 /** 1031 * Subclasses of Phone probably want to replace this with a 1032 * version scoped to their packages 1033 */ notifyHandoverStateChanged(Connection cn)1034 public void notifyHandoverStateChanged(Connection cn) { 1035 AsyncResult ar = new AsyncResult(null, cn, null); 1036 mHandoverRegistrants.notifyRegistrants(ar); 1037 } 1038 1039 /** 1040 * Notifies when a Handover happens due to Silent Redial 1041 */ registerForRedialConnectionChanged(Handler h, int what, Object obj)1042 public void registerForRedialConnectionChanged(Handler h, int what, Object obj) { 1043 checkCorrectThread(h); 1044 mRedialRegistrants.addUnique(h, what, obj); 1045 } 1046 1047 /** 1048 * Unregisters for redial connection notifications 1049 */ unregisterForRedialConnectionChanged(Handler h)1050 public void unregisterForRedialConnectionChanged(Handler h) { 1051 mRedialRegistrants.remove(h); 1052 } 1053 1054 /** 1055 * Subclasses of Phone probably want to replace this with a 1056 * version scoped to their packages 1057 */ notifyRedialConnectionChanged(Connection cn)1058 public void notifyRedialConnectionChanged(Connection cn) { 1059 AsyncResult ar = new AsyncResult(null, cn, null); 1060 mRedialRegistrants.notifyRegistrants(ar); 1061 } 1062 setIsInEmergencyCall()1063 protected void setIsInEmergencyCall() { 1064 } 1065 1066 /** 1067 * Notify the phone that an SMS has been sent. This will be used determine if the SMS was sent 1068 * to an emergency address. 1069 * @param destinationAddress the address that the SMS was sent to. 1070 */ notifySmsSent(String destinationAddress)1071 public void notifySmsSent(String destinationAddress) { 1072 TelephonyManager m = (TelephonyManager) getContext().getSystemService( 1073 Context.TELEPHONY_SERVICE); 1074 if (m != null && m.isEmergencyNumber(destinationAddress)) { 1075 mLocalLog.log("Emergency SMS detected, recording time."); 1076 mTimeLastEmergencySmsSentMs = SystemClock.elapsedRealtime(); 1077 } 1078 } 1079 1080 /** 1081 * Determine if the Phone has recently sent an emergency SMS and is still in the interval of 1082 * time defined by a carrier that we may need to do perform special actions, for example 1083 * override user setting for location so the carrier can find the user's location for emergency 1084 * services. 1085 * 1086 * @return true if the device is in emergency SMS mode, false otherwise. 1087 */ isInEmergencySmsMode()1088 public boolean isInEmergencySmsMode() { 1089 long lastSmsTimeMs = mTimeLastEmergencySmsSentMs; 1090 if (lastSmsTimeMs == EMERGENCY_SMS_NO_TIME_RECORDED) { 1091 // an emergency SMS hasn't been sent since the last check. 1092 return false; 1093 } 1094 CarrierConfigManager configManager = (CarrierConfigManager) 1095 getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); 1096 PersistableBundle b = configManager.getConfigForSubId(getSubId()); 1097 if (b == null) { 1098 // default for KEY_EMERGENCY_SMS_MODE_TIMER_MS_INT is 0 and CarrierConfig isn't 1099 // available, so return false. 1100 return false; 1101 } 1102 int eSmsTimerMs = b.getInt(CarrierConfigManager.KEY_EMERGENCY_SMS_MODE_TIMER_MS_INT, 0); 1103 if (eSmsTimerMs == 0) { 1104 // We do not support this feature for this carrier. 1105 return false; 1106 } 1107 if (eSmsTimerMs > EMERGENCY_SMS_TIMER_MAX_MS) { 1108 eSmsTimerMs = EMERGENCY_SMS_TIMER_MAX_MS; 1109 } 1110 boolean isInEmergencySmsMode = SystemClock.elapsedRealtime() 1111 <= (lastSmsTimeMs + eSmsTimerMs); 1112 if (!isInEmergencySmsMode) { 1113 // Shortcut this next time so we do not have to waste time if another emergency SMS 1114 // hasn't been sent since the last query. 1115 mTimeLastEmergencySmsSentMs = EMERGENCY_SMS_NO_TIME_RECORDED; 1116 } else { 1117 mLocalLog.log("isInEmergencySmsMode: queried while eSMS mode is active."); 1118 } 1119 return isInEmergencySmsMode; 1120 } 1121 migrateFrom(Phone from)1122 protected void migrateFrom(Phone from) { 1123 migrate(mHandoverRegistrants, from.mHandoverRegistrants); 1124 migrate(mPreciseCallStateRegistrants, from.mPreciseCallStateRegistrants); 1125 migrate(mNewRingingConnectionRegistrants, from.mNewRingingConnectionRegistrants); 1126 migrate(mIncomingRingRegistrants, from.mIncomingRingRegistrants); 1127 migrate(mDisconnectRegistrants, from.mDisconnectRegistrants); 1128 migrate(mServiceStateRegistrants, from.mServiceStateRegistrants); 1129 migrate(mMmiCompleteRegistrants, from.mMmiCompleteRegistrants); 1130 migrate(mMmiRegistrants, from.mMmiRegistrants); 1131 migrate(mUnknownConnectionRegistrants, from.mUnknownConnectionRegistrants); 1132 migrate(mSuppServiceFailedRegistrants, from.mSuppServiceFailedRegistrants); 1133 migrate(mCellInfoRegistrants, from.mCellInfoRegistrants); 1134 migrate(mRedialRegistrants, from.mRedialRegistrants); 1135 // The emergency state of IMS phone will be cleared in ImsPhone#notifySrvccState after 1136 // receive SRVCC completed 1137 if (from.isInEmergencyCall()) { 1138 setIsInEmergencyCall(); 1139 } 1140 setEcmCanceledForEmergency(from.isEcmCanceledForEmergency()); 1141 } 1142 migrate(RegistrantList to, RegistrantList from)1143 protected void migrate(RegistrantList to, RegistrantList from) { 1144 if (from == null) { 1145 // May be null in some cases, such as testing. 1146 return; 1147 } 1148 from.removeCleared(); 1149 for (int i = 0, n = from.size(); i < n; i++) { 1150 Registrant r = (Registrant) from.get(i); 1151 Message msg = r.messageForRegistrant(); 1152 // Since CallManager has already registered with both CS and IMS phones, 1153 // the migrate should happen only for those registrants which are not 1154 // registered with CallManager.Hence the below check is needed to add 1155 // only those registrants to the registrant list which are not 1156 // coming from the CallManager. 1157 if (msg != null) { 1158 if (msg.obj == CallManager.getInstance().getRegistrantIdentifier()) { 1159 continue; 1160 } else { 1161 to.add((Registrant) from.get(i)); 1162 } 1163 } else { 1164 Rlog.d(LOG_TAG, "msg is null"); 1165 } 1166 } 1167 } 1168 1169 /** 1170 * Notifies when a previously untracked non-ringing/waiting connection has appeared. 1171 * This is likely due to some other entity (eg, SIM card application) initiating a call. 1172 */ 1173 @UnsupportedAppUsage registerForUnknownConnection(Handler h, int what, Object obj)1174 public void registerForUnknownConnection(Handler h, int what, Object obj) { 1175 checkCorrectThread(h); 1176 1177 mUnknownConnectionRegistrants.addUnique(h, what, obj); 1178 } 1179 1180 /** 1181 * Unregisters for unknown connection notifications. 1182 */ 1183 @UnsupportedAppUsage unregisterForUnknownConnection(Handler h)1184 public void unregisterForUnknownConnection(Handler h) { 1185 mUnknownConnectionRegistrants.remove(h); 1186 } 1187 1188 /** 1189 * Notifies when a new ringing or waiting connection has appeared.<p> 1190 * 1191 * Messages received from this: 1192 * Message.obj will be an AsyncResult 1193 * AsyncResult.userObj = obj 1194 * AsyncResult.result = a Connection. <p> 1195 * Please check Connection.isRinging() to make sure the Connection 1196 * has not dropped since this message was posted. 1197 * If Connection.isRinging() is true, then 1198 * Connection.getCall() == Phone.getRingingCall() 1199 */ 1200 @UnsupportedAppUsage registerForNewRingingConnection( Handler h, int what, Object obj)1201 public void registerForNewRingingConnection( 1202 Handler h, int what, Object obj) { 1203 checkCorrectThread(h); 1204 1205 mNewRingingConnectionRegistrants.addUnique(h, what, obj); 1206 } 1207 1208 /** 1209 * Unregisters for new ringing connection notification. 1210 * Extraneous calls are tolerated silently 1211 */ 1212 @UnsupportedAppUsage unregisterForNewRingingConnection(Handler h)1213 public void unregisterForNewRingingConnection(Handler h) { 1214 mNewRingingConnectionRegistrants.remove(h); 1215 } 1216 1217 /** 1218 * Notifies when phone's video capabilities changes <p> 1219 * 1220 * Messages received from this: 1221 * Message.obj will be an AsyncResult 1222 * AsyncResult.userObj = obj 1223 * AsyncResult.result = true if phone supports video calling <p> 1224 */ registerForVideoCapabilityChanged( Handler h, int what, Object obj)1225 public void registerForVideoCapabilityChanged( 1226 Handler h, int what, Object obj) { 1227 checkCorrectThread(h); 1228 1229 mVideoCapabilityChangedRegistrants.addUnique(h, what, obj); 1230 1231 // Notify any registrants of the cached video capability as soon as they register. 1232 notifyForVideoCapabilityChanged(mIsVideoCapable); 1233 } 1234 1235 /** 1236 * Unregisters for video capability changed notification. 1237 * Extraneous calls are tolerated silently 1238 */ unregisterForVideoCapabilityChanged(Handler h)1239 public void unregisterForVideoCapabilityChanged(Handler h) { 1240 mVideoCapabilityChangedRegistrants.remove(h); 1241 } 1242 1243 /** 1244 * Register for notifications when a sInCall VoicePrivacy is enabled 1245 * 1246 * @param h Handler that receives the notification message. 1247 * @param what User-defined message code. 1248 * @param obj User object. 1249 */ registerForInCallVoicePrivacyOn(Handler h, int what, Object obj)1250 public void registerForInCallVoicePrivacyOn(Handler h, int what, Object obj){ 1251 mCi.registerForInCallVoicePrivacyOn(h, what, obj); 1252 } 1253 1254 /** 1255 * Unegister for notifications when a sInCall VoicePrivacy is enabled 1256 * 1257 * @param h Handler to be removed from the registrant list. 1258 */ unregisterForInCallVoicePrivacyOn(Handler h)1259 public void unregisterForInCallVoicePrivacyOn(Handler h){ 1260 mCi.unregisterForInCallVoicePrivacyOn(h); 1261 } 1262 1263 /** 1264 * Register for notifications when a sInCall VoicePrivacy is disabled 1265 * 1266 * @param h Handler that receives the notification message. 1267 * @param what User-defined message code. 1268 * @param obj User object. 1269 */ registerForInCallVoicePrivacyOff(Handler h, int what, Object obj)1270 public void registerForInCallVoicePrivacyOff(Handler h, int what, Object obj){ 1271 mCi.registerForInCallVoicePrivacyOff(h, what, obj); 1272 } 1273 1274 /** 1275 * Unregister for notifications when a sInCall VoicePrivacy is disabled 1276 * 1277 * @param h Handler to be removed from the registrant list. 1278 */ unregisterForInCallVoicePrivacyOff(Handler h)1279 public void unregisterForInCallVoicePrivacyOff(Handler h){ 1280 mCi.unregisterForInCallVoicePrivacyOff(h); 1281 } 1282 1283 /** 1284 * Notifies when an incoming call rings.<p> 1285 * 1286 * Messages received from this: 1287 * Message.obj will be an AsyncResult 1288 * AsyncResult.userObj = obj 1289 * AsyncResult.result = a Connection. <p> 1290 */ 1291 @UnsupportedAppUsage registerForIncomingRing( Handler h, int what, Object obj)1292 public void registerForIncomingRing( 1293 Handler h, int what, Object obj) { 1294 checkCorrectThread(h); 1295 1296 mIncomingRingRegistrants.addUnique(h, what, obj); 1297 } 1298 1299 /** 1300 * Unregisters for ring notification. 1301 * Extraneous calls are tolerated silently 1302 */ 1303 @UnsupportedAppUsage unregisterForIncomingRing(Handler h)1304 public void unregisterForIncomingRing(Handler h) { 1305 mIncomingRingRegistrants.remove(h); 1306 } 1307 1308 /** 1309 * Notifies when a voice connection has disconnected, either due to local 1310 * or remote hangup or error. 1311 * 1312 * Messages received from this will have the following members:<p> 1313 * <ul><li>Message.obj will be an AsyncResult</li> 1314 * <li>AsyncResult.userObj = obj</li> 1315 * <li>AsyncResult.result = a Connection object that is 1316 * no longer connected.</li></ul> 1317 */ 1318 @UnsupportedAppUsage registerForDisconnect(Handler h, int what, Object obj)1319 public void registerForDisconnect(Handler h, int what, Object obj) { 1320 checkCorrectThread(h); 1321 1322 mDisconnectRegistrants.addUnique(h, what, obj); 1323 } 1324 1325 /** 1326 * Unregisters for voice disconnection notification. 1327 * Extraneous calls are tolerated silently 1328 */ 1329 @UnsupportedAppUsage unregisterForDisconnect(Handler h)1330 public void unregisterForDisconnect(Handler h) { 1331 mDisconnectRegistrants.remove(h); 1332 } 1333 1334 /** 1335 * Register for notifications when a supplementary service attempt fails. 1336 * Message.obj will contain an AsyncResult. 1337 * 1338 * @param h Handler that receives the notification message. 1339 * @param what User-defined message code. 1340 * @param obj User object. 1341 */ registerForSuppServiceFailed(Handler h, int what, Object obj)1342 public void registerForSuppServiceFailed(Handler h, int what, Object obj) { 1343 checkCorrectThread(h); 1344 1345 mSuppServiceFailedRegistrants.addUnique(h, what, obj); 1346 } 1347 1348 /** 1349 * Unregister for notifications when a supplementary service attempt fails. 1350 * Extraneous calls are tolerated silently 1351 * 1352 * @param h Handler to be removed from the registrant list. 1353 */ unregisterForSuppServiceFailed(Handler h)1354 public void unregisterForSuppServiceFailed(Handler h) { 1355 mSuppServiceFailedRegistrants.remove(h); 1356 } 1357 1358 /** 1359 * Register for notifications of initiation of a new MMI code request. 1360 * MMI codes for GSM are discussed in 3GPP TS 22.030.<p> 1361 * 1362 * Example: If Phone.dial is called with "*#31#", then the app will 1363 * be notified here.<p> 1364 * 1365 * The returned <code>Message.obj</code> will contain an AsyncResult. 1366 * 1367 * <code>obj.result</code> will be an "MmiCode" object. 1368 */ 1369 @UnsupportedAppUsage registerForMmiInitiate(Handler h, int what, Object obj)1370 public void registerForMmiInitiate(Handler h, int what, Object obj) { 1371 checkCorrectThread(h); 1372 1373 mMmiRegistrants.addUnique(h, what, obj); 1374 } 1375 1376 /** 1377 * Unregisters for new MMI initiate notification. 1378 * Extraneous calls are tolerated silently 1379 */ 1380 @UnsupportedAppUsage unregisterForMmiInitiate(Handler h)1381 public void unregisterForMmiInitiate(Handler h) { 1382 mMmiRegistrants.remove(h); 1383 } 1384 1385 /** 1386 * Register for notifications that an MMI request has completed 1387 * its network activity and is in its final state. This may mean a state 1388 * of COMPLETE, FAILED, or CANCELLED. 1389 * 1390 * <code>Message.obj</code> will contain an AsyncResult. 1391 * <code>obj.result</code> will be an "MmiCode" object 1392 */ 1393 @UnsupportedAppUsage registerForMmiComplete(Handler h, int what, Object obj)1394 public void registerForMmiComplete(Handler h, int what, Object obj) { 1395 checkCorrectThread(h); 1396 1397 mMmiCompleteRegistrants.addUnique(h, what, obj); 1398 } 1399 1400 /** 1401 * Unregisters for MMI complete notification. 1402 * Extraneous calls are tolerated silently 1403 */ 1404 @UnsupportedAppUsage unregisterForMmiComplete(Handler h)1405 public void unregisterForMmiComplete(Handler h) { 1406 checkCorrectThread(h); 1407 1408 mMmiCompleteRegistrants.remove(h); 1409 } 1410 1411 /** 1412 * Registration point for Sim records loaded 1413 * @param h handler to notify 1414 * @param what what code of message when delivered 1415 * @param obj placed in Message.obj 1416 */ 1417 @UnsupportedAppUsage registerForSimRecordsLoaded(Handler h, int what, Object obj)1418 public void registerForSimRecordsLoaded(Handler h, int what, Object obj) { 1419 } 1420 1421 /** 1422 * Unregister for notifications for Sim records loaded 1423 * @param h Handler to be removed from the registrant list. 1424 */ 1425 @UnsupportedAppUsage unregisterForSimRecordsLoaded(Handler h)1426 public void unregisterForSimRecordsLoaded(Handler h) { 1427 } 1428 1429 /** 1430 * Register for TTY mode change notifications from the network. 1431 * Message.obj will contain an AsyncResult. 1432 * AsyncResult.result will be an Integer containing new mode. 1433 * 1434 * @param h Handler that receives the notification message. 1435 * @param what User-defined message code. 1436 * @param obj User object. 1437 */ registerForTtyModeReceived(Handler h, int what, Object obj)1438 public void registerForTtyModeReceived(Handler h, int what, Object obj) { 1439 } 1440 1441 /** 1442 * Unregisters for TTY mode change notifications. 1443 * Extraneous calls are tolerated silently 1444 * 1445 * @param h Handler to be removed from the registrant list. 1446 */ unregisterForTtyModeReceived(Handler h)1447 public void unregisterForTtyModeReceived(Handler h) { 1448 } 1449 1450 /** 1451 * Switches network selection mode to "automatic", re-scanning and 1452 * re-selecting a network if appropriate. 1453 * 1454 * @param response The message to dispatch when the network selection 1455 * is complete. 1456 * 1457 * @see #selectNetworkManually(OperatorInfo, boolean, android.os.Message) 1458 */ 1459 @UnsupportedAppUsage setNetworkSelectionModeAutomatic(Message response)1460 public void setNetworkSelectionModeAutomatic(Message response) { 1461 Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic, querying current mode"); 1462 // we don't want to do this unnecessarily - it actually causes 1463 // the radio to repeat network selection and is costly 1464 // first check if we're already in automatic mode 1465 Message msg = obtainMessage(EVENT_CHECK_FOR_NETWORK_AUTOMATIC); 1466 msg.obj = response; 1467 mCi.getNetworkSelectionMode(msg); 1468 } 1469 onCheckForNetworkSelectionModeAutomatic(Message fromRil)1470 private void onCheckForNetworkSelectionModeAutomatic(Message fromRil) { 1471 AsyncResult ar = (AsyncResult)fromRil.obj; 1472 Message response = (Message)ar.userObj; 1473 boolean doAutomatic = true; 1474 if (ar.exception == null && ar.result != null) { 1475 try { 1476 int[] modes = (int[])ar.result; 1477 if (modes[0] == 0) { 1478 // already confirmed to be in automatic mode - don't resend 1479 doAutomatic = false; 1480 } 1481 } catch (Exception e) { 1482 // send the setting on error 1483 } 1484 } 1485 1486 // wrap the response message in our own message along with 1487 // an empty string (to indicate automatic selection) for the 1488 // operator's id. 1489 NetworkSelectMessage nsm = new NetworkSelectMessage(); 1490 nsm.message = response; 1491 nsm.operatorNumeric = ""; 1492 nsm.operatorAlphaLong = ""; 1493 nsm.operatorAlphaShort = ""; 1494 1495 if (doAutomatic) { 1496 Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic - set network selection auto"); 1497 Message msg = obtainMessage(EVENT_SET_NETWORK_AUTOMATIC_COMPLETE, nsm); 1498 mCi.setNetworkSelectionModeAutomatic(msg); 1499 } else { 1500 Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic - already auto, ignoring"); 1501 // let the calling application know that the we are ignoring automatic mode switch. 1502 if (nsm.message != null) { 1503 nsm.message.arg1 = ALREADY_IN_AUTO_SELECTION; 1504 } 1505 1506 ar.userObj = nsm; 1507 handleSetSelectNetwork(ar); 1508 } 1509 1510 updateSavedNetworkOperator(nsm); 1511 } 1512 1513 /** 1514 * Query the radio for the current network selection mode. 1515 * 1516 * Return values: 1517 * 0 - automatic. 1518 * 1 - manual. 1519 */ getNetworkSelectionMode(Message message)1520 public void getNetworkSelectionMode(Message message) { 1521 mCi.getNetworkSelectionMode(message); 1522 } 1523 getClientRequestStats()1524 public List<ClientRequestStats> getClientRequestStats() { 1525 return mCi.getClientRequestStats(); 1526 } 1527 1528 /** 1529 * Manually selects a network. <code>response</code> is 1530 * dispatched when this is complete. <code>response.obj</code> will be 1531 * an AsyncResult, and <code>response.obj.exception</code> will be non-null 1532 * on failure. 1533 * 1534 * @see #setNetworkSelectionModeAutomatic(Message) 1535 */ 1536 @UnsupportedAppUsage selectNetworkManually(OperatorInfo network, boolean persistSelection, Message response)1537 public void selectNetworkManually(OperatorInfo network, boolean persistSelection, 1538 Message response) { 1539 // wrap the response message in our own message along with 1540 // the operator's id. 1541 NetworkSelectMessage nsm = new NetworkSelectMessage(); 1542 nsm.message = response; 1543 nsm.operatorNumeric = network.getOperatorNumeric(); 1544 nsm.operatorAlphaLong = network.getOperatorAlphaLong(); 1545 nsm.operatorAlphaShort = network.getOperatorAlphaShort(); 1546 1547 Message msg = obtainMessage(EVENT_SET_NETWORK_MANUAL_COMPLETE, nsm); 1548 mCi.setNetworkSelectionModeManual(network.getOperatorNumeric(), network.getRan(), msg); 1549 1550 if (persistSelection) { 1551 updateSavedNetworkOperator(nsm); 1552 } else { 1553 clearSavedNetworkSelection(); 1554 updateManualNetworkSelection(nsm); 1555 } 1556 } 1557 1558 /** 1559 * Registration point for emergency call/callback mode start. Message.obj is AsyncResult and 1560 * Message.obj.result will be Integer indicating start of call by value 1 or end of call by 1561 * value 0 1562 * @param h handler to notify 1563 * @param what what code of message when delivered 1564 * @param obj placed in Message.obj.userObj 1565 */ registerForEmergencyCallToggle(Handler h, int what, Object obj)1566 public void registerForEmergencyCallToggle(Handler h, int what, Object obj) { 1567 Registrant r = new Registrant(h, what, obj); 1568 mEmergencyCallToggledRegistrants.add(r); 1569 } 1570 unregisterForEmergencyCallToggle(Handler h)1571 public void unregisterForEmergencyCallToggle(Handler h) { 1572 mEmergencyCallToggledRegistrants.remove(h); 1573 } 1574 updateSavedNetworkOperator(NetworkSelectMessage nsm)1575 private void updateSavedNetworkOperator(NetworkSelectMessage nsm) { 1576 int subId = getSubId(); 1577 if (SubscriptionManager.isValidSubscriptionId(subId)) { 1578 // open the shared preferences editor, and write the value. 1579 // nsm.operatorNumeric is "" if we're in automatic.selection. 1580 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 1581 SharedPreferences.Editor editor = sp.edit(); 1582 editor.putString(NETWORK_SELECTION_KEY + subId, nsm.operatorNumeric); 1583 editor.putString(NETWORK_SELECTION_NAME_KEY + subId, nsm.operatorAlphaLong); 1584 editor.putString(NETWORK_SELECTION_SHORT_KEY + subId, nsm.operatorAlphaShort); 1585 1586 // commit and log the result. 1587 if (!editor.commit()) { 1588 Rlog.e(LOG_TAG, "failed to commit network selection preference"); 1589 } 1590 } else { 1591 Rlog.e(LOG_TAG, "Cannot update network selection preference due to invalid subId " + 1592 subId); 1593 } 1594 } 1595 1596 /** 1597 * Update non-perisited manual network selection. 1598 * 1599 * @param nsm PLMN info of the selected network 1600 */ updateManualNetworkSelection(NetworkSelectMessage nsm)1601 protected void updateManualNetworkSelection(NetworkSelectMessage nsm) { 1602 Rlog.e(LOG_TAG, "updateManualNetworkSelection() should be overridden"); 1603 } 1604 1605 /** 1606 * Used to track the settings upon completion of the network change. 1607 */ handleSetSelectNetwork(AsyncResult ar)1608 private void handleSetSelectNetwork(AsyncResult ar) { 1609 // look for our wrapper within the asyncresult, skip the rest if it 1610 // is null. 1611 if (!(ar.userObj instanceof NetworkSelectMessage)) { 1612 Rlog.e(LOG_TAG, "unexpected result from user object."); 1613 return; 1614 } 1615 1616 NetworkSelectMessage nsm = (NetworkSelectMessage) ar.userObj; 1617 1618 // found the object, now we send off the message we had originally 1619 // attached to the request. 1620 if (nsm.message != null) { 1621 AsyncResult.forMessage(nsm.message, ar.result, ar.exception); 1622 nsm.message.sendToTarget(); 1623 } 1624 } 1625 1626 /** 1627 * Method to retrieve the saved operator from the Shared Preferences 1628 */ 1629 @NonNull getSavedNetworkSelection()1630 public OperatorInfo getSavedNetworkSelection() { 1631 // open the shared preferences and search with our key. 1632 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 1633 String numeric = sp.getString(NETWORK_SELECTION_KEY + getSubId(), ""); 1634 String name = sp.getString(NETWORK_SELECTION_NAME_KEY + getSubId(), ""); 1635 String shrt = sp.getString(NETWORK_SELECTION_SHORT_KEY + getSubId(), ""); 1636 return new OperatorInfo(name, shrt, numeric); 1637 } 1638 1639 /** 1640 * Clears the saved network selection. 1641 */ clearSavedNetworkSelection()1642 private void clearSavedNetworkSelection() { 1643 // open the shared preferences and search with our key. 1644 PreferenceManager.getDefaultSharedPreferences(getContext()).edit(). 1645 remove(NETWORK_SELECTION_KEY + getSubId()). 1646 remove(NETWORK_SELECTION_NAME_KEY + getSubId()). 1647 remove(NETWORK_SELECTION_SHORT_KEY + getSubId()).commit(); 1648 } 1649 1650 /** 1651 * Method to restore the previously saved operator id, or reset to 1652 * automatic selection, all depending upon the value in the shared 1653 * preferences. 1654 */ restoreSavedNetworkSelection(Message response)1655 private void restoreSavedNetworkSelection(Message response) { 1656 // retrieve the operator 1657 OperatorInfo networkSelection = getSavedNetworkSelection(); 1658 1659 // set to auto if the id is empty, otherwise select the network. 1660 if (networkSelection == null || TextUtils.isEmpty(networkSelection.getOperatorNumeric())) { 1661 setNetworkSelectionModeAutomatic(response); 1662 } else { 1663 selectNetworkManually(networkSelection, true, response); 1664 } 1665 } 1666 1667 /** 1668 * Saves CLIR setting so that we can re-apply it as necessary 1669 * (in case the RIL resets it across reboots). 1670 */ saveClirSetting(int commandInterfaceCLIRMode)1671 public void saveClirSetting(int commandInterfaceCLIRMode) { 1672 // Open the shared preferences editor, and write the value. 1673 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 1674 SharedPreferences.Editor editor = sp.edit(); 1675 editor.putInt(CLIR_KEY + getSubId(), commandInterfaceCLIRMode); 1676 Rlog.i(LOG_TAG, "saveClirSetting: " + CLIR_KEY + getSubId() + "=" 1677 + commandInterfaceCLIRMode); 1678 1679 // Commit and log the result. 1680 if (!editor.commit()) { 1681 Rlog.e(LOG_TAG, "Failed to commit CLIR preference"); 1682 } 1683 } 1684 1685 /** 1686 * For unit tests; don't send notifications to "Phone" 1687 * mailbox registrants if true. 1688 */ setUnitTestMode(boolean f)1689 private void setUnitTestMode(boolean f) { 1690 mUnitTestMode = f; 1691 } 1692 1693 /** 1694 * @return true If unit test mode is enabled 1695 */ getUnitTestMode()1696 public boolean getUnitTestMode() { 1697 return mUnitTestMode; 1698 } 1699 1700 /** 1701 * To be invoked when a voice call Connection disconnects. 1702 * 1703 * Subclasses of Phone probably want to replace this with a 1704 * version scoped to their packages 1705 */ notifyDisconnectP(Connection cn)1706 protected void notifyDisconnectP(Connection cn) { 1707 AsyncResult ar = new AsyncResult(null, cn, null); 1708 mDisconnectRegistrants.notifyRegistrants(ar); 1709 } 1710 1711 /** 1712 * Register for ServiceState changed. 1713 * Message.obj will contain an AsyncResult. 1714 * AsyncResult.result will be a ServiceState instance 1715 */ 1716 @UnsupportedAppUsage registerForServiceStateChanged( Handler h, int what, Object obj)1717 public void registerForServiceStateChanged( 1718 Handler h, int what, Object obj) { 1719 mServiceStateRegistrants.add(h, what, obj); 1720 } 1721 1722 /** 1723 * Unregisters for ServiceStateChange notification. 1724 * Extraneous calls are tolerated silently 1725 */ 1726 @UnsupportedAppUsage unregisterForServiceStateChanged(Handler h)1727 public void unregisterForServiceStateChanged(Handler h) { 1728 mServiceStateRegistrants.remove(h); 1729 } 1730 1731 /** 1732 * Notifies when out-band ringback tone is needed.<p> 1733 * 1734 * Messages received from this: 1735 * Message.obj will be an AsyncResult 1736 * AsyncResult.userObj = obj 1737 * AsyncResult.result = boolean, true to start play ringback tone 1738 * and false to stop. <p> 1739 */ 1740 @UnsupportedAppUsage registerForRingbackTone(Handler h, int what, Object obj)1741 public void registerForRingbackTone(Handler h, int what, Object obj) { 1742 mCi.registerForRingbackTone(h, what, obj); 1743 } 1744 1745 /** 1746 * Unregisters for ringback tone notification. 1747 */ 1748 @UnsupportedAppUsage unregisterForRingbackTone(Handler h)1749 public void unregisterForRingbackTone(Handler h) { 1750 mCi.unregisterForRingbackTone(h); 1751 } 1752 1753 /** 1754 * Notifies when out-band on-hold tone is needed.<p> 1755 * 1756 * Messages received from this: 1757 * Message.obj will be an AsyncResult 1758 * AsyncResult.userObj = obj 1759 * AsyncResult.result = boolean, true to start play on-hold tone 1760 * and false to stop. <p> 1761 */ registerForOnHoldTone(Handler h, int what, Object obj)1762 public void registerForOnHoldTone(Handler h, int what, Object obj) { 1763 } 1764 1765 /** 1766 * Unregisters for on-hold tone notification. 1767 */ unregisterForOnHoldTone(Handler h)1768 public void unregisterForOnHoldTone(Handler h) { 1769 } 1770 1771 /** 1772 * Registers the handler to reset the uplink mute state to get 1773 * uplink audio. 1774 */ registerForResendIncallMute(Handler h, int what, Object obj)1775 public void registerForResendIncallMute(Handler h, int what, Object obj) { 1776 mCi.registerForResendIncallMute(h, what, obj); 1777 } 1778 1779 /** 1780 * Unregisters for resend incall mute notifications. 1781 */ unregisterForResendIncallMute(Handler h)1782 public void unregisterForResendIncallMute(Handler h) { 1783 mCi.unregisterForResendIncallMute(h); 1784 } 1785 1786 /** 1787 * Registers for CellInfo changed. 1788 * Message.obj will contain an AsyncResult. 1789 * AsyncResult.result will be a List<CellInfo> instance 1790 */ registerForCellInfo( Handler h, int what, Object obj)1791 public void registerForCellInfo( 1792 Handler h, int what, Object obj) { 1793 mCellInfoRegistrants.add(h, what, obj); 1794 } 1795 1796 /** 1797 * Unregisters for CellInfo notification. 1798 * Extraneous calls are tolerated silently 1799 */ unregisterForCellInfo(Handler h)1800 public void unregisterForCellInfo(Handler h) { 1801 mCellInfoRegistrants.remove(h); 1802 } 1803 1804 /** 1805 * Enables or disables echo suppression. 1806 */ setEchoSuppressionEnabled()1807 public void setEchoSuppressionEnabled() { 1808 // no need for regular phone 1809 } 1810 1811 /** 1812 * Subclasses of Phone probably want to replace this with a 1813 * version scoped to their packages 1814 */ notifyServiceStateChangedP(ServiceState ss)1815 protected void notifyServiceStateChangedP(ServiceState ss) { 1816 AsyncResult ar = new AsyncResult(null, new ServiceState(ss), null); 1817 mServiceStateRegistrants.notifyRegistrants(ar); 1818 1819 mNotifier.notifyServiceState(this); 1820 } 1821 1822 /** 1823 * Version of notifyServiceStateChangedP which allows us to specify the subId. This is used when 1824 * we send out a final ServiceState update when a phone's subId becomes invalid. 1825 */ notifyServiceStateChangedPForSubId(ServiceState ss, int subId)1826 protected void notifyServiceStateChangedPForSubId(ServiceState ss, int subId) { 1827 AsyncResult ar = new AsyncResult(null, ss, null); 1828 mServiceStateRegistrants.notifyRegistrants(ar); 1829 1830 mNotifier.notifyServiceStateForSubId(this, ss, subId); 1831 } 1832 1833 /** 1834 * If this is a simulated phone interface, returns a SimulatedRadioControl. 1835 * @return SimulatedRadioControl if this is a simulated interface; 1836 * otherwise, null. 1837 */ getSimulatedRadioControl()1838 public SimulatedRadioControl getSimulatedRadioControl() { 1839 return mSimulatedRadioControl; 1840 } 1841 1842 /** 1843 * Verifies the current thread is the same as the thread originally 1844 * used in the initialization of this instance. Throws RuntimeException 1845 * if not. 1846 * 1847 * @exception RuntimeException if the current thread is not 1848 * the thread that originally obtained this Phone instance. 1849 */ checkCorrectThread(Handler h)1850 private void checkCorrectThread(Handler h) { 1851 if (h.getLooper() != mLooper) { 1852 throw new RuntimeException( 1853 "com.android.internal.telephony.Phone must be used from within one thread"); 1854 } 1855 } 1856 1857 /** 1858 * Set the properties by matching the carrier string in 1859 * a string-array resource 1860 */ getLocaleFromCarrierProperties()1861 @Nullable Locale getLocaleFromCarrierProperties() { 1862 String carrier = SystemProperties.get("ro.carrier"); 1863 1864 if (null == carrier || 0 == carrier.length() || "unknown".equals(carrier)) { 1865 return null; 1866 } 1867 1868 CharSequence[] carrierLocales = mContext.getResources().getTextArray( 1869 R.array.carrier_properties); 1870 1871 for (int i = 0; i < carrierLocales.length; i+=3) { 1872 String c = carrierLocales[i].toString(); 1873 if (carrier.equals(c)) { 1874 return Locale.forLanguageTag(carrierLocales[i + 1].toString().replace('_', '-')); 1875 } 1876 } 1877 1878 return null; 1879 } 1880 1881 /** 1882 * Get current coarse-grained voice call state. 1883 * Use {@link #registerForPreciseCallStateChanged(Handler, int, Object) 1884 * registerForPreciseCallStateChanged()} for change notification. <p> 1885 * If the phone has an active call and call waiting occurs, 1886 * then the phone state is RINGING not OFFHOOK 1887 * <strong>Note:</strong> 1888 * This registration point provides notification of finer-grained 1889 * changes.<p> 1890 */ 1891 @UnsupportedAppUsage getState()1892 public abstract PhoneConstants.State getState(); 1893 1894 /** 1895 * Retrieves the IccFileHandler of the Phone instance 1896 */ 1897 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getIccFileHandler()1898 public IccFileHandler getIccFileHandler(){ 1899 UiccCardApplication uiccApplication = mUiccApplication.get(); 1900 IccFileHandler fh; 1901 1902 if (uiccApplication == null) { 1903 Rlog.d(LOG_TAG, "getIccFileHandler: uiccApplication == null, return null"); 1904 fh = null; 1905 } else { 1906 fh = uiccApplication.getIccFileHandler(); 1907 } 1908 1909 Rlog.d(LOG_TAG, "getIccFileHandler: fh=" + fh); 1910 return fh; 1911 } 1912 1913 /* 1914 * Retrieves the Handler of the Phone instance 1915 */ getHandler()1916 public Handler getHandler() { 1917 return this; 1918 } 1919 1920 /** 1921 * Update the phone object if the voice radio technology has changed 1922 * 1923 * @param voiceRadioTech The new voice radio technology 1924 */ updatePhoneObject(int voiceRadioTech)1925 public void updatePhoneObject(int voiceRadioTech) { 1926 } 1927 1928 /** 1929 * Retrieves the ServiceStateTracker of the phone instance. 1930 */ 1931 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getServiceStateTracker()1932 public ServiceStateTracker getServiceStateTracker() { 1933 return null; 1934 } 1935 1936 /** 1937 * Override to merge into {@link #getServiceState} when telecom has registered a SIM call 1938 * manager that supports over-the-top SIM-based calling (e.g. carrier-provided wi-fi calling 1939 * implementation). 1940 * 1941 * @param hasService Whether or not the SIM call manager currently provides over-the-top voice 1942 */ setVoiceServiceStateOverride(boolean hasService)1943 public void setVoiceServiceStateOverride(boolean hasService) {} 1944 1945 /** 1946 * Check whether the radio is off for thermal reason. 1947 * 1948 * @return {@code true} only if thermal mitigation is one of the reason for which radio is off. 1949 */ isRadioOffForThermalMitigation()1950 public boolean isRadioOffForThermalMitigation() { 1951 ServiceStateTracker sst = getServiceStateTracker(); 1952 return sst != null && sst.getRadioPowerOffReasons() 1953 .contains(TelephonyManager.RADIO_POWER_REASON_THERMAL); 1954 } 1955 1956 /** 1957 * Retrieves the EmergencyNumberTracker of the phone instance. 1958 */ getEmergencyNumberTracker()1959 public EmergencyNumberTracker getEmergencyNumberTracker() { 1960 return null; 1961 } 1962 1963 /** 1964 * Get call tracker 1965 */ 1966 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getCallTracker()1967 public CallTracker getCallTracker() { 1968 return null; 1969 } 1970 1971 /** 1972 * @return The instance of access networks manager. 1973 */ getAccessNetworksManager()1974 public AccessNetworksManager getAccessNetworksManager() { 1975 return null; 1976 } 1977 1978 /** 1979 * Retrieves the DeviceStateMonitor of the phone instance. 1980 */ getDeviceStateMonitor()1981 public DeviceStateMonitor getDeviceStateMonitor() { 1982 return null; 1983 } 1984 1985 /** 1986 * Retrieves the DisplayInfoController of the phone instance. 1987 */ getDisplayInfoController()1988 public DisplayInfoController getDisplayInfoController() { 1989 return null; 1990 } 1991 1992 /** 1993 * Retrieves the SignalStrengthController of the phone instance. 1994 */ getSignalStrengthController()1995 public SignalStrengthController getSignalStrengthController() { 1996 Log.wtf(LOG_TAG, "getSignalStrengthController return null."); 1997 return null; 1998 } 1999 2000 /** 2001 * Update voice activation state 2002 */ setVoiceActivationState(int state)2003 public void setVoiceActivationState(int state) { 2004 mSimActivationTracker.setVoiceActivationState(state); 2005 } 2006 /** 2007 * Update data activation state 2008 */ setDataActivationState(int state)2009 public void setDataActivationState(int state) { 2010 mSimActivationTracker.setDataActivationState(state); 2011 } 2012 2013 /** 2014 * Returns voice activation state 2015 */ getVoiceActivationState()2016 public int getVoiceActivationState() { 2017 return mSimActivationTracker.getVoiceActivationState(); 2018 } 2019 /** 2020 * Returns data activation state 2021 */ getDataActivationState()2022 public int getDataActivationState() { 2023 return mSimActivationTracker.getDataActivationState(); 2024 } 2025 2026 /** 2027 * Update voice mail count related fields and notify listeners 2028 */ updateVoiceMail()2029 public void updateVoiceMail() { 2030 Rlog.e(LOG_TAG, "updateVoiceMail() should be overridden"); 2031 } 2032 getCurrentUiccAppType()2033 public AppType getCurrentUiccAppType() { 2034 UiccCardApplication currentApp = mUiccApplication.get(); 2035 if (currentApp != null) { 2036 return currentApp.getType(); 2037 } 2038 return AppType.APPTYPE_UNKNOWN; 2039 } 2040 2041 /** 2042 * Returns the ICC card interface for this phone, or null 2043 * if not applicable to underlying technology. 2044 */ 2045 @UnsupportedAppUsage getIccCard()2046 public IccCard getIccCard() { 2047 return null; 2048 //throw new Exception("getIccCard Shouldn't be called from Phone"); 2049 } 2050 2051 /** 2052 * Retrieves the serial number of the ICC, if applicable. Returns only the decimal digits before 2053 * the first hex digit in the ICC ID. 2054 */ 2055 @UnsupportedAppUsage getIccSerialNumber()2056 public String getIccSerialNumber() { 2057 IccRecords r = mIccRecords.get(); 2058 return (r != null) ? r.getIccId() : null; 2059 } 2060 2061 /** 2062 * Retrieves the full serial number of the ICC (including hex digits), if applicable. 2063 */ getFullIccSerialNumber()2064 public String getFullIccSerialNumber() { 2065 IccRecords r = mIccRecords.get(); 2066 return (r != null) ? r.getFullIccId() : null; 2067 } 2068 2069 /** 2070 * Returns SIM record load state. Use 2071 * <code>getSimCard().registerForReady()</code> for change notification. 2072 * 2073 * @return true if records from the SIM have been loaded and are 2074 * available (if applicable). If not applicable to the underlying 2075 * technology, returns true as well. 2076 */ getIccRecordsLoaded()2077 public boolean getIccRecordsLoaded() { 2078 IccRecords r = mIccRecords.get(); 2079 return (r != null) ? r.getRecordsLoaded() : false; 2080 } 2081 2082 /** Set the minimum interval for CellInfo requests to the modem */ setCellInfoMinInterval(int interval)2083 public void setCellInfoMinInterval(int interval) { 2084 getServiceStateTracker().setCellInfoMinInterval(interval); 2085 } 2086 2087 /** 2088 * @return the last known CellInfo 2089 */ getAllCellInfo()2090 public List<CellInfo> getAllCellInfo() { 2091 return getServiceStateTracker().getAllCellInfo(); 2092 } 2093 2094 /** 2095 * @param workSource calling WorkSource 2096 * @param rspMsg the response message containing the cell info 2097 */ requestCellInfoUpdate(WorkSource workSource, Message rspMsg)2098 public void requestCellInfoUpdate(WorkSource workSource, Message rspMsg) { 2099 getServiceStateTracker().requestAllCellInfo(workSource, rspMsg); 2100 } 2101 2102 /** 2103 * Returns the current CellIdentity if known 2104 */ getCurrentCellIdentity()2105 public CellIdentity getCurrentCellIdentity() { 2106 return getServiceStateTracker().getCellIdentity(); 2107 } 2108 2109 /** 2110 * @param workSource calling WorkSource 2111 * @param rspMsg the response message containing the cell location 2112 */ getCellIdentity(WorkSource workSource, Message rspMsg)2113 public void getCellIdentity(WorkSource workSource, Message rspMsg) { 2114 getServiceStateTracker().requestCellIdentity(workSource, rspMsg); 2115 } 2116 2117 /** 2118 * Sets the minimum time in milli-seconds between {@link PhoneStateListener#onCellInfoChanged 2119 * PhoneStateListener.onCellInfoChanged} will be invoked. 2120 * 2121 * The default, 0, means invoke onCellInfoChanged when any of the reported 2122 * information changes. Setting the value to INT_MAX(0x7fffffff) means never issue 2123 * A onCellInfoChanged. 2124 * 2125 * @param rateInMillis the rate 2126 * @param workSource calling WorkSource 2127 */ setCellInfoListRate(int rateInMillis, WorkSource workSource)2128 public void setCellInfoListRate(int rateInMillis, WorkSource workSource) { 2129 mCi.setCellInfoListRate(rateInMillis, null, workSource); 2130 } 2131 2132 /** 2133 * Get voice message waiting indicator status. No change notification 2134 * available on this interface. Use PhoneStateNotifier or similar instead. 2135 * 2136 * @return true if there is a voice message waiting 2137 */ getMessageWaitingIndicator()2138 public boolean getMessageWaitingIndicator() { 2139 return mVmCount != 0; 2140 } 2141 2142 /** 2143 * Retrieves manually selected network info. 2144 */ getManualNetworkSelectionPlmn()2145 public String getManualNetworkSelectionPlmn() { 2146 return null; 2147 } 2148 2149 getCallForwardingIndicatorFromSharedPref()2150 private int getCallForwardingIndicatorFromSharedPref() { 2151 int status = IccRecords.CALL_FORWARDING_STATUS_DISABLED; 2152 int subId = getSubId(); 2153 if (SubscriptionManager.isValidSubscriptionId(subId)) { 2154 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 2155 status = sp.getInt(CF_STATUS + subId, IccRecords.CALL_FORWARDING_STATUS_UNKNOWN); 2156 Rlog.d(LOG_TAG, "getCallForwardingIndicatorFromSharedPref: for subId " + subId + "= " + 2157 status); 2158 // Check for old preference if status is UNKNOWN for current subId. This part of the 2159 // code is needed only when upgrading from M to N. 2160 if (status == IccRecords.CALL_FORWARDING_STATUS_UNKNOWN) { 2161 String subscriberId = sp.getString(CF_ID, null); 2162 if (subscriberId != null) { 2163 String currentSubscriberId = getSubscriberId(); 2164 2165 if (subscriberId.equals(currentSubscriberId)) { 2166 // get call forwarding status from preferences 2167 status = sp.getInt(CF_STATUS, IccRecords.CALL_FORWARDING_STATUS_DISABLED); 2168 setCallForwardingIndicatorInSharedPref( 2169 status == IccRecords.CALL_FORWARDING_STATUS_ENABLED ? true : false); 2170 Rlog.d(LOG_TAG, "getCallForwardingIndicatorFromSharedPref: " + status); 2171 } else { 2172 Rlog.d(LOG_TAG, "getCallForwardingIndicatorFromSharedPref: returning " + 2173 "DISABLED as status for matching subscriberId not found"); 2174 } 2175 2176 // get rid of old preferences. 2177 SharedPreferences.Editor editor = sp.edit(); 2178 editor.remove(CF_ID); 2179 editor.remove(CF_STATUS); 2180 editor.apply(); 2181 } 2182 } 2183 } else { 2184 Rlog.e(LOG_TAG, "getCallForwardingIndicatorFromSharedPref: invalid subId " + subId); 2185 } 2186 return status; 2187 } 2188 setCallForwardingIndicatorInSharedPref(boolean enable)2189 private void setCallForwardingIndicatorInSharedPref(boolean enable) { 2190 int status = enable ? IccRecords.CALL_FORWARDING_STATUS_ENABLED : 2191 IccRecords.CALL_FORWARDING_STATUS_DISABLED; 2192 int subId = getSubId(); 2193 Rlog.i(LOG_TAG, "setCallForwardingIndicatorInSharedPref: Storing status = " + status + 2194 " in pref " + CF_STATUS + subId); 2195 2196 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 2197 SharedPreferences.Editor editor = sp.edit(); 2198 editor.putInt(CF_STATUS + subId, status); 2199 editor.apply(); 2200 } 2201 setVoiceCallForwardingFlag(int line, boolean enable, String number)2202 public void setVoiceCallForwardingFlag(int line, boolean enable, String number) { 2203 setCallForwardingIndicatorInSharedPref(enable); 2204 IccRecords r = getIccRecords(); 2205 if (r != null) { 2206 r.setVoiceCallForwardingFlag(line, enable, number); 2207 } 2208 notifyCallForwardingIndicator(); 2209 } 2210 2211 /** 2212 * Set the voice call forwarding flag for GSM/UMTS and the like SIMs 2213 * 2214 * @param r to enable/disable 2215 * @param line to enable/disable 2216 * @param enable 2217 * @param number to which CFU is enabled 2218 */ setVoiceCallForwardingFlag(IccRecords r, int line, boolean enable, String number)2219 public void setVoiceCallForwardingFlag(IccRecords r, int line, boolean enable, 2220 String number) { 2221 setCallForwardingIndicatorInSharedPref(enable); 2222 if (r != null) { 2223 r.setVoiceCallForwardingFlag(line, enable, number); 2224 } 2225 notifyCallForwardingIndicator(); 2226 } 2227 2228 /** 2229 * Get voice call forwarding indicator status. No change notification 2230 * available on this interface. Use PhoneStateNotifier or similar instead. 2231 * 2232 * @return true if there is a voice call forwarding 2233 */ getCallForwardingIndicator()2234 public boolean getCallForwardingIndicator() { 2235 if (getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) { 2236 Rlog.e(LOG_TAG, "getCallForwardingIndicator: not possible in CDMA"); 2237 return false; 2238 } 2239 IccRecords r = getIccRecords(); 2240 int callForwardingIndicator = IccRecords.CALL_FORWARDING_STATUS_UNKNOWN; 2241 if (r != null) { 2242 callForwardingIndicator = r.getVoiceCallForwardingFlag(); 2243 } 2244 if (callForwardingIndicator == IccRecords.CALL_FORWARDING_STATUS_UNKNOWN) { 2245 callForwardingIndicator = getCallForwardingIndicatorFromSharedPref(); 2246 } 2247 Rlog.v(LOG_TAG, "getCallForwardingIndicator: iccForwardingFlag=" + (r != null 2248 ? r.getVoiceCallForwardingFlag() : "null") + ", sharedPrefFlag=" 2249 + getCallForwardingIndicatorFromSharedPref()); 2250 return (callForwardingIndicator == IccRecords.CALL_FORWARDING_STATUS_ENABLED); 2251 } 2252 getCarrierSignalAgent()2253 public CarrierSignalAgent getCarrierSignalAgent() { 2254 return mCarrierSignalAgent; 2255 } 2256 getCarrierActionAgent()2257 public CarrierActionAgent getCarrierActionAgent() { 2258 return mCarrierActionAgent; 2259 } 2260 2261 /** 2262 * Query the CDMA roaming preference setting. 2263 * 2264 * @param response is callback message to report one of TelephonyManager#CDMA_ROAMING_MODE_* 2265 */ queryCdmaRoamingPreference(Message response)2266 public void queryCdmaRoamingPreference(Message response) { 2267 mCi.queryCdmaRoamingPreference(response); 2268 } 2269 2270 /** 2271 * Get the CDMA subscription mode setting. 2272 * 2273 * @param response is callback message to report one of TelephonyManager#CDMA_SUBSCRIPTION_* 2274 */ queryCdmaSubscriptionMode(Message response)2275 public void queryCdmaSubscriptionMode(Message response) { 2276 mCi.getCdmaSubscriptionSource(response); 2277 } 2278 2279 /** 2280 * Get current signal strength. No change notification available on this 2281 * interface. Use <code>PhoneStateNotifier</code> or an equivalent. 2282 * An ASU is 0-31 or -1 if unknown (for GSM, dBm = -113 - 2 * asu). 2283 * The following special values are defined:</p> 2284 * <ul><li>0 means "-113 dBm or less".</li> 2285 * <li>31 means "-51 dBm or greater".</li></ul> 2286 * 2287 * @return Current signal strength as SignalStrength 2288 */ getSignalStrength()2289 public @NonNull SignalStrength getSignalStrength() { 2290 SignalStrengthController ssc = getSignalStrengthController(); 2291 if (ssc == null) { 2292 return new SignalStrength(); 2293 } else { 2294 return ssc.getSignalStrength(); 2295 } 2296 } 2297 2298 /** 2299 * @return true, if the device is in a state where both voice and data 2300 * are supported simultaneously. This can change based on location or network condition. 2301 */ isConcurrentVoiceAndDataAllowed()2302 public boolean isConcurrentVoiceAndDataAllowed() { 2303 ServiceStateTracker sst = getServiceStateTracker(); 2304 return sst == null ? false : sst.isConcurrentVoiceAndDataAllowed(); 2305 } 2306 2307 /** 2308 * Requests to set the CDMA roaming preference 2309 * @param cdmaRoamingType one of TelephonyManager#CDMA_ROAMING_MODE_* 2310 * @param response is callback message 2311 */ setCdmaRoamingPreference(int cdmaRoamingType, Message response)2312 public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) { 2313 mCi.setCdmaRoamingPreference(cdmaRoamingType, response); 2314 } 2315 2316 /** 2317 * Requests to set the CDMA subscription mode 2318 * @param cdmaSubscriptionType one of TelephonyManager#CDMA_SUBSCRIPTION_* 2319 * @param response is callback message 2320 */ setCdmaSubscriptionMode(int cdmaSubscriptionType, Message response)2321 public void setCdmaSubscriptionMode(int cdmaSubscriptionType, Message response) { 2322 mCi.setCdmaSubscriptionSource(cdmaSubscriptionType, response); 2323 } 2324 2325 /** 2326 * Get the effective allowed network types on the device. 2327 * 2328 * @return effective network type 2329 */ getEffectiveAllowedNetworkTypes()2330 private @TelephonyManager.NetworkTypeBitMask long getEffectiveAllowedNetworkTypes() { 2331 long allowedNetworkTypes = TelephonyManager.getAllNetworkTypesBitmask(); 2332 synchronized (mAllowedNetworkTypesForReasons) { 2333 for (long networkTypes : mAllowedNetworkTypesForReasons.values()) { 2334 allowedNetworkTypes = allowedNetworkTypes & networkTypes; 2335 } 2336 } 2337 if (!mIsCarrierNrSupported) { 2338 allowedNetworkTypes &= ~TelephonyManager.NETWORK_TYPE_BITMASK_NR; 2339 } 2340 if (m2gAdminUpdater.isCellular2gDisabled()) { 2341 logd("SubId " + getSubId() 2342 + " disabling 2g in getEffectiveAllowedNetworkTypes according to admin user " 2343 + "restriction"); 2344 allowedNetworkTypes &= ~TelephonyManager.NETWORK_CLASS_BITMASK_2G; 2345 } 2346 logd("SubId" + getSubId() + ",getEffectiveAllowedNetworkTypes: " 2347 + TelephonyManager.convertNetworkTypeBitmaskToString(allowedNetworkTypes)); 2348 return allowedNetworkTypes; 2349 } 2350 2351 /** 2352 * Notify the latest allowed network types changed. 2353 */ notifyAllowedNetworkTypesChanged( @elephonyManager.AllowedNetworkTypesReason int reason)2354 public void notifyAllowedNetworkTypesChanged( 2355 @TelephonyManager.AllowedNetworkTypesReason int reason) { 2356 logd("SubId" + getSubId() + ",notifyAllowedNetworkTypesChanged: reason: " + reason 2357 + " value:" + TelephonyManager.convertNetworkTypeBitmaskToString( 2358 getAllowedNetworkTypes(reason))); 2359 mNotifier.notifyAllowedNetworkTypesChanged(this, reason, getAllowedNetworkTypes(reason)); 2360 } 2361 2362 /** 2363 * Is E-UTRA-NR Dual Connectivity enabled 2364 */ isNrDualConnectivityEnabled(Message message, WorkSource workSource)2365 public void isNrDualConnectivityEnabled(Message message, WorkSource workSource) { 2366 mCi.isNrDualConnectivityEnabled(message, workSource); 2367 } 2368 2369 /** 2370 * Enable/Disable E-UTRA-NR Dual Connectivity 2371 * @param nrDualConnectivityState expected NR dual connectivity state 2372 * This can be passed following states 2373 * <ol> 2374 * <li>Enable NR dual connectivity {@link TelephonyManager#NR_DUAL_CONNECTIVITY_ENABLE} 2375 * <li>Disable NR dual connectivity {@link TelephonyManager#NR_DUAL_CONNECTIVITY_DISABLE} 2376 * <li>Disable NR dual connectivity and force secondary cell to be released 2377 * {@link TelephonyManager#NR_DUAL_CONNECTIVITY_DISABLE_IMMEDIATE} 2378 * </ol> 2379 */ setNrDualConnectivityState( @elephonyManager.NrDualConnectivityState int nrDualConnectivityState, Message message, WorkSource workSource)2380 public void setNrDualConnectivityState( 2381 @TelephonyManager.NrDualConnectivityState int nrDualConnectivityState, 2382 Message message, WorkSource workSource) { 2383 mCi.setNrDualConnectivityState(nrDualConnectivityState, message, workSource); 2384 } 2385 2386 /** 2387 * Get the allowed network types for a certain reason. 2388 * @param reason reason to configure allowed network types 2389 * @return the allowed network types. 2390 */ getAllowedNetworkTypes( @elephonyManager.AllowedNetworkTypesReason int reason)2391 public @TelephonyManager.NetworkTypeBitMask long getAllowedNetworkTypes( 2392 @TelephonyManager.AllowedNetworkTypesReason int reason) { 2393 long allowedNetworkTypes; 2394 long defaultAllowedNetworkTypes = RadioAccessFamily.getRafFromNetworkType( 2395 RILConstants.PREFERRED_NETWORK_MODE); 2396 2397 if (!TelephonyManager.isValidAllowedNetworkTypesReason(reason)) { 2398 throw new IllegalArgumentException("AllowedNetworkTypes NumberFormat exception"); 2399 } 2400 2401 synchronized (mAllowedNetworkTypesForReasons) { 2402 allowedNetworkTypes = mAllowedNetworkTypesForReasons.getOrDefault( 2403 reason, 2404 defaultAllowedNetworkTypes); 2405 } 2406 if (!mIsCarrierNrSupported 2407 && reason == TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER) { 2408 allowedNetworkTypes = updateAllowedNetworkTypeForCarrierWithCarrierConfig(); 2409 } 2410 logd("SubId" + getSubId() + ",get allowed network types " 2411 + convertAllowedNetworkTypeMapIndexToDbName(reason) 2412 + ": value = " + TelephonyManager.convertNetworkTypeBitmaskToString( 2413 allowedNetworkTypes)); 2414 return allowedNetworkTypes; 2415 } 2416 2417 /** 2418 * Loads the allowed network type from subscription database. 2419 */ loadAllowedNetworksFromSubscriptionDatabase()2420 public void loadAllowedNetworksFromSubscriptionDatabase() { 2421 String result = null; 2422 SubscriptionInfoInternal subInfo = mSubscriptionManagerService 2423 .getSubscriptionInfoInternal(getSubId()); 2424 if (subInfo != null) { 2425 result = subInfo.getAllowedNetworkTypesForReasons(); 2426 } 2427 2428 // After fw load network type from DB, do unlock if subId is valid. 2429 mIsAllowedNetworkTypesLoadedFromDb = SubscriptionManager.isValidSubscriptionId( 2430 getSubId()); 2431 2432 if (TextUtils.isEmpty(result)) { 2433 return; 2434 } 2435 2436 logd("SubId" + getSubId() + ",load allowed network types : value = " + result); 2437 Map<Integer, Long> oldAllowedNetworkTypes = new HashMap<>(mAllowedNetworkTypesForReasons); 2438 mAllowedNetworkTypesForReasons.clear(); 2439 try { 2440 // Format: "REASON=VALUE,REASON2=VALUE2" 2441 for (String pair : result.trim().split(",")) { 2442 String[] networkTypesValues = (pair.trim().toLowerCase(Locale.ROOT)).split("="); 2443 if (networkTypesValues.length != 2) { 2444 Rlog.e(LOG_TAG, "Invalid ALLOWED_NETWORK_TYPES from DB, value = " + pair); 2445 continue; 2446 } 2447 int key = convertAllowedNetworkTypeDbNameToMapIndex(networkTypesValues[0]); 2448 long value = Long.parseLong(networkTypesValues[1]); 2449 if (TelephonyManager.isValidAllowedNetworkTypesReason(key) 2450 && value != INVALID_ALLOWED_NETWORK_TYPES) { 2451 synchronized (mAllowedNetworkTypesForReasons) { 2452 mAllowedNetworkTypesForReasons.put(key, value); 2453 } 2454 if (!oldAllowedNetworkTypes.containsKey(key) 2455 || oldAllowedNetworkTypes.get(key) != value) { 2456 if (oldAllowedNetworkTypes.containsKey(key)) { 2457 oldAllowedNetworkTypes.remove(key); 2458 } 2459 notifyAllowedNetworkTypesChanged(key); 2460 } 2461 } 2462 } 2463 } catch (NumberFormatException e) { 2464 Rlog.e(LOG_TAG, "allowedNetworkTypes NumberFormat exception" + e); 2465 } 2466 2467 for (int key : oldAllowedNetworkTypes.keySet()) { 2468 notifyAllowedNetworkTypesChanged(key); 2469 } 2470 } 2471 convertAllowedNetworkTypeDbNameToMapIndex(String name)2472 private int convertAllowedNetworkTypeDbNameToMapIndex(String name) { 2473 switch (name) { 2474 case ALLOWED_NETWORK_TYPES_TEXT_USER: 2475 return TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER; 2476 case ALLOWED_NETWORK_TYPES_TEXT_POWER: 2477 return TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_POWER; 2478 case ALLOWED_NETWORK_TYPES_TEXT_CARRIER: 2479 return TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER; 2480 case ALLOWED_NETWORK_TYPES_TEXT_ENABLE_2G: 2481 return TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G; 2482 default: 2483 return INVALID_ALLOWED_NETWORK_TYPES; 2484 } 2485 } 2486 2487 /** 2488 * Convert the allowed network types reason to string. 2489 * 2490 * @param reason The allowed network types reason. 2491 * 2492 * @return The converted string. 2493 */ convertAllowedNetworkTypeMapIndexToDbName( @elephonyManager.AllowedNetworkTypesReason int reason)2494 public static String convertAllowedNetworkTypeMapIndexToDbName( 2495 @TelephonyManager.AllowedNetworkTypesReason int reason) { 2496 switch (reason) { 2497 case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER: 2498 return ALLOWED_NETWORK_TYPES_TEXT_USER; 2499 case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_POWER: 2500 return ALLOWED_NETWORK_TYPES_TEXT_POWER; 2501 case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER: 2502 return ALLOWED_NETWORK_TYPES_TEXT_CARRIER; 2503 case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G: 2504 return ALLOWED_NETWORK_TYPES_TEXT_ENABLE_2G; 2505 default: 2506 throw new IllegalArgumentException( 2507 "No DB name conversion available for allowed network type reason: " + reason 2508 + ". Did you forget to add an ALLOWED_NETWORK_TYPE_TEXT entry for" 2509 + " a new reason?"); 2510 } 2511 } 2512 2513 private @TelephonyManager.NetworkTypeBitMask long updateAllowedNetworkTypeForCarrierWithCarrierConfig()2514 updateAllowedNetworkTypeForCarrierWithCarrierConfig() { 2515 long defaultAllowedNetworkTypes = RadioAccessFamily.getRafFromNetworkType( 2516 RILConstants.PREFERRED_NETWORK_MODE); 2517 long allowedNetworkTypes; 2518 synchronized (mAllowedNetworkTypesForReasons) { 2519 allowedNetworkTypes = mAllowedNetworkTypesForReasons.getOrDefault( 2520 TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER, 2521 defaultAllowedNetworkTypes); 2522 } 2523 if (mIsCarrierNrSupported) { 2524 return allowedNetworkTypes; 2525 } 2526 allowedNetworkTypes = allowedNetworkTypes & ~TelephonyManager.NETWORK_TYPE_BITMASK_NR; 2527 2528 logd("Allowed network types for 'carrier' reason is changed by carrier config = " 2529 + TelephonyManager.convertNetworkTypeBitmaskToString(allowedNetworkTypes)); 2530 return allowedNetworkTypes; 2531 } 2532 2533 /** 2534 * Requests to set the allowed network types for a specific reason 2535 * 2536 * @param reason reason to configure allowed network type 2537 * @param networkTypes one of the network types 2538 * @param response callback Message 2539 */ setAllowedNetworkTypes(@elephonyManager.AllowedNetworkTypesReason int reason, @TelephonyManager.NetworkTypeBitMask long networkTypes, @Nullable Message response)2540 public void setAllowedNetworkTypes(@TelephonyManager.AllowedNetworkTypesReason int reason, 2541 @TelephonyManager.NetworkTypeBitMask long networkTypes, @Nullable Message response) { 2542 int subId = getSubId(); 2543 if (!TelephonyManager.isValidAllowedNetworkTypesReason(reason)) { 2544 loge("setAllowedNetworkTypes: Invalid allowed network type reason: " + reason); 2545 if (response != null) { 2546 AsyncResult.forMessage(response, null, 2547 new CommandException(CommandException.Error.INVALID_ARGUMENTS)); 2548 response.sendToTarget(); 2549 } 2550 return; 2551 } 2552 if (!SubscriptionManager.isUsableSubscriptionId(subId) 2553 || !mIsAllowedNetworkTypesLoadedFromDb) { 2554 loge("setAllowedNetworkTypes: no sim or network type is not loaded. SubscriptionId: " 2555 + subId + ", isNetworkTypeLoaded" + mIsAllowedNetworkTypesLoadedFromDb); 2556 if (response != null) { 2557 AsyncResult.forMessage(response, null, 2558 new CommandException(CommandException.Error.MISSING_RESOURCE)); 2559 response.sendToTarget(); 2560 } 2561 return; 2562 } 2563 String mapAsString = ""; 2564 synchronized (mAllowedNetworkTypesForReasons) { 2565 mAllowedNetworkTypesForReasons.put(reason, networkTypes); 2566 mapAsString = mAllowedNetworkTypesForReasons.keySet().stream() 2567 .map(key -> convertAllowedNetworkTypeMapIndexToDbName(key) + "=" 2568 + mAllowedNetworkTypesForReasons.get(key)) 2569 .collect(Collectors.joining(",")); 2570 } 2571 SubscriptionManager.setSubscriptionProperty(subId, 2572 SubscriptionManager.ALLOWED_NETWORK_TYPES, 2573 mapAsString); 2574 logd("setAllowedNetworkTypes: SubId" + subId + ",setAllowedNetworkTypes " + mapAsString); 2575 2576 updateAllowedNetworkTypes(response); 2577 notifyAllowedNetworkTypesChanged(reason); 2578 } 2579 updateAllowedNetworkTypes(Message response)2580 protected void updateAllowedNetworkTypes(Message response) { 2581 int modemRaf = getRadioAccessFamily(); 2582 if (modemRaf == RadioAccessFamily.RAF_UNKNOWN) { 2583 Rlog.d(LOG_TAG, "setPreferredNetworkType: Abort, unknown RAF: " 2584 + modemRaf); 2585 if (response != null) { 2586 CommandException ex; 2587 ex = new CommandException(CommandException.Error.GENERIC_FAILURE); 2588 AsyncResult.forMessage(response, null, ex); 2589 response.sendToTarget(); 2590 } 2591 return; 2592 } 2593 2594 int filteredRaf = (int) (modemRaf & getEffectiveAllowedNetworkTypes()); 2595 2596 logd("setAllowedNetworkTypes: modemRafBitMask = " + modemRaf 2597 + " ,modemRaf = " + TelephonyManager.convertNetworkTypeBitmaskToString(modemRaf) 2598 + " ,filteredRafBitMask = " + filteredRaf 2599 + " ,filteredRaf = " + TelephonyManager.convertNetworkTypeBitmaskToString( 2600 filteredRaf)); 2601 mCi.setAllowedNetworkTypesBitmap(filteredRaf, response); 2602 mPreferredNetworkTypeRegistrants.notifyRegistrants(); 2603 } 2604 2605 /** 2606 * Query the allowed network types bitmask setting 2607 * 2608 * @param response is callback message to report network types bitmask 2609 */ getAllowedNetworkTypesBitmask(Message response)2610 public void getAllowedNetworkTypesBitmask(Message response) { 2611 mCi.getAllowedNetworkTypesBitmap(response); 2612 } 2613 2614 /** 2615 * Register for preferred network type changes 2616 * 2617 * @param h Handler that receives the notification message. 2618 * @param what User-defined message code. 2619 * @param obj User object. 2620 */ registerForPreferredNetworkTypeChanged(Handler h, int what, Object obj)2621 public void registerForPreferredNetworkTypeChanged(Handler h, int what, Object obj) { 2622 checkCorrectThread(h); 2623 mPreferredNetworkTypeRegistrants.addUnique(h, what, obj); 2624 } 2625 2626 /** 2627 * Unregister for preferred network type changes. 2628 * 2629 * @param h Handler that should be unregistered. 2630 */ unregisterForPreferredNetworkTypeChanged(Handler h)2631 public void unregisterForPreferredNetworkTypeChanged(Handler h) { 2632 mPreferredNetworkTypeRegistrants.remove(h); 2633 } 2634 2635 /** 2636 * Get the cached value of the preferred network type setting 2637 */ getCachedAllowedNetworkTypesBitmask()2638 public int getCachedAllowedNetworkTypesBitmask() { 2639 if (mCi != null && mCi instanceof BaseCommands) { 2640 return ((BaseCommands) mCi).mAllowedNetworkTypesBitmask; 2641 } else { 2642 return RadioAccessFamily.getRafFromNetworkType(RILConstants.PREFERRED_NETWORK_MODE); 2643 } 2644 } 2645 2646 /** 2647 * Gets the default SMSC address. 2648 * 2649 * @param result Callback message contains the SMSC address. 2650 */ 2651 @UnsupportedAppUsage getSmscAddress(Message result)2652 public void getSmscAddress(Message result) { 2653 mCi.getSmscAddress(result); 2654 } 2655 2656 /** 2657 * Sets the default SMSC address. 2658 * 2659 * @param address new SMSC address 2660 * @param result Callback message is empty on completion 2661 */ 2662 @UnsupportedAppUsage setSmscAddress(String address, Message result)2663 public void setSmscAddress(String address, Message result) { 2664 mCi.setSmscAddress(address, result); 2665 } 2666 2667 /** 2668 * setTTYMode 2669 * sets a TTY mode option. 2670 * @param ttyMode is a one of the following: 2671 * - {@link com.android.internal.telephony.Phone#TTY_MODE_OFF} 2672 * - {@link com.android.internal.telephony.Phone#TTY_MODE_FULL} 2673 * - {@link com.android.internal.telephony.Phone#TTY_MODE_HCO} 2674 * - {@link com.android.internal.telephony.Phone#TTY_MODE_VCO} 2675 * @param onComplete a callback message when the action is completed 2676 */ setTTYMode(int ttyMode, Message onComplete)2677 public void setTTYMode(int ttyMode, Message onComplete) { 2678 mCi.setTTYMode(ttyMode, onComplete); 2679 } 2680 2681 /** 2682 * setUiTTYMode 2683 * sets a TTY mode option. 2684 * @param ttyMode is a one of the following: 2685 * - {@link com.android.internal.telephony.Phone#TTY_MODE_OFF} 2686 * - {@link com.android.internal.telephony.Phone#TTY_MODE_FULL} 2687 * - {@link com.android.internal.telephony.Phone#TTY_MODE_HCO} 2688 * - {@link com.android.internal.telephony.Phone#TTY_MODE_VCO} 2689 * @param onComplete a callback message when the action is completed 2690 */ setUiTTYMode(int uiTtyMode, Message onComplete)2691 public void setUiTTYMode(int uiTtyMode, Message onComplete) { 2692 Rlog.d(LOG_TAG, "unexpected setUiTTYMode method call"); 2693 } 2694 2695 /** 2696 * queryTTYMode 2697 * query the status of the TTY mode 2698 * 2699 * @param onComplete a callback message when the action is completed. 2700 */ queryTTYMode(Message onComplete)2701 public void queryTTYMode(Message onComplete) { 2702 mCi.queryTTYMode(onComplete); 2703 } 2704 2705 /** 2706 * Enable or disable enhanced Voice Privacy (VP). If enhanced VP is 2707 * disabled, normal VP is enabled. 2708 * 2709 * @param enable whether true or false to enable or disable. 2710 * @param onComplete a callback message when the action is completed. 2711 */ enableEnhancedVoicePrivacy(boolean enable, Message onComplete)2712 public void enableEnhancedVoicePrivacy(boolean enable, Message onComplete) { 2713 } 2714 2715 /** 2716 * Get the currently set Voice Privacy (VP) mode. 2717 * 2718 * @param onComplete a callback message when the action is completed. 2719 */ getEnhancedVoicePrivacy(Message onComplete)2720 public void getEnhancedVoicePrivacy(Message onComplete) { 2721 } 2722 2723 /** 2724 * Assign a specified band for RF configuration. 2725 * 2726 * @param bandMode one of BM_*_BAND 2727 * @param response is callback message 2728 */ setBandMode(int bandMode, Message response)2729 public void setBandMode(int bandMode, Message response) { 2730 mCi.setBandMode(bandMode, response); 2731 } 2732 2733 /** 2734 * Query the list of band mode supported by RF. 2735 * 2736 * @param response is callback message 2737 * ((AsyncResult)response.obj).result is an int[] where int[0] is 2738 * the size of the array and the rest of each element representing 2739 * one available BM_*_BAND 2740 */ queryAvailableBandMode(Message response)2741 public void queryAvailableBandMode(Message response) { 2742 mCi.queryAvailableBandMode(response); 2743 } 2744 2745 /** 2746 * Invokes RIL_REQUEST_OEM_HOOK_RAW on RIL implementation. 2747 * 2748 * @param data The data for the request. 2749 * @param response <strong>On success</strong>, 2750 * (byte[])(((AsyncResult)response.obj).result) 2751 * <strong>On failure</strong>, 2752 * (((AsyncResult)response.obj).result) == null and 2753 * (((AsyncResult)response.obj).exception) being an instance of 2754 * com.android.internal.telephony.gsm.CommandException 2755 * 2756 * @see #invokeOemRilRequestRaw(byte[], android.os.Message) 2757 * @deprecated OEM needs a vendor-extension hal and their apps should use that instead 2758 */ 2759 @UnsupportedAppUsage 2760 @Deprecated invokeOemRilRequestRaw(byte[] data, Message response)2761 public void invokeOemRilRequestRaw(byte[] data, Message response) { 2762 mCi.invokeOemRilRequestRaw(data, response); 2763 } 2764 2765 /** 2766 * Invokes RIL_REQUEST_OEM_HOOK_Strings on RIL implementation. 2767 * 2768 * @param strings The strings to make available as the request data. 2769 * @param response <strong>On success</strong>, "response" bytes is 2770 * made available as: 2771 * (String[])(((AsyncResult)response.obj).result). 2772 * <strong>On failure</strong>, 2773 * (((AsyncResult)response.obj).result) == null and 2774 * (((AsyncResult)response.obj).exception) being an instance of 2775 * com.android.internal.telephony.gsm.CommandException 2776 * 2777 * @see #invokeOemRilRequestStrings(java.lang.String[], android.os.Message) 2778 * @deprecated OEM needs a vendor-extension hal and their apps should use that instead 2779 */ 2780 @UnsupportedAppUsage 2781 @Deprecated invokeOemRilRequestStrings(String[] strings, Message response)2782 public void invokeOemRilRequestStrings(String[] strings, Message response) { 2783 mCi.invokeOemRilRequestStrings(strings, response); 2784 } 2785 2786 /** 2787 * Read one of the NV items defined in {@link RadioNVItems} / {@code ril_nv_items.h}. 2788 * Used for device configuration by some CDMA operators. 2789 * 2790 * @param itemID the ID of the item to read 2791 * @param response callback message with the String response in the obj field 2792 * @param workSource calling WorkSource 2793 */ nvReadItem(int itemID, Message response, WorkSource workSource)2794 public void nvReadItem(int itemID, Message response, WorkSource workSource) { 2795 mCi.nvReadItem(itemID, response, workSource); 2796 } 2797 2798 /** 2799 * Write one of the NV items defined in {@link RadioNVItems} / {@code ril_nv_items.h}. 2800 * Used for device configuration by some CDMA operators. 2801 * 2802 * @param itemID the ID of the item to read 2803 * @param itemValue the value to write, as a String 2804 * @param response Callback message. 2805 * @param workSource calling WorkSource 2806 */ nvWriteItem(int itemID, String itemValue, Message response, WorkSource workSource)2807 public void nvWriteItem(int itemID, String itemValue, Message response, 2808 WorkSource workSource) { 2809 mCi.nvWriteItem(itemID, itemValue, response, workSource); 2810 } 2811 2812 /** 2813 * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage. 2814 * Used for device configuration by some CDMA operators. 2815 * 2816 * @param preferredRoamingList byte array containing the new PRL 2817 * @param response Callback message. 2818 */ nvWriteCdmaPrl(byte[] preferredRoamingList, Message response)2819 public void nvWriteCdmaPrl(byte[] preferredRoamingList, Message response) { 2820 mCi.nvWriteCdmaPrl(preferredRoamingList, response); 2821 } 2822 2823 /** 2824 * Perform the radio modem reboot. The radio will be taken offline. Used for device 2825 * configuration by some CDMA operators. 2826 * TODO: reuse nvResetConfig for now, should move to separate HAL API. 2827 * 2828 * @param response Callback message. 2829 */ rebootModem(Message response)2830 public void rebootModem(Message response) { 2831 mCi.nvResetConfig(1 /* 1: reload NV reset, trigger a modem reboot */, response); 2832 } 2833 2834 /** 2835 * Perform the modem configuration reset. Used for device configuration by some CDMA operators. 2836 * TODO: reuse nvResetConfig for now, should move to separate HAL API. 2837 * 2838 * @param response Callback message. 2839 */ resetModemConfig(Message response)2840 public void resetModemConfig(Message response) { 2841 mCi.nvResetConfig(3 /* factory NV reset */, response); 2842 } 2843 2844 /** 2845 * Perform modem configuration erase. Used for network reset 2846 * 2847 * @param response Callback message. 2848 */ eraseModemConfig(Message response)2849 public void eraseModemConfig(Message response) { 2850 mCi.nvResetConfig(2 /* erase NV */, response); 2851 } 2852 2853 /** 2854 * Erase data saved in the SharedPreference. Used for network reset 2855 * 2856 */ eraseDataInSharedPreferences()2857 public boolean eraseDataInSharedPreferences() { 2858 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 2859 SharedPreferences.Editor editor = sp.edit(); 2860 Rlog.d(LOG_TAG, "Erase all data saved in SharedPreferences"); 2861 editor.clear(); 2862 return editor.commit(); 2863 } 2864 setSystemSelectionChannels(List<RadioAccessSpecifier> specifiers, Message response)2865 public void setSystemSelectionChannels(List<RadioAccessSpecifier> specifiers, 2866 Message response) { 2867 mCi.setSystemSelectionChannels(specifiers, response); 2868 } 2869 2870 /** 2871 * Get which bands the modem's background scan is acting on. 2872 * 2873 * @param response Callback message. 2874 */ getSystemSelectionChannels(Message response)2875 public void getSystemSelectionChannels(Message response) { 2876 mCi.getSystemSelectionChannels(response); 2877 } 2878 notifyDataActivity()2879 public void notifyDataActivity() { 2880 mNotifier.notifyDataActivity(this); 2881 } 2882 notifyMessageWaitingIndicator()2883 private void notifyMessageWaitingIndicator() { 2884 // Do not notify voice mail waiting if device doesn't support voice 2885 if (!mIsVoiceCapable) 2886 return; 2887 2888 // This function is added to send the notification to DefaultPhoneNotifier. 2889 mNotifier.notifyMessageWaitingChanged(this); 2890 } 2891 2892 /** Send notification with an updated PreciseDataConnectionState to a single data connection */ notifyDataConnection(PreciseDataConnectionState state)2893 public void notifyDataConnection(PreciseDataConnectionState state) { 2894 mNotifier.notifyDataConnection(this, state); 2895 } 2896 2897 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) notifyOtaspChanged(int otaspMode)2898 public void notifyOtaspChanged(int otaspMode) { 2899 mOtaspRegistrants.notifyRegistrants(new AsyncResult(null, otaspMode, null)); 2900 } 2901 notifyVoiceActivationStateChanged(int state)2902 public void notifyVoiceActivationStateChanged(int state) { 2903 mNotifier.notifyVoiceActivationStateChanged(this, state); 2904 } 2905 notifyDataActivationStateChanged(int state)2906 public void notifyDataActivationStateChanged(int state) { 2907 mNotifier.notifyDataActivationStateChanged(this, state); 2908 } 2909 notifyUserMobileDataStateChanged(boolean state)2910 public void notifyUserMobileDataStateChanged(boolean state) { 2911 mNotifier.notifyUserMobileDataStateChanged(this, state); 2912 } 2913 2914 /** Send notification that display info has changed. */ notifyDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo)2915 public void notifyDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo) { 2916 mNotifier.notifyDisplayInfoChanged(this, telephonyDisplayInfo); 2917 } 2918 notifySignalStrength()2919 public void notifySignalStrength() { 2920 mNotifier.notifySignalStrength(this); 2921 } 2922 getDataConnectionState(String apnType)2923 public PhoneConstants.DataState getDataConnectionState(String apnType) { 2924 return PhoneConstants.DataState.DISCONNECTED; 2925 } 2926 2927 /** Default implementation to get the PreciseDataConnectionState */ getPreciseDataConnectionState(String apnType)2928 public @Nullable PreciseDataConnectionState getPreciseDataConnectionState(String apnType) { 2929 return null; 2930 } 2931 notifyCellInfo(List<CellInfo> cellInfo)2932 public void notifyCellInfo(List<CellInfo> cellInfo) { 2933 AsyncResult ar = new AsyncResult(null, cellInfo, null); 2934 mCellInfoRegistrants.notifyRegistrants(ar); 2935 2936 mNotifier.notifyCellInfo(this, cellInfo); 2937 } 2938 2939 /** 2940 * Registration point for PhysicalChannelConfig change. 2941 * @param h handler to notify 2942 * @param what what code of message when delivered 2943 * @param obj placed in Message.obj.userObj 2944 */ registerForPhysicalChannelConfig(Handler h, int what, Object obj)2945 public void registerForPhysicalChannelConfig(Handler h, int what, Object obj) { 2946 checkCorrectThread(h); 2947 Registrant registrant = new Registrant(h, what, obj); 2948 mPhysicalChannelConfigRegistrants.add(registrant); 2949 // notify first 2950 List<PhysicalChannelConfig> physicalChannelConfigs = getPhysicalChannelConfigList(); 2951 if (physicalChannelConfigs != null) { 2952 registrant.notifyRegistrant(new AsyncResult(null, physicalChannelConfigs, null)); 2953 } 2954 } 2955 unregisterForPhysicalChannelConfig(Handler h)2956 public void unregisterForPhysicalChannelConfig(Handler h) { 2957 mPhysicalChannelConfigRegistrants.remove(h); 2958 } 2959 2960 /** Notify {@link PhysicalChannelConfig} changes. */ notifyPhysicalChannelConfig(List<PhysicalChannelConfig> configs)2961 public void notifyPhysicalChannelConfig(List<PhysicalChannelConfig> configs) { 2962 mPhysicalChannelConfigRegistrants.notifyRegistrants(new AsyncResult(null, configs, null)); 2963 mNotifier.notifyPhysicalChannelConfig(this, configs); 2964 } 2965 getPhysicalChannelConfigList()2966 public List<PhysicalChannelConfig> getPhysicalChannelConfigList() { 2967 return null; 2968 } 2969 2970 /** 2971 * Notify listeners that SRVCC state has changed. 2972 */ notifySrvccStateChanged(int state)2973 public void notifySrvccStateChanged(int state) { 2974 mNotifier.notifySrvccStateChanged(this, state); 2975 } 2976 2977 /** Notify the {@link EmergencyNumber} changes. */ notifyEmergencyNumberList()2978 public void notifyEmergencyNumberList() { 2979 mNotifier.notifyEmergencyNumberList(this); 2980 } 2981 2982 /** Notify the outgoing Sms {@link EmergencyNumber} changes. */ notifyOutgoingEmergencySms(EmergencyNumber emergencyNumber)2983 public void notifyOutgoingEmergencySms(EmergencyNumber emergencyNumber) { 2984 mNotifier.notifyOutgoingEmergencySms(this, emergencyNumber); 2985 } 2986 2987 /** Notify the data enabled changes. */ notifyDataEnabled(boolean enabled, @TelephonyManager.DataEnabledReason int reason)2988 public void notifyDataEnabled(boolean enabled, 2989 @TelephonyManager.DataEnabledReason int reason) { 2990 mNotifier.notifyDataEnabled(this, enabled, reason); 2991 } 2992 2993 /** Notify link capacity estimate has changed. */ notifyLinkCapacityEstimateChanged( List<LinkCapacityEstimate> linkCapacityEstimateList)2994 public void notifyLinkCapacityEstimateChanged( 2995 List<LinkCapacityEstimate> linkCapacityEstimateList) { 2996 mNotifier.notifyLinkCapacityEstimateChanged(this, linkCapacityEstimateList); 2997 } 2998 2999 /** 3000 * @return true if a mobile originating emergency call is active 3001 */ isInEmergencyCall()3002 public boolean isInEmergencyCall() { 3003 return false; 3004 } 3005 3006 // This property is used to handle phone process crashes, and is the same for CDMA and IMS 3007 // phones getInEcmMode()3008 protected static boolean getInEcmMode() { 3009 if (DomainSelectionResolver.getInstance().isDomainSelectionSupported()) { 3010 return EmergencyStateTracker.getInstance().isInEcm(); 3011 } 3012 return TelephonyProperties.in_ecm_mode().orElse(false); 3013 } 3014 3015 /** 3016 * @return {@code true} if we are in emergency call back mode. This is a period where the phone 3017 * should be using as little power as possible and be ready to receive an incoming call from the 3018 * emergency operator. 3019 */ isInEcm()3020 public boolean isInEcm() { 3021 if (DomainSelectionResolver.getInstance().isDomainSelectionSupported()) { 3022 return EmergencyStateTracker.getInstance().isInEcm(); 3023 } 3024 return mIsPhoneInEcmState; 3025 } 3026 isInImsEcm()3027 public boolean isInImsEcm() { 3028 return false; 3029 } 3030 isInCdmaEcm()3031 public boolean isInCdmaEcm() { 3032 if (DomainSelectionResolver.getInstance().isDomainSelectionSupported()) { 3033 return EmergencyStateTracker.getInstance().isInCdmaEcm(); 3034 } 3035 return getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA && isInEcm() 3036 && (mImsPhone == null || !mImsPhone.isInImsEcm()); 3037 } 3038 setIsInEcm(boolean isInEcm)3039 public void setIsInEcm(boolean isInEcm) { 3040 if (!getUnitTestMode()) { 3041 TelephonyProperties.in_ecm_mode(isInEcm); 3042 } 3043 mIsPhoneInEcmState = isInEcm; 3044 } 3045 3046 /** 3047 * @return true if this Phone is in an emergency call that caused emergency callback mode to be 3048 * canceled, false if not. 3049 */ isEcmCanceledForEmergency()3050 public boolean isEcmCanceledForEmergency() { 3051 return mEcmCanceledForEmergency; 3052 } 3053 3054 /** 3055 * Set whether or not this Phone has an active emergency call that was placed during emergency 3056 * callback mode and caused it to be temporarily canceled. 3057 * @param isCanceled true if an emergency call was placed that caused ECM to be canceled, false 3058 * if it is not in this state. 3059 */ setEcmCanceledForEmergency(boolean isCanceled)3060 public void setEcmCanceledForEmergency(boolean isCanceled) { 3061 mEcmCanceledForEmergency = isCanceled; 3062 } 3063 3064 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getVideoState(Call call)3065 private static int getVideoState(Call call) { 3066 int videoState = VideoProfile.STATE_AUDIO_ONLY; 3067 Connection conn = call.getEarliestConnection(); 3068 if (conn != null) { 3069 videoState = conn.getVideoState(); 3070 } 3071 return videoState; 3072 } 3073 3074 /** 3075 * Determines if the specified call currently is or was at some point a video call, or if it is 3076 * a conference call. 3077 * @param call The call. 3078 * @return {@code true} if the call is or was a video call or is a conference call, 3079 * {@code false} otherwise. 3080 */ isVideoCallOrConference(Call call)3081 private boolean isVideoCallOrConference(Call call) { 3082 if (call.isMultiparty()) { 3083 return true; 3084 } 3085 3086 boolean isDowngradedVideoCall = false; 3087 if (call instanceof ImsPhoneCall) { 3088 ImsPhoneCall imsPhoneCall = (ImsPhoneCall) call; 3089 ImsCall imsCall = imsPhoneCall.getImsCall(); 3090 return imsCall != null && (imsCall.isVideoCall() || 3091 imsCall.wasVideoCall()); 3092 } 3093 return isDowngradedVideoCall; 3094 } 3095 3096 /** 3097 * @return {@code true} if an IMS video call or IMS conference is present, false otherwise. 3098 */ isImsVideoCallOrConferencePresent()3099 public boolean isImsVideoCallOrConferencePresent() { 3100 boolean isPresent = false; 3101 if (mImsPhone != null) { 3102 isPresent = isVideoCallOrConference(mImsPhone.getForegroundCall()) || 3103 isVideoCallOrConference(mImsPhone.getBackgroundCall()) || 3104 isVideoCallOrConference(mImsPhone.getRingingCall()); 3105 } 3106 Rlog.d(LOG_TAG, "isImsVideoCallOrConferencePresent: " + isPresent); 3107 return isPresent; 3108 } 3109 3110 /** 3111 * Return a numerical identifier for the phone radio interface. 3112 * @return PHONE_TYPE_XXX as defined above. 3113 */ 3114 @UnsupportedAppUsage getPhoneType()3115 public abstract int getPhoneType(); 3116 3117 /** 3118 * Returns unread voicemail count. This count is shown when the voicemail 3119 * notification is expanded.<p> 3120 */ getVoiceMessageCount()3121 public int getVoiceMessageCount(){ 3122 return mVmCount; 3123 } 3124 3125 /** sets the voice mail count of the phone and notifies listeners. */ setVoiceMessageCount(int countWaiting)3126 public void setVoiceMessageCount(int countWaiting) { 3127 mVmCount = countWaiting; 3128 int subId = getSubId(); 3129 if (SubscriptionManager.isValidSubscriptionId(subId)) { 3130 3131 Rlog.d(LOG_TAG, "setVoiceMessageCount: Storing Voice Mail Count = " + countWaiting + 3132 " for mVmCountKey = " + VM_COUNT + subId + " in preferences."); 3133 3134 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 3135 SharedPreferences.Editor editor = sp.edit(); 3136 editor.putInt(VM_COUNT + subId, countWaiting); 3137 editor.apply(); 3138 } else { 3139 Rlog.e(LOG_TAG, "setVoiceMessageCount in sharedPreference: invalid subId " + subId); 3140 } 3141 // store voice mail count in SIM 3142 IccRecords records = UiccController.getInstance().getIccRecords( 3143 mPhoneId, UiccController.APP_FAM_3GPP); 3144 if (records != null) { 3145 Rlog.d(LOG_TAG, "setVoiceMessageCount: updating SIM Records"); 3146 records.setVoiceMessageWaiting(1, countWaiting); 3147 } else { 3148 Rlog.d(LOG_TAG, "setVoiceMessageCount: SIM Records not found"); 3149 } 3150 // notify listeners of voice mail 3151 notifyMessageWaitingIndicator(); 3152 } 3153 3154 /** gets the voice mail count from preferences */ getStoredVoiceMessageCount()3155 protected int getStoredVoiceMessageCount() { 3156 int countVoiceMessages = 0; 3157 int subId = getSubId(); 3158 if (SubscriptionManager.isValidSubscriptionId(subId)) { 3159 int invalidCount = -2; //-1 is not really invalid. It is used for unknown number of vm 3160 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 3161 int countFromSP = sp.getInt(VM_COUNT + subId, invalidCount); 3162 if (countFromSP != invalidCount) { 3163 countVoiceMessages = countFromSP; 3164 Rlog.d(LOG_TAG, "getStoredVoiceMessageCount: from preference for subId " + subId + 3165 "= " + countVoiceMessages); 3166 } else { 3167 // Check for old preference if count not found for current subId. This part of the 3168 // code is needed only when upgrading from M to N. 3169 String subscriberId = sp.getString(VM_ID, null); 3170 if (subscriberId != null) { 3171 String currentSubscriberId = getSubscriberId(); 3172 3173 if (currentSubscriberId != null && currentSubscriberId.equals(subscriberId)) { 3174 // get voice mail count from preferences 3175 countVoiceMessages = sp.getInt(VM_COUNT, 0); 3176 setVoiceMessageCount(countVoiceMessages); 3177 Rlog.d(LOG_TAG, "getStoredVoiceMessageCount: from preference = " + 3178 countVoiceMessages); 3179 } else { 3180 Rlog.d(LOG_TAG, "getStoredVoiceMessageCount: returning 0 as count for " + 3181 "matching subscriberId not found"); 3182 3183 } 3184 // get rid of old preferences. 3185 SharedPreferences.Editor editor = sp.edit(); 3186 editor.remove(VM_ID); 3187 editor.remove(VM_COUNT); 3188 editor.apply(); 3189 } 3190 } 3191 } else { 3192 Rlog.e(LOG_TAG, "getStoredVoiceMessageCount: invalid subId " + subId); 3193 } 3194 return countVoiceMessages; 3195 } 3196 3197 /** 3198 * send secret dialer codes to launch arbitrary activities. 3199 * an Intent is started with the android_secret_code://<code> URI. 3200 * 3201 * @param code stripped version of secret code without *#*# prefix and #*#* suffix 3202 */ sendDialerSpecialCode(String code)3203 public void sendDialerSpecialCode(String code) { 3204 if (!TextUtils.isEmpty(code)) { 3205 final BroadcastOptions options = BroadcastOptions.makeBasic(); 3206 options.setBackgroundActivityStartsAllowed(true); 3207 Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION, 3208 Uri.parse("android_secret_code://" + code)); 3209 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 3210 mContext.sendBroadcast(intent, null, options.toBundle()); 3211 3212 // {@link TelephonyManager.ACTION_SECRET_CODE} will replace {@link 3213 // TelephonyIntents#SECRET_CODE_ACTION} in the next Android version. Before 3214 // that both of these two actions will be broadcast. 3215 Intent secrectCodeIntent = new Intent(TelephonyManager.ACTION_SECRET_CODE, 3216 Uri.parse("android_secret_code://" + code)); 3217 secrectCodeIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 3218 mContext.sendBroadcast(secrectCodeIntent, null, options.toBundle()); 3219 } 3220 } 3221 3222 /** 3223 * Returns the CDMA ERI icon index to display 3224 */ getCdmaEriIconIndex()3225 public int getCdmaEriIconIndex() { 3226 return -1; 3227 } 3228 3229 /** 3230 * Returns the CDMA ERI icon mode, 3231 * 0 - ON 3232 * 1 - FLASHING 3233 */ getCdmaEriIconMode()3234 public int getCdmaEriIconMode() { 3235 return -1; 3236 } 3237 3238 /** 3239 * Returns the CDMA ERI text, 3240 */ getCdmaEriText()3241 public String getCdmaEriText() { 3242 return "GSM nw, no ERI"; 3243 } 3244 3245 /** 3246 * Retrieves the MIN for CDMA phones. 3247 */ getCdmaMin()3248 public String getCdmaMin() { 3249 return null; 3250 } 3251 3252 /** 3253 * Check if subscription data has been assigned to mMin 3254 * 3255 * return true if MIN info is ready; false otherwise. 3256 */ isMinInfoReady()3257 public boolean isMinInfoReady() { 3258 return false; 3259 } 3260 3261 /** 3262 * Retrieves PRL Version for CDMA phones 3263 */ getCdmaPrlVersion()3264 public String getCdmaPrlVersion(){ 3265 return null; 3266 } 3267 3268 /** 3269 * @return {@code true} if data is suspended. 3270 */ isDataSuspended()3271 public boolean isDataSuspended() { 3272 return false; 3273 } 3274 3275 /** 3276 * send burst DTMF tone, it can send the string as single character or multiple character 3277 * ignore if there is no active call or not valid digits string. 3278 * Valid digit means only includes characters ISO-LATIN characters 0-9, *, # 3279 * The difference between sendDtmf and sendBurstDtmf is sendDtmf only sends one character, 3280 * this api can send single character and multiple character, also, this api has response 3281 * back to caller. 3282 * 3283 * @param dtmfString is string representing the dialing digit(s) in the active call 3284 * @param on the DTMF ON length in milliseconds, or 0 for default 3285 * @param off the DTMF OFF length in milliseconds, or 0 for default 3286 * @param onComplete is the callback message when the action is processed by BP 3287 * 3288 */ sendBurstDtmf(String dtmfString, int on, int off, Message onComplete)3289 public void sendBurstDtmf(String dtmfString, int on, int off, Message onComplete) { 3290 } 3291 3292 /** 3293 * Sets an event to be fired when the telephony system processes 3294 * a post-dial character on an outgoing call.<p> 3295 * 3296 * Messages of type <code>what</code> will be sent to <code>h</code>. 3297 * The <code>obj</code> field of these Message's will be instances of 3298 * <code>AsyncResult</code>. <code>Message.obj.result</code> will be 3299 * a Connection object.<p> 3300 * 3301 * Message.arg1 will be the post dial character being processed, 3302 * or 0 ('\0') if end of string.<p> 3303 * 3304 * If Connection.getPostDialState() == WAIT, 3305 * the application must call 3306 * {@link com.android.internal.telephony.Connection#proceedAfterWaitChar() 3307 * Connection.proceedAfterWaitChar()} or 3308 * {@link com.android.internal.telephony.Connection#cancelPostDial() 3309 * Connection.cancelPostDial()} 3310 * for the telephony system to continue playing the post-dial 3311 * DTMF sequence.<p> 3312 * 3313 * If Connection.getPostDialState() == WILD, 3314 * the application must call 3315 * {@link com.android.internal.telephony.Connection#proceedAfterWildChar 3316 * Connection.proceedAfterWildChar()} 3317 * or 3318 * {@link com.android.internal.telephony.Connection#cancelPostDial() 3319 * Connection.cancelPostDial()} 3320 * for the telephony system to continue playing the 3321 * post-dial DTMF sequence.<p> 3322 * 3323 * Only one post dial character handler may be set. <p> 3324 * Calling this method with "h" equal to null unsets this handler.<p> 3325 */ 3326 @UnsupportedAppUsage setOnPostDialCharacter(Handler h, int what, Object obj)3327 public void setOnPostDialCharacter(Handler h, int what, Object obj) { 3328 mPostDialHandler = new Registrant(h, what, obj); 3329 } 3330 getPostDialHandler()3331 public Registrant getPostDialHandler() { 3332 return mPostDialHandler; 3333 } 3334 3335 /** 3336 * request to exit emergency call back mode 3337 * the caller should use setOnECMModeExitResponse 3338 * to receive the emergency callback mode exit response 3339 */ 3340 @UnsupportedAppUsage exitEmergencyCallbackMode()3341 public void exitEmergencyCallbackMode() { 3342 } 3343 3344 /** 3345 * Register for notifications when CDMA OTA Provision status change 3346 * 3347 * @param h Handler that receives the notification message. 3348 * @param what User-defined message code. 3349 * @param obj User object. 3350 */ registerForCdmaOtaStatusChange(Handler h, int what, Object obj)3351 public void registerForCdmaOtaStatusChange(Handler h, int what, Object obj) { 3352 } 3353 3354 /** 3355 * Unregister for notifications when CDMA OTA Provision status change 3356 * @param h Handler to be removed from the registrant list. 3357 */ unregisterForCdmaOtaStatusChange(Handler h)3358 public void unregisterForCdmaOtaStatusChange(Handler h) { 3359 } 3360 3361 /** 3362 * Registration point for subscription info ready 3363 * @param h handler to notify 3364 * @param what what code of message when delivered 3365 * @param obj placed in Message.obj 3366 */ registerForSubscriptionInfoReady(Handler h, int what, Object obj)3367 public void registerForSubscriptionInfoReady(Handler h, int what, Object obj) { 3368 } 3369 3370 /** 3371 * Unregister for notifications for subscription info 3372 * @param h Handler to be removed from the registrant list. 3373 */ unregisterForSubscriptionInfoReady(Handler h)3374 public void unregisterForSubscriptionInfoReady(Handler h) { 3375 } 3376 3377 /** 3378 * Returns true if OTA Service Provisioning needs to be performed. 3379 */ 3380 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) needsOtaServiceProvisioning()3381 public boolean needsOtaServiceProvisioning() { 3382 return false; 3383 } 3384 3385 /** 3386 * this decides if the dial number is OTA(Over the air provision) number or not 3387 * @param dialStr is string representing the dialing digit(s) 3388 * @return true means the dialStr is OTA number, and false means the dialStr is not OTA number 3389 */ isOtaSpNumber(String dialStr)3390 public boolean isOtaSpNumber(String dialStr) { 3391 return false; 3392 } 3393 3394 /** 3395 * Register for notifications when OTA Service Provisioning mode has changed. 3396 * 3397 * <p>The mode is integer. {@link TelephonyManager#OTASP_UNKNOWN} 3398 * means the value is currently unknown and the system should wait until 3399 * {@link TelephonyManager#OTASP_NEEDED} or {@link TelephonyManager#OTASP_NOT_NEEDED} is 3400 * received before making the decision to perform OTASP or not. 3401 * 3402 * @param h Handler that receives the notification message. 3403 * @param what User-defined message code. 3404 * @param obj User object. 3405 */ registerForOtaspChange(Handler h, int what, Object obj)3406 public void registerForOtaspChange(Handler h, int what, Object obj) { 3407 checkCorrectThread(h); 3408 mOtaspRegistrants.addUnique(h, what, obj); 3409 // notify first 3410 new Registrant(h, what, obj).notifyRegistrant(new AsyncResult(null, getOtasp(), null)); 3411 } 3412 3413 /** 3414 * Unegister for notifications when OTA Service Provisioning mode has changed. 3415 * @param h Handler to be removed from the registrant list. 3416 */ unregisterForOtaspChange(Handler h)3417 public void unregisterForOtaspChange(Handler h) { 3418 mOtaspRegistrants.remove(h); 3419 } 3420 3421 /** 3422 * Returns the current OTA Service Provisioning mode. 3423 * 3424 * @see registerForOtaspChange 3425 */ getOtasp()3426 public int getOtasp() { 3427 return TelephonyManager.OTASP_UNKNOWN; 3428 } 3429 3430 /** 3431 * Register for notifications when CDMA call waiting comes 3432 * 3433 * @param h Handler that receives the notification message. 3434 * @param what User-defined message code. 3435 * @param obj User object. 3436 */ registerForCallWaiting(Handler h, int what, Object obj)3437 public void registerForCallWaiting(Handler h, int what, Object obj){ 3438 } 3439 3440 /** 3441 * Unegister for notifications when CDMA Call waiting comes 3442 * @param h Handler to be removed from the registrant list. 3443 */ unregisterForCallWaiting(Handler h)3444 public void unregisterForCallWaiting(Handler h){ 3445 } 3446 3447 /** 3448 * Registration point for Ecm timer reset 3449 * @param h handler to notify 3450 * @param what user-defined message code 3451 * @param obj placed in Message.obj 3452 */ 3453 @UnsupportedAppUsage registerForEcmTimerReset(Handler h, int what, Object obj)3454 public void registerForEcmTimerReset(Handler h, int what, Object obj) { 3455 } 3456 3457 /** 3458 * Unregister for notification for Ecm timer reset 3459 * @param h Handler to be removed from the registrant list. 3460 */ 3461 @UnsupportedAppUsage unregisterForEcmTimerReset(Handler h)3462 public void unregisterForEcmTimerReset(Handler h) { 3463 } 3464 3465 /** 3466 * Register for signal information notifications from the network. 3467 * Message.obj will contain an AsyncResult. 3468 * AsyncResult.result will be a SuppServiceNotification instance. 3469 * 3470 * @param h Handler that receives the notification message. 3471 * @param what User-defined message code. 3472 * @param obj User object. 3473 */ registerForSignalInfo(Handler h, int what, Object obj)3474 public void registerForSignalInfo(Handler h, int what, Object obj) { 3475 mCi.registerForSignalInfo(h, what, obj); 3476 } 3477 3478 /** 3479 * Unregisters for signal information notifications. 3480 * Extraneous calls are tolerated silently 3481 * 3482 * @param h Handler to be removed from the registrant list. 3483 */ unregisterForSignalInfo(Handler h)3484 public void unregisterForSignalInfo(Handler h) { 3485 mCi.unregisterForSignalInfo(h); 3486 } 3487 3488 /** 3489 * Register for display information notifications from the network. 3490 * Message.obj will contain an AsyncResult. 3491 * AsyncResult.result will be a SuppServiceNotification instance. 3492 * 3493 * @param h Handler that receives the notification message. 3494 * @param what User-defined message code. 3495 * @param obj User object. 3496 */ registerForDisplayInfo(Handler h, int what, Object obj)3497 public void registerForDisplayInfo(Handler h, int what, Object obj) { 3498 mCi.registerForDisplayInfo(h, what, obj); 3499 } 3500 3501 /** 3502 * Unregisters for display information notifications. 3503 * Extraneous calls are tolerated silently 3504 * 3505 * @param h Handler to be removed from the registrant list. 3506 */ unregisterForDisplayInfo(Handler h)3507 public void unregisterForDisplayInfo(Handler h) { 3508 mCi.unregisterForDisplayInfo(h); 3509 } 3510 3511 /** 3512 * Register for CDMA number information record notification from the network. 3513 * Message.obj will contain an AsyncResult. 3514 * AsyncResult.result will be a CdmaInformationRecords.CdmaNumberInfoRec 3515 * instance. 3516 * 3517 * @param h Handler that receives the notification message. 3518 * @param what User-defined message code. 3519 * @param obj User object. 3520 */ registerForNumberInfo(Handler h, int what, Object obj)3521 public void registerForNumberInfo(Handler h, int what, Object obj) { 3522 mCi.registerForNumberInfo(h, what, obj); 3523 } 3524 3525 /** 3526 * Unregisters for number information record notifications. 3527 * Extraneous calls are tolerated silently 3528 * 3529 * @param h Handler to be removed from the registrant list. 3530 */ unregisterForNumberInfo(Handler h)3531 public void unregisterForNumberInfo(Handler h) { 3532 mCi.unregisterForNumberInfo(h); 3533 } 3534 3535 /** 3536 * Register for CDMA redirected number information record notification 3537 * from the network. 3538 * Message.obj will contain an AsyncResult. 3539 * AsyncResult.result will be a CdmaInformationRecords.CdmaRedirectingNumberInfoRec 3540 * instance. 3541 * 3542 * @param h Handler that receives the notification message. 3543 * @param what User-defined message code. 3544 * @param obj User object. 3545 */ registerForRedirectedNumberInfo(Handler h, int what, Object obj)3546 public void registerForRedirectedNumberInfo(Handler h, int what, Object obj) { 3547 mCi.registerForRedirectedNumberInfo(h, what, obj); 3548 } 3549 3550 /** 3551 * Unregisters for redirected number information record notification. 3552 * Extraneous calls are tolerated silently 3553 * 3554 * @param h Handler to be removed from the registrant list. 3555 */ unregisterForRedirectedNumberInfo(Handler h)3556 public void unregisterForRedirectedNumberInfo(Handler h) { 3557 mCi.unregisterForRedirectedNumberInfo(h); 3558 } 3559 3560 /** 3561 * Register for CDMA line control information record notification 3562 * from the network. 3563 * Message.obj will contain an AsyncResult. 3564 * AsyncResult.result will be a CdmaInformationRecords.CdmaLineControlInfoRec 3565 * instance. 3566 * 3567 * @param h Handler that receives the notification message. 3568 * @param what User-defined message code. 3569 * @param obj User object. 3570 */ registerForLineControlInfo(Handler h, int what, Object obj)3571 public void registerForLineControlInfo(Handler h, int what, Object obj) { 3572 mCi.registerForLineControlInfo(h, what, obj); 3573 } 3574 3575 /** 3576 * Unregisters for line control information notifications. 3577 * Extraneous calls are tolerated silently 3578 * 3579 * @param h Handler to be removed from the registrant list. 3580 */ unregisterForLineControlInfo(Handler h)3581 public void unregisterForLineControlInfo(Handler h) { 3582 mCi.unregisterForLineControlInfo(h); 3583 } 3584 3585 /** 3586 * Register for CDMA T53 CLIR information record notifications 3587 * from the network. 3588 * Message.obj will contain an AsyncResult. 3589 * AsyncResult.result will be a CdmaInformationRecords.CdmaT53ClirInfoRec 3590 * instance. 3591 * 3592 * @param h Handler that receives the notification message. 3593 * @param what User-defined message code. 3594 * @param obj User object. 3595 */ registerFoT53ClirlInfo(Handler h, int what, Object obj)3596 public void registerFoT53ClirlInfo(Handler h, int what, Object obj) { 3597 mCi.registerFoT53ClirlInfo(h, what, obj); 3598 } 3599 3600 /** 3601 * Unregisters for T53 CLIR information record notification 3602 * Extraneous calls are tolerated silently 3603 * 3604 * @param h Handler to be removed from the registrant list. 3605 */ unregisterForT53ClirInfo(Handler h)3606 public void unregisterForT53ClirInfo(Handler h) { 3607 mCi.unregisterForT53ClirInfo(h); 3608 } 3609 3610 /** 3611 * Register for CDMA T53 audio control information record notifications 3612 * from the network. 3613 * Message.obj will contain an AsyncResult. 3614 * AsyncResult.result will be a CdmaInformationRecords.CdmaT53AudioControlInfoRec 3615 * instance. 3616 * 3617 * @param h Handler that receives the notification message. 3618 * @param what User-defined message code. 3619 * @param obj User object. 3620 */ registerForT53AudioControlInfo(Handler h, int what, Object obj)3621 public void registerForT53AudioControlInfo(Handler h, int what, Object obj) { 3622 mCi.registerForT53AudioControlInfo(h, what, obj); 3623 } 3624 3625 /** 3626 * Unregisters for T53 audio control information record notifications. 3627 * Extraneous calls are tolerated silently 3628 * 3629 * @param h Handler to be removed from the registrant list. 3630 */ unregisterForT53AudioControlInfo(Handler h)3631 public void unregisterForT53AudioControlInfo(Handler h) { 3632 mCi.unregisterForT53AudioControlInfo(h); 3633 } 3634 3635 /** 3636 * registers for exit emergency call back mode request response 3637 * 3638 * @param h Handler that receives the notification message. 3639 * @param what User-defined message code. 3640 * @param obj User object. 3641 */ 3642 @UnsupportedAppUsage setOnEcbModeExitResponse(Handler h, int what, Object obj)3643 public void setOnEcbModeExitResponse(Handler h, int what, Object obj){ 3644 } 3645 3646 /** 3647 * Unregisters for exit emergency call back mode request response 3648 * 3649 * @param h Handler to be removed from the registrant list. 3650 */ 3651 @UnsupportedAppUsage unsetOnEcbModeExitResponse(Handler h)3652 public void unsetOnEcbModeExitResponse(Handler h){ 3653 } 3654 3655 /** 3656 * Register for radio off or not available 3657 * 3658 * @param h Handler that receives the notification message. 3659 * @param what User-defined message code. 3660 * @param obj User object. 3661 */ registerForRadioOffOrNotAvailable(Handler h, int what, Object obj)3662 public void registerForRadioOffOrNotAvailable(Handler h, int what, Object obj) { 3663 mRadioOffOrNotAvailableRegistrants.addUnique(h, what, obj); 3664 } 3665 3666 /** 3667 * Unregisters for radio off or not available 3668 * 3669 * @param h Handler to be removed from the registrant list. 3670 */ unregisterForRadioOffOrNotAvailable(Handler h)3671 public void unregisterForRadioOffOrNotAvailable(Handler h) { 3672 mRadioOffOrNotAvailableRegistrants.remove(h); 3673 } 3674 3675 /** 3676 * Location to an updatable file listing carrier provisioning urls. 3677 * An example: 3678 * 3679 * <?xml version="1.0" encoding="utf-8"?> 3680 * <provisioningUrls> 3681 * <provisioningUrl mcc="310" mnc="4">http://myserver.com/foo?mdn=%3$s&iccid=%1$s&imei=%2$s</provisioningUrl> 3682 * </provisioningUrls> 3683 */ 3684 private static final String PROVISIONING_URL_PATH = 3685 "/data/misc/radio/provisioning_urls.xml"; 3686 private final File mProvisioningUrlFile = new File(PROVISIONING_URL_PATH); 3687 3688 /** XML tag for root element. */ 3689 private static final String TAG_PROVISIONING_URLS = "provisioningUrls"; 3690 /** XML tag for individual url */ 3691 private static final String TAG_PROVISIONING_URL = "provisioningUrl"; 3692 /** XML attribute for mcc */ 3693 private static final String ATTR_MCC = "mcc"; 3694 /** XML attribute for mnc */ 3695 private static final String ATTR_MNC = "mnc"; 3696 getProvisioningUrlBaseFromFile()3697 private String getProvisioningUrlBaseFromFile() { 3698 XmlPullParser parser; 3699 final Configuration config = mContext.getResources().getConfiguration(); 3700 3701 try (FileReader fileReader = new FileReader(mProvisioningUrlFile)) { 3702 parser = Xml.newPullParser(); 3703 parser.setInput(fileReader); 3704 XmlUtils.beginDocument(parser, TAG_PROVISIONING_URLS); 3705 3706 while (true) { 3707 XmlUtils.nextElement(parser); 3708 3709 final String element = parser.getName(); 3710 if (element == null) break; 3711 3712 if (element.equals(TAG_PROVISIONING_URL)) { 3713 String mcc = parser.getAttributeValue(null, ATTR_MCC); 3714 try { 3715 if (mcc != null && Integer.parseInt(mcc) == config.mcc) { 3716 String mnc = parser.getAttributeValue(null, ATTR_MNC); 3717 if (mnc != null && Integer.parseInt(mnc) == config.mnc) { 3718 parser.next(); 3719 if (parser.getEventType() == XmlPullParser.TEXT) { 3720 return parser.getText(); 3721 } 3722 } 3723 } 3724 } catch (NumberFormatException e) { 3725 Rlog.e(LOG_TAG, "Exception in getProvisioningUrlBaseFromFile: " + e); 3726 } 3727 } 3728 } 3729 return null; 3730 } catch (FileNotFoundException e) { 3731 Rlog.e(LOG_TAG, "Carrier Provisioning Urls file not found"); 3732 } catch (XmlPullParserException e) { 3733 Rlog.e(LOG_TAG, "Xml parser exception reading Carrier Provisioning Urls file: " + e); 3734 } catch (IOException e) { 3735 Rlog.e(LOG_TAG, "I/O exception reading Carrier Provisioning Urls file: " + e); 3736 } 3737 return null; 3738 } 3739 3740 /** 3741 * Get the mobile provisioning url. 3742 */ getMobileProvisioningUrl()3743 public String getMobileProvisioningUrl() { 3744 String url = getProvisioningUrlBaseFromFile(); 3745 if (TextUtils.isEmpty(url)) { 3746 url = mContext.getResources().getString(R.string.mobile_provisioning_url); 3747 Rlog.d(LOG_TAG, "getMobileProvisioningUrl: url from resource =" + url); 3748 } else { 3749 Rlog.d(LOG_TAG, "getMobileProvisioningUrl: url from File =" + url); 3750 } 3751 // Populate the iccid, imei and phone number in the provisioning url. 3752 if (!TextUtils.isEmpty(url)) { 3753 String phoneNumber = getLine1Number(); 3754 if (TextUtils.isEmpty(phoneNumber)) { 3755 phoneNumber = "0000000000"; 3756 } 3757 url = String.format(url, 3758 getIccSerialNumber() /* ICCID */, 3759 getDeviceId() /* IMEI */, 3760 phoneNumber /* Phone number */); 3761 } 3762 3763 return url; 3764 } 3765 3766 /** 3767 * Check if there are matching tethering (i.e DUN) for the carrier. 3768 * @return true if there is a matching DUN APN. 3769 */ hasMatchedTetherApnSetting()3770 public boolean hasMatchedTetherApnSetting() { 3771 NetworkRegistrationInfo nrs = getServiceState().getNetworkRegistrationInfo( 3772 NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN); 3773 if (nrs != null) { 3774 return getDataNetworkController().getDataProfileManager() 3775 .isTetheringDataProfileExisting(nrs.getAccessNetworkTechnology()); 3776 } 3777 return false; 3778 } 3779 3780 /** 3781 * Report on whether data connectivity is allowed for internet. 3782 * 3783 * @return {@code true} if internet data is allowed to be established. 3784 */ isDataAllowed()3785 public boolean isDataAllowed() { 3786 return getDataNetworkController().isInternetDataAllowed(); 3787 } 3788 3789 /** 3790 * Action set from carrier signalling broadcast receivers to enable/disable metered apns. 3791 */ carrierActionSetMeteredApnsEnabled(boolean enabled)3792 public void carrierActionSetMeteredApnsEnabled(boolean enabled) { 3793 mCarrierActionAgent.carrierActionSetMeteredApnsEnabled(enabled); 3794 } 3795 3796 /** 3797 * Action set from carrier signalling broadcast receivers to enable/disable radio 3798 */ carrierActionSetRadioEnabled(boolean enabled)3799 public void carrierActionSetRadioEnabled(boolean enabled) { 3800 mCarrierActionAgent.carrierActionSetRadioEnabled(enabled); 3801 } 3802 3803 /** 3804 * Action set from carrier app to start/stop reporting default network condition. 3805 */ carrierActionReportDefaultNetworkStatus(boolean report)3806 public void carrierActionReportDefaultNetworkStatus(boolean report) { 3807 mCarrierActionAgent.carrierActionReportDefaultNetworkStatus(report); 3808 } 3809 3810 /** 3811 * Action set from carrier signalling broadcast receivers to reset all carrier actions 3812 */ carrierActionResetAll()3813 public void carrierActionResetAll() { 3814 mCarrierActionAgent.carrierActionReset(); 3815 } 3816 3817 /** 3818 * Notify registrants of a new ringing Connection. 3819 * Subclasses of Phone probably want to replace this with a 3820 * version scoped to their packages 3821 */ notifyNewRingingConnectionP(Connection cn)3822 public void notifyNewRingingConnectionP(Connection cn) { 3823 Rlog.i(LOG_TAG, String.format( 3824 "notifyNewRingingConnection: phoneId=[%d], connection=[%s], registrants=[%s]", 3825 getPhoneId(), cn, getNewRingingConnectionRegistrantsAsString())); 3826 if (!mIsVoiceCapable) 3827 return; 3828 AsyncResult ar = new AsyncResult(null, cn, null); 3829 mNewRingingConnectionRegistrants.notifyRegistrants(ar); 3830 } 3831 3832 /** 3833 * helper for notifyNewRingingConnectionP(Connection) to create a string for a log message. 3834 * 3835 * @return a list of objects in mNewRingingConnectionRegistrants as a String 3836 */ getNewRingingConnectionRegistrantsAsString()3837 private String getNewRingingConnectionRegistrantsAsString() { 3838 List<String> registrants = new ArrayList<>(); 3839 for (int i = 0; i < mNewRingingConnectionRegistrants.size(); i++) { 3840 registrants.add(mNewRingingConnectionRegistrants.get(i).toString()); 3841 } 3842 return String.join(", ", registrants); 3843 } 3844 3845 /** 3846 * Notify registrants of a new unknown connection. 3847 */ notifyUnknownConnectionP(Connection cn)3848 public void notifyUnknownConnectionP(Connection cn) { 3849 mUnknownConnectionRegistrants.notifyResult(cn); 3850 } 3851 3852 /** 3853 * Notify registrants if phone is video capable. 3854 */ notifyForVideoCapabilityChanged(boolean isVideoCallCapable)3855 public void notifyForVideoCapabilityChanged(boolean isVideoCallCapable) { 3856 // Cache the current video capability so that we don't lose the information. 3857 mIsVideoCapable = isVideoCallCapable; 3858 3859 AsyncResult ar = new AsyncResult(null, isVideoCallCapable, null); 3860 mVideoCapabilityChangedRegistrants.notifyRegistrants(ar); 3861 } 3862 3863 /** 3864 * Notify registrants of a RING event. 3865 */ notifyIncomingRing()3866 private void notifyIncomingRing() { 3867 if (!mIsVoiceCapable) 3868 return; 3869 AsyncResult ar = new AsyncResult(null, this, null); 3870 mIncomingRingRegistrants.notifyRegistrants(ar); 3871 } 3872 3873 /** 3874 * Send the incoming call Ring notification if conditions are right. 3875 */ sendIncomingCallRingNotification(int token)3876 private void sendIncomingCallRingNotification(int token) { 3877 if (mIsVoiceCapable && !mDoesRilSendMultipleCallRing && 3878 (token == mCallRingContinueToken)) { 3879 Rlog.d(LOG_TAG, "Sending notifyIncomingRing"); 3880 notifyIncomingRing(); 3881 sendMessageDelayed( 3882 obtainMessage(EVENT_CALL_RING_CONTINUE, token, 0), mCallRingDelay); 3883 } else { 3884 Rlog.d(LOG_TAG, "Ignoring ring notification request," 3885 + " mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing 3886 + " token=" + token 3887 + " mCallRingContinueToken=" + mCallRingContinueToken 3888 + " mIsVoiceCapable=" + mIsVoiceCapable); 3889 } 3890 } 3891 3892 /** 3893 * Enable or disable always reporting signal strength changes from radio. 3894 * 3895 * @param isEnable {@code true} for enabling; {@code false} for disabling. 3896 */ setAlwaysReportSignalStrength(boolean isEnable)3897 public void setAlwaysReportSignalStrength(boolean isEnable) { 3898 if (mDeviceStateMonitor != null) { 3899 mDeviceStateMonitor.setAlwaysReportSignalStrength(isEnable); 3900 } 3901 } 3902 3903 /** 3904 * TODO: Adding a function for each property is not good. 3905 * A fucntion of type getPhoneProp(propType) where propType is an 3906 * enum of GSM+CDMA+LTE props would be a better approach. 3907 * 3908 * Get "Restriction of menu options for manual PLMN selection" bit 3909 * status from EF_CSP data, this belongs to "Value Added Services Group". 3910 * @return true if this bit is set or EF_CSP data is unavailable, 3911 * false otherwise 3912 */ 3913 @UnsupportedAppUsage isCspPlmnEnabled()3914 public boolean isCspPlmnEnabled() { 3915 return false; 3916 } 3917 3918 /** 3919 * Return an interface to retrieve the ISIM records for IMS, if available. 3920 * @return the interface to retrieve the ISIM records, or null if not supported 3921 */ 3922 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getIsimRecords()3923 public IsimRecords getIsimRecords() { 3924 Rlog.e(LOG_TAG, "getIsimRecords() is only supported on LTE devices"); 3925 return null; 3926 } 3927 3928 /** 3929 * Retrieves the MSISDN from the UICC. For GSM/UMTS phones, this is equivalent to 3930 * {@link #getLine1Number()}. For CDMA phones, {@link #getLine1Number()} returns 3931 * the MDN, so this method is provided to return the MSISDN on CDMA/LTE phones. 3932 */ 3933 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getMsisdn()3934 public String getMsisdn() { 3935 return null; 3936 } 3937 3938 /** 3939 * Retrieves the EF_PNN from the UICC For GSM/UMTS phones. 3940 */ getPlmn()3941 public String getPlmn() { 3942 return null; 3943 } 3944 notifyCallForwardingIndicator()3945 public void notifyCallForwardingIndicator() { 3946 } 3947 3948 /** 3949 * Sets the SIM voice message waiting indicator records. 3950 * @param line GSM Subscriber Profile Number, one-based. Only '1' is supported 3951 * @param countWaiting The number of messages waiting, if known. Use 3952 * -1 to indicate that an unknown number of 3953 * messages are waiting 3954 */ setVoiceMessageWaiting(int line, int countWaiting)3955 public void setVoiceMessageWaiting(int line, int countWaiting) { 3956 // This function should be overridden by class GsmCdmaPhone. 3957 Rlog.e(LOG_TAG, "Error! This function should never be executed, inactive Phone."); 3958 } 3959 3960 /** 3961 * Gets the USIM service table from the UICC, if present and available. 3962 * @return an interface to the UsimServiceTable record, or null if not available 3963 */ getUsimServiceTable()3964 public UsimServiceTable getUsimServiceTable() { 3965 IccRecords r = mIccRecords.get(); 3966 return (r != null) ? r.getUsimServiceTable() : null; 3967 } 3968 3969 /** 3970 * Gets the Uicc card corresponding to this phone. 3971 * @return the UiccCard object corresponding to the phone ID. 3972 */ 3973 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getUiccCard()3974 public UiccCard getUiccCard() { 3975 return mUiccController.getUiccCard(mPhoneId); 3976 } 3977 3978 /** 3979 * Gets the Uicc port corresponding to this phone. 3980 * @return the UiccPort object corresponding to the phone ID. 3981 */ getUiccPort()3982 public UiccPort getUiccPort() { 3983 return mUiccController.getUiccPort(mPhoneId); 3984 } 3985 3986 /** 3987 * Set IMS registration state 3988 */ setImsRegistrationState(boolean registered)3989 public void setImsRegistrationState(boolean registered) { 3990 } 3991 3992 /** 3993 * Return an instance of a IMS phone 3994 */ 3995 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getImsPhone()3996 public Phone getImsPhone() { 3997 return mImsPhone; 3998 } 3999 4000 @VisibleForTesting setImsPhone(ImsPhone imsPhone)4001 public void setImsPhone(ImsPhone imsPhone) { 4002 mImsPhone = imsPhone; 4003 } 4004 4005 /** 4006 * Returns Carrier specific information that will be used to encrypt the IMSI and IMPI. 4007 * @param keyType whether the key is being used for WLAN or ePDG. 4008 * @param fallback whether or not to fall back to the encryption key info stored in carrier 4009 * config 4010 * @return ImsiEncryptionInfo which includes the Key Type, the Public Key 4011 * {@link java.security.PublicKey} and the Key Identifier. 4012 * The keyIdentifier This is used by the server to help it locate the private key to 4013 * decrypt the permanent identity. 4014 */ getCarrierInfoForImsiEncryption(int keyType, boolean fallback)4015 public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType, boolean fallback) { 4016 return null; 4017 } 4018 4019 /** 4020 * Sets the carrier information needed to encrypt the IMSI and IMPI. 4021 * @param imsiEncryptionInfo Carrier specific information that will be used to encrypt the 4022 * IMSI and IMPI. This includes the Key type, the Public key 4023 * {@link java.security.PublicKey} and the Key identifier. 4024 */ setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo)4025 public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo) { 4026 return; 4027 } 4028 4029 /** 4030 * Deletes all the keys for a given Carrier from the device keystore. 4031 * @param carrierId : the carrier ID which needs to be matched in the delete query 4032 */ deleteCarrierInfoForImsiEncryption(int carrierId)4033 public void deleteCarrierInfoForImsiEncryption(int carrierId) { 4034 return; 4035 } 4036 getCarrierId()4037 public int getCarrierId() { 4038 return TelephonyManager.UNKNOWN_CARRIER_ID; 4039 } 4040 getCarrierName()4041 public String getCarrierName() { 4042 return null; 4043 } 4044 getMNOCarrierId()4045 public int getMNOCarrierId() { 4046 return TelephonyManager.UNKNOWN_CARRIER_ID; 4047 } 4048 getSpecificCarrierId()4049 public int getSpecificCarrierId() { 4050 return TelephonyManager.UNKNOWN_CARRIER_ID; 4051 } 4052 getSpecificCarrierName()4053 public String getSpecificCarrierName() { 4054 return null; 4055 } 4056 getCarrierIdListVersion()4057 public int getCarrierIdListVersion() { 4058 return TelephonyManager.UNKNOWN_CARRIER_ID_LIST_VERSION; 4059 } 4060 getEmergencyNumberDbVersion()4061 public int getEmergencyNumberDbVersion() { 4062 return TelephonyManager.INVALID_EMERGENCY_NUMBER_DB_VERSION; 4063 } 4064 resolveSubscriptionCarrierId(String simState)4065 public void resolveSubscriptionCarrierId(String simState) { 4066 } 4067 4068 /** 4069 * Resets the Carrier Keys in the database. This involves 2 steps: 4070 * 1. Delete the keys from the database. 4071 * 2. Send an intent to download new Certificates. 4072 */ resetCarrierKeysForImsiEncryption()4073 public void resetCarrierKeysForImsiEncryption() { 4074 return; 4075 } 4076 4077 /** 4078 * Return if UT capability of ImsPhone is enabled or not 4079 */ 4080 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) isUtEnabled()4081 public boolean isUtEnabled() { 4082 if (mImsPhone != null) { 4083 return mImsPhone.isUtEnabled(); 4084 } 4085 return false; 4086 } 4087 4088 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) dispose()4089 public void dispose() { 4090 } 4091 4092 /** 4093 * Dials a number. 4094 * 4095 * @param dialString The number to dial. 4096 * @param dialArgs Parameters to dial with. 4097 * @return The Connection. 4098 * @throws CallStateException 4099 */ dialInternal(String dialString, DialArgs dialArgs)4100 protected Connection dialInternal(String dialString, DialArgs dialArgs) 4101 throws CallStateException { 4102 // dialInternal shall be overriden by GsmCdmaPhone 4103 return null; 4104 } 4105 4106 /* 4107 * This function is for CSFB SS. GsmCdmaPhone overrides this function. 4108 */ setCallWaiting(boolean enable, int serviceClass, Message onComplete)4109 public void setCallWaiting(boolean enable, int serviceClass, Message onComplete) { 4110 } 4111 queryCLIP(Message onComplete)4112 public void queryCLIP(Message onComplete) { 4113 } 4114 4115 /* 4116 * Returns the subscription id. 4117 */ 4118 @UnsupportedAppUsage getSubId()4119 public int getSubId() { 4120 return mSubscriptionManagerService.getSubId(mPhoneId); 4121 } 4122 4123 /** 4124 * Returns the phone id. 4125 */ 4126 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) getPhoneId()4127 public int getPhoneId() { 4128 return mPhoneId; 4129 } 4130 4131 /** 4132 * Override the service provider name and the operator name for the current ICCID. 4133 */ setOperatorBrandOverride(String brand)4134 public boolean setOperatorBrandOverride(String brand) { 4135 return false; 4136 } 4137 4138 /** 4139 * Override the roaming indicator for the current ICCID. 4140 */ setRoamingOverride(List<String> gsmRoamingList, List<String> gsmNonRoamingList, List<String> cdmaRoamingList, List<String> cdmaNonRoamingList)4141 public boolean setRoamingOverride(List<String> gsmRoamingList, 4142 List<String> gsmNonRoamingList, List<String> cdmaRoamingList, 4143 List<String> cdmaNonRoamingList) { 4144 String iccId = getIccSerialNumber(); 4145 if (TextUtils.isEmpty(iccId)) { 4146 return false; 4147 } 4148 4149 setRoamingOverrideHelper(gsmRoamingList, GSM_ROAMING_LIST_OVERRIDE_PREFIX, iccId); 4150 setRoamingOverrideHelper(gsmNonRoamingList, GSM_NON_ROAMING_LIST_OVERRIDE_PREFIX, iccId); 4151 setRoamingOverrideHelper(cdmaRoamingList, CDMA_ROAMING_LIST_OVERRIDE_PREFIX, iccId); 4152 setRoamingOverrideHelper(cdmaNonRoamingList, CDMA_NON_ROAMING_LIST_OVERRIDE_PREFIX, iccId); 4153 4154 // Refresh. 4155 ServiceStateTracker tracker = getServiceStateTracker(); 4156 if (tracker != null) { 4157 tracker.pollState(); 4158 } 4159 return true; 4160 } 4161 setRoamingOverrideHelper(List<String> list, String prefix, String iccId)4162 private void setRoamingOverrideHelper(List<String> list, String prefix, String iccId) { 4163 SharedPreferences.Editor spEditor = 4164 PreferenceManager.getDefaultSharedPreferences(mContext).edit(); 4165 String key = prefix + iccId; 4166 if (list == null || list.isEmpty()) { 4167 spEditor.remove(key).commit(); 4168 } else { 4169 spEditor.putStringSet(key, new HashSet<String>(list)).commit(); 4170 } 4171 } 4172 isMccMncMarkedAsRoaming(String mccMnc)4173 public boolean isMccMncMarkedAsRoaming(String mccMnc) { 4174 return getRoamingOverrideHelper(GSM_ROAMING_LIST_OVERRIDE_PREFIX, mccMnc); 4175 } 4176 isMccMncMarkedAsNonRoaming(String mccMnc)4177 public boolean isMccMncMarkedAsNonRoaming(String mccMnc) { 4178 return getRoamingOverrideHelper(GSM_NON_ROAMING_LIST_OVERRIDE_PREFIX, mccMnc); 4179 } 4180 isSidMarkedAsRoaming(int SID)4181 public boolean isSidMarkedAsRoaming(int SID) { 4182 return getRoamingOverrideHelper(CDMA_ROAMING_LIST_OVERRIDE_PREFIX, 4183 Integer.toString(SID)); 4184 } 4185 isSidMarkedAsNonRoaming(int SID)4186 public boolean isSidMarkedAsNonRoaming(int SID) { 4187 return getRoamingOverrideHelper(CDMA_NON_ROAMING_LIST_OVERRIDE_PREFIX, 4188 Integer.toString(SID)); 4189 } 4190 4191 /** 4192 * Query the IMS Registration Status. 4193 * 4194 * @return true if IMS is Registered 4195 */ isImsRegistered()4196 public boolean isImsRegistered() { 4197 Phone imsPhone = mImsPhone; 4198 boolean isImsRegistered = false; 4199 if (imsPhone != null) { 4200 isImsRegistered = imsPhone.isImsRegistered(); 4201 } else { 4202 ServiceStateTracker sst = getServiceStateTracker(); 4203 if (sst != null) { 4204 isImsRegistered = sst.isImsRegistered(); 4205 } 4206 } 4207 Rlog.d(LOG_TAG, "isImsRegistered =" + isImsRegistered); 4208 return isImsRegistered; 4209 } 4210 4211 /** 4212 * Get Wifi Calling Feature Availability 4213 */ 4214 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) isWifiCallingEnabled()4215 public boolean isWifiCallingEnabled() { 4216 Phone imsPhone = mImsPhone; 4217 boolean isWifiCallingEnabled = false; 4218 if (imsPhone != null) { 4219 isWifiCallingEnabled = imsPhone.isWifiCallingEnabled(); 4220 } 4221 Rlog.d(LOG_TAG, "isWifiCallingEnabled =" + isWifiCallingEnabled); 4222 return isWifiCallingEnabled; 4223 } 4224 4225 /** 4226 * @return true if the IMS capability for the registration technology specified is available, 4227 * false otherwise. 4228 */ isImsCapabilityAvailable(int capability, int regTech)4229 public boolean isImsCapabilityAvailable(int capability, int regTech) throws ImsException { 4230 Phone imsPhone = mImsPhone; 4231 boolean isAvailable = false; 4232 if (imsPhone != null) { 4233 isAvailable = imsPhone.isImsCapabilityAvailable(capability, regTech); 4234 } 4235 Rlog.d(LOG_TAG, "isImsCapabilityAvailable, capability=" + capability + ", regTech=" 4236 + regTech + ", isAvailable=" + isAvailable); 4237 return isAvailable; 4238 } 4239 4240 /** 4241 * Get Volte Feature Availability 4242 * @deprecated Use {@link #isVoiceOverCellularImsEnabled} instead. 4243 */ 4244 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 4245 @Deprecated isVolteEnabled()4246 public boolean isVolteEnabled() { 4247 return isVoiceOverCellularImsEnabled(); 4248 } 4249 4250 /** 4251 * @return {@code true} if voice over IMS on cellular is enabled, {@code false} otherwise. 4252 */ isVoiceOverCellularImsEnabled()4253 public boolean isVoiceOverCellularImsEnabled() { 4254 Phone imsPhone = mImsPhone; 4255 boolean isVolteEnabled = false; 4256 if (imsPhone != null) { 4257 isVolteEnabled = imsPhone.isVoiceOverCellularImsEnabled(); 4258 } 4259 Rlog.d(LOG_TAG, "isVoiceOverCellularImsEnabled=" + isVolteEnabled); 4260 return isVolteEnabled; 4261 } 4262 4263 /** 4264 * @return the IMS MmTel Registration technology for this Phone, defined in 4265 * {@link ImsRegistrationImplBase}. 4266 */ getImsRegistrationTech()4267 public int getImsRegistrationTech() { 4268 Phone imsPhone = mImsPhone; 4269 int regTech = ImsRegistrationImplBase.REGISTRATION_TECH_NONE; 4270 if (imsPhone != null) { 4271 regTech = imsPhone.getImsRegistrationTech(); 4272 } 4273 Rlog.d(LOG_TAG, "getImsRegistrationTechnology =" + regTech); 4274 return regTech; 4275 } 4276 4277 /** 4278 * Get the IMS MmTel Registration technology for this Phone, defined in 4279 * {@link ImsRegistrationImplBase}. 4280 */ getImsRegistrationTech(Consumer<Integer> callback)4281 public void getImsRegistrationTech(Consumer<Integer> callback) { 4282 Phone imsPhone = mImsPhone; 4283 if (imsPhone != null) { 4284 imsPhone.getImsRegistrationTech(callback); 4285 } else { 4286 callback.accept(ImsRegistrationImplBase.REGISTRATION_TECH_NONE); 4287 } 4288 } 4289 4290 /** 4291 * Asynchronously get the IMS MmTel Registration state for this Phone. 4292 */ getImsRegistrationState(Consumer<Integer> callback)4293 public void getImsRegistrationState(Consumer<Integer> callback) { 4294 Phone imsPhone = mImsPhone; 4295 if (imsPhone != null) { 4296 imsPhone.getImsRegistrationState(callback); 4297 } else { 4298 callback.accept(RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED); 4299 } 4300 } 4301 4302 getRoamingOverrideHelper(String prefix, String key)4303 private boolean getRoamingOverrideHelper(String prefix, String key) { 4304 String iccId = getIccSerialNumber(); 4305 if (TextUtils.isEmpty(iccId) || TextUtils.isEmpty(key)) { 4306 return false; 4307 } 4308 4309 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 4310 Set<String> value = sp.getStringSet(prefix + iccId, null); 4311 if (value == null) { 4312 return false; 4313 } 4314 return value.contains(key); 4315 } 4316 4317 /** 4318 * @return returns the latest radio state from the modem 4319 */ getRadioPowerState()4320 public int getRadioPowerState() { 4321 return mCi.getRadioState(); 4322 } 4323 4324 /** 4325 * Is Radio Present on the device and is it accessible 4326 */ isRadioAvailable()4327 public boolean isRadioAvailable() { 4328 return mCi.getRadioState() != TelephonyManager.RADIO_POWER_UNAVAILABLE; 4329 } 4330 4331 /** 4332 * Is Radio turned on 4333 */ isRadioOn()4334 public boolean isRadioOn() { 4335 return mCi.getRadioState() == TelephonyManager.RADIO_POWER_ON; 4336 } 4337 4338 /** 4339 * shutdown Radio gracefully 4340 */ shutdownRadio()4341 public void shutdownRadio() { 4342 getServiceStateTracker().requestShutdown(); 4343 } 4344 4345 /** 4346 * Return true if the device is shutting down. 4347 */ isShuttingDown()4348 public boolean isShuttingDown() { 4349 return getServiceStateTracker().isDeviceShuttingDown(); 4350 } 4351 4352 /** 4353 * Set phone radio capability 4354 * 4355 * @param rc the phone radio capability defined in 4356 * RadioCapability. It's a input object used to transfer parameter to logic modem 4357 * @param response Callback message. 4358 */ setRadioCapability(RadioCapability rc, Message response)4359 public void setRadioCapability(RadioCapability rc, Message response) { 4360 mCi.setRadioCapability(rc, response); 4361 } 4362 4363 /** 4364 * Get phone radio access family 4365 * 4366 * @return a bit mask to identify the radio access family. 4367 */ getRadioAccessFamily()4368 public int getRadioAccessFamily() { 4369 final RadioCapability rc = getRadioCapability(); 4370 return (rc == null ? RadioAccessFamily.RAF_UNKNOWN : rc.getRadioAccessFamily()); 4371 } 4372 4373 /** 4374 * Get the associated data modems Id. 4375 * 4376 * @return a String containing the id of the data modem 4377 */ getModemUuId()4378 public String getModemUuId() { 4379 final RadioCapability rc = getRadioCapability(); 4380 return (rc == null ? "" : rc.getLogicalModemUuid()); 4381 } 4382 4383 /** 4384 * Get phone radio capability 4385 * 4386 * @return the capability of the radio defined in RadioCapability 4387 */ getRadioCapability()4388 public RadioCapability getRadioCapability() { 4389 return mRadioCapability.get(); 4390 } 4391 4392 /** 4393 * The RadioCapability has changed. This comes up from the RIL and is called when radios first 4394 * become available or after a capability switch. The flow is we use setRadioCapability to 4395 * request a change with the RIL and get an UNSOL response with the new data which gets set 4396 * here. 4397 * 4398 * @param rc the phone radio capability currently in effect for this phone. 4399 * @param capabilitySwitched whether this method called after a radio capability switch 4400 * completion or called when radios first become available. 4401 */ radioCapabilityUpdated(RadioCapability rc, boolean capabilitySwitched)4402 public void radioCapabilityUpdated(RadioCapability rc, boolean capabilitySwitched) { 4403 // Called when radios first become available or after a capability switch 4404 // Update the cached value 4405 mRadioCapability.set(rc); 4406 4407 if (SubscriptionManager.isValidSubscriptionId(getSubId())) { 4408 boolean restoreSelection = !mContext.getResources().getBoolean( 4409 com.android.internal.R.bool.skip_restoring_network_selection); 4410 sendSubscriptionSettings(restoreSelection); 4411 } 4412 4413 // When radio capability switch is done, query IMEI value and update it in Phone objects 4414 // to make it in sync with the IMEI value currently used by Logical-Modem. 4415 if (capabilitySwitched) { 4416 mCi.getImei(obtainMessage(EVENT_GET_DEVICE_IMEI_DONE)); 4417 mCi.getDeviceIdentity(obtainMessage(EVENT_GET_DEVICE_IDENTITY_DONE)); 4418 } 4419 } 4420 sendSubscriptionSettings(boolean restoreNetworkSelection)4421 public void sendSubscriptionSettings(boolean restoreNetworkSelection) { 4422 // Send settings down 4423 if (mIsAllowedNetworkTypesLoadedFromDb) { 4424 updateAllowedNetworkTypes(null); 4425 } 4426 4427 if (restoreNetworkSelection) { 4428 restoreSavedNetworkSelection(null); 4429 } 4430 4431 updateUsageSetting(); 4432 } 4433 getResolvedUsageSetting(int subId)4434 private int getResolvedUsageSetting(int subId) { 4435 SubscriptionInfo subInfo = null; 4436 SubscriptionInfoInternal subInfoInternal = mSubscriptionManagerService 4437 .getSubscriptionInfoInternal(subId); 4438 if (subInfoInternal != null) { 4439 subInfo = subInfoInternal.toSubscriptionInfo(); 4440 } 4441 4442 if (subInfo == null 4443 || subInfo.getUsageSetting() == SubscriptionManager.USAGE_SETTING_UNKNOWN) { 4444 loge("Failed to get SubscriptionInfo for subId=" + subId); 4445 return SubscriptionManager.USAGE_SETTING_UNKNOWN; 4446 } 4447 4448 if (subInfo.getUsageSetting() != SubscriptionManager.USAGE_SETTING_DEFAULT) { 4449 return subInfo.getUsageSetting(); 4450 } 4451 4452 if (subInfo.isOpportunistic()) { 4453 return SubscriptionManager.USAGE_SETTING_DATA_CENTRIC; 4454 } else { 4455 return mContext.getResources().getInteger( 4456 com.android.internal.R.integer.config_default_cellular_usage_setting); 4457 } 4458 } 4459 4460 /** 4461 * Attempt to update the usage setting. 4462 * 4463 * @return whether the usage setting will be updated (used for test) 4464 */ updateUsageSetting()4465 public boolean updateUsageSetting() { 4466 if (!mIsUsageSettingSupported) return false; 4467 4468 final int subId = getSubId(); 4469 if (!SubscriptionManager.isValidSubscriptionId(subId)) return false; 4470 4471 final int lastPreferredUsageSetting = mPreferredUsageSetting; 4472 4473 mPreferredUsageSetting = getResolvedUsageSetting(subId); 4474 if (mPreferredUsageSetting == SubscriptionManager.USAGE_SETTING_UNKNOWN) { 4475 loge("Usage Setting is Supported but Preferred Setting Unknown!"); 4476 return false; 4477 } 4478 4479 // We might get a lot of requests to update, so definitely we don't want to hammer 4480 // the modem with multiple duplicate requests for usage setting updates 4481 if (mPreferredUsageSetting == lastPreferredUsageSetting) return false; 4482 4483 String logStr = "mPreferredUsageSetting=" + mPreferredUsageSetting 4484 + ", lastPreferredUsageSetting=" + lastPreferredUsageSetting 4485 + ", mUsageSettingFromModem=" + mUsageSettingFromModem; 4486 logd(logStr); 4487 mLocalLog.log(logStr); 4488 4489 // If the modem value hasn't been updated, request it. 4490 if (mUsageSettingFromModem == SubscriptionManager.USAGE_SETTING_UNKNOWN) { 4491 mCi.getUsageSetting(obtainMessage(EVENT_GET_USAGE_SETTING_DONE)); 4492 // If the modem value is already known, and the value has changed, proceed to update. 4493 } else if (mPreferredUsageSetting != mUsageSettingFromModem) { 4494 mCi.setUsageSetting(obtainMessage(EVENT_SET_USAGE_SETTING_DONE), 4495 mPreferredUsageSetting); 4496 } 4497 return true; 4498 } 4499 4500 4501 4502 /** 4503 * Registers the handler when phone radio capability is changed. 4504 * 4505 * @param h Handler for notification message. 4506 * @param what User-defined message code. 4507 * @param obj User object. 4508 */ registerForRadioCapabilityChanged(Handler h, int what, Object obj)4509 public void registerForRadioCapabilityChanged(Handler h, int what, Object obj) { 4510 mCi.registerForRadioCapabilityChanged(h, what, obj); 4511 } 4512 4513 /** 4514 * Unregister for notifications when phone radio type and access technology is changed. 4515 * 4516 * @param h Handler to be removed from the registrant list. 4517 */ unregisterForRadioCapabilityChanged(Handler h)4518 public void unregisterForRadioCapabilityChanged(Handler h) { 4519 mCi.unregisterForRadioCapabilityChanged(this); 4520 } 4521 4522 /** 4523 * Determines if the connection to IMS services are available yet. 4524 * @return {@code true} if the connection to IMS services are available. 4525 */ isImsAvailable()4526 public boolean isImsAvailable() { 4527 if (mImsPhone == null) { 4528 return false; 4529 } 4530 4531 return mImsPhone.isImsAvailable(); 4532 } 4533 4534 /** 4535 * Determines if video calling is enabled for the phone. 4536 * 4537 * @return {@code true} if video calling is enabled, {@code false} otherwise. 4538 */ 4539 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) isVideoEnabled()4540 public boolean isVideoEnabled() { 4541 Phone imsPhone = mImsPhone; 4542 if (imsPhone != null) { 4543 return imsPhone.isVideoEnabled(); 4544 } 4545 return false; 4546 } 4547 4548 /** 4549 * Returns the status of Link Capacity Estimation (LCE) service. 4550 */ getLceStatus()4551 public int getLceStatus() { 4552 return mLceStatus; 4553 } 4554 4555 /** 4556 * Returns the modem activity information 4557 */ getModemActivityInfo(Message response, WorkSource workSource)4558 public void getModemActivityInfo(Message response, WorkSource workSource) { 4559 mCi.getModemActivityInfo(response, workSource); 4560 } 4561 4562 /** 4563 * Starts LCE service after radio becomes available. 4564 * LCE service state may get destroyed on the modem when radio becomes unavailable. 4565 */ startLceAfterRadioIsAvailable()4566 public void startLceAfterRadioIsAvailable() { 4567 mCi.startLceService(DEFAULT_REPORT_INTERVAL_MS, LCE_PULL_MODE, 4568 obtainMessage(EVENT_CONFIG_LCE)); 4569 } 4570 4571 /** 4572 * Control the data throttling at modem. 4573 * 4574 * @param result Message that will be sent back to the requester 4575 * @param workSource calling Worksource 4576 * @param dataThrottlingAction the DataThrottlingAction that is being requested. Defined in 4577 * android.telephony.TelephonyManger. 4578 * @param completionWindowMillis milliseconds in which data throttling action has to be 4579 * achieved. 4580 */ setDataThrottling(Message result, WorkSource workSource, int dataThrottlingAction, long completionWindowMillis)4581 public void setDataThrottling(Message result, WorkSource workSource, 4582 int dataThrottlingAction, long completionWindowMillis) { 4583 mCi.setDataThrottling(result, workSource, dataThrottlingAction, completionWindowMillis); 4584 } 4585 4586 /** 4587 * Set allowed carriers 4588 */ setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, Message response, WorkSource workSource)4589 public void setAllowedCarriers(CarrierRestrictionRules carrierRestrictionRules, 4590 Message response, WorkSource workSource) { 4591 mCi.setAllowedCarriers(carrierRestrictionRules, response, workSource); 4592 } 4593 4594 /** Sets the SignalStrength reporting criteria. */ setLinkCapacityReportingCriteria(int[] dlThresholds, int[] ulThresholds, int ran)4595 public void setLinkCapacityReportingCriteria(int[] dlThresholds, int[] ulThresholds, int ran) { 4596 // no-op default implementation 4597 } 4598 4599 /** 4600 * Get allowed carriers 4601 */ getAllowedCarriers(Message response, WorkSource workSource)4602 public void getAllowedCarriers(Message response, WorkSource workSource) { 4603 mCi.getAllowedCarriers(response, workSource); 4604 } 4605 4606 /** 4607 * Returns the locale based on the carrier properties (such as {@code ro.carrier}) and 4608 * SIM preferences. 4609 */ getLocaleFromSimAndCarrierPrefs()4610 public Locale getLocaleFromSimAndCarrierPrefs() { 4611 final IccRecords records = mIccRecords.get(); 4612 if (records != null && records.getSimLanguage() != null) { 4613 return new Locale(records.getSimLanguage()); 4614 } 4615 4616 return getLocaleFromCarrierProperties(); 4617 } 4618 updateCurrentCarrierInProvider()4619 public boolean updateCurrentCarrierInProvider() { 4620 return false; 4621 } 4622 4623 @UnsupportedAppUsage getIccSmsInterfaceManager()4624 public IccSmsInterfaceManager getIccSmsInterfaceManager(){ 4625 return null; 4626 } 4627 isMatchGid(String gid)4628 protected boolean isMatchGid(String gid) { 4629 String gid1 = getGroupIdLevel1(); 4630 int gidLength = gid.length(); 4631 if (!TextUtils.isEmpty(gid1) && (gid1.length() >= gidLength) 4632 && gid1.substring(0, gidLength).equalsIgnoreCase(gid)) { 4633 return true; 4634 } 4635 return false; 4636 } 4637 checkWfcWifiOnlyModeBeforeDial(Phone imsPhone, int phoneId, Context context)4638 public static void checkWfcWifiOnlyModeBeforeDial(Phone imsPhone, int phoneId, Context context) 4639 throws CallStateException { 4640 if (imsPhone == null || !imsPhone.isWifiCallingEnabled()) { 4641 ImsManager imsManager = ImsManager.getInstance(context, phoneId); 4642 boolean wfcWiFiOnly = (imsManager.isWfcEnabledByPlatform() 4643 && imsManager.isWfcEnabledByUser() && (imsManager.getWfcMode() 4644 == ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY)); 4645 if (wfcWiFiOnly) { 4646 throw new CallStateException( 4647 CallStateException.ERROR_OUT_OF_SERVICE, 4648 "WFC Wi-Fi Only Mode: IMS not registered"); 4649 } 4650 } 4651 } 4652 startRingbackTone()4653 public void startRingbackTone() { 4654 } 4655 stopRingbackTone()4656 public void stopRingbackTone() { 4657 } 4658 callEndCleanupHandOverCallIfAny()4659 public void callEndCleanupHandOverCallIfAny() { 4660 } 4661 4662 /** 4663 * Cancel USSD session. 4664 * 4665 * @param msg The message to dispatch when the USSD session terminated. 4666 */ cancelUSSD(Message msg)4667 public void cancelUSSD(Message msg) { 4668 } 4669 4670 /** 4671 * Set boolean broadcastEmergencyCallStateChanges 4672 */ setBroadcastEmergencyCallStateChanges(boolean broadcast)4673 public abstract void setBroadcastEmergencyCallStateChanges(boolean broadcast); 4674 sendEmergencyCallStateChange(boolean callActive)4675 public abstract void sendEmergencyCallStateChange(boolean callActive); 4676 4677 /** 4678 * This function returns the parent phone of the current phone. It is applicable 4679 * only for IMS phone (function is overridden by ImsPhone). For others the phone 4680 * object itself is returned. 4681 * @return 4682 */ getDefaultPhone()4683 public Phone getDefaultPhone() { 4684 return this; 4685 } 4686 4687 /** 4688 * SIP URIs aliased to the current subscriber given by the IMS implementation. 4689 * Applicable only on IMS; used in absence of line1number. 4690 * @return array of SIP URIs aliased to the current subscriber 4691 */ getCurrentSubscriberUris()4692 public Uri[] getCurrentSubscriberUris() { 4693 return null; 4694 } 4695 getAppSmsManager()4696 public AppSmsManager getAppSmsManager() { 4697 return mAppSmsManager; 4698 } 4699 4700 /** 4701 * Set SIM card power state. 4702 * @param state State of SIM (power down, power up, pass through) 4703 * - {@link android.telephony.TelephonyManager#CARD_POWER_DOWN} 4704 * - {@link android.telephony.TelephonyManager#CARD_POWER_UP} 4705 * - {@link android.telephony.TelephonyManager#CARD_POWER_UP_PASS_THROUGH} 4706 **/ setSimPowerState(int state, Message result, WorkSource workSource)4707 public void setSimPowerState(int state, Message result, WorkSource workSource) { 4708 mCi.setSimCardPower(state, result, workSource); 4709 } 4710 4711 /** 4712 * Enable or disable Voice over NR (VoNR) 4713 * @param enabled enable or disable VoNR. 4714 **/ setVoNrEnabled(boolean enabled, Message result, WorkSource workSource)4715 public void setVoNrEnabled(boolean enabled, Message result, WorkSource workSource) { 4716 mCi.setVoNrEnabled(enabled, result, workSource); 4717 } 4718 4719 /** 4720 * Is voice over NR enabled 4721 */ isVoNrEnabled(Message message, WorkSource workSource)4722 public void isVoNrEnabled(Message message, WorkSource workSource) { 4723 mCi.isVoNrEnabled(message, workSource); 4724 } 4725 setCarrierTestOverride(String mccmnc, String imsi, String iccid, String gid1, String gid2, String pnn, String spn, String carrierPrivilegeRules, String apn)4726 public void setCarrierTestOverride(String mccmnc, String imsi, String iccid, String gid1, 4727 String gid2, String pnn, String spn, String carrierPrivilegeRules, String apn) { 4728 } 4729 4730 /** 4731 * Check if the device can only make the emergency call. The device is emergency call only if 4732 * none of the phone is in service, and one of them has the capability to make the emergency 4733 * call. 4734 * 4735 * @return {@code True} if the device is emergency call only, otherwise return {@code False}. 4736 */ isEmergencyCallOnly()4737 public static boolean isEmergencyCallOnly() { 4738 boolean isEmergencyCallOnly = false; 4739 for (Phone phone : PhoneFactory.getPhones()) { 4740 if (phone != null) { 4741 ServiceStateTracker sst = phone.getServiceStateTracker(); 4742 ServiceState ss = sst.getServiceState(); 4743 // Combined reg state is in service, hence the device is not emergency call only. 4744 if (sst.getCombinedRegState(ss) == ServiceState.STATE_IN_SERVICE) { 4745 return false; 4746 } 4747 isEmergencyCallOnly |= ss.isEmergencyOnly(); 4748 } 4749 } 4750 return isEmergencyCallOnly; 4751 } 4752 4753 // Return true if either CSIM or RUIM app is present. By default it returns false. isCdmaSubscriptionAppPresent()4754 public boolean isCdmaSubscriptionAppPresent() { 4755 return false; 4756 } 4757 4758 /** 4759 * Enable or disable uicc applications. 4760 * @param enable whether to enable or disable uicc applications. 4761 * @param onCompleteMessage callback for async operation. Ignored if blockingCall is true. 4762 */ enableUiccApplications(boolean enable, Message onCompleteMessage)4763 public void enableUiccApplications(boolean enable, Message onCompleteMessage) {} 4764 4765 /** 4766 * Whether disabling a physical subscription is supported or not. 4767 */ canDisablePhysicalSubscription()4768 public boolean canDisablePhysicalSubscription() { 4769 return false; 4770 } 4771 4772 /** 4773 * Get the HAL version. 4774 * 4775 * @return the current HalVersion 4776 * 4777 * @deprecated Use {@link #getHalVersion(int service)} instead. 4778 */ 4779 @Deprecated getHalVersion()4780 public HalVersion getHalVersion() { 4781 return getHalVersion(HAL_SERVICE_RADIO); 4782 } 4783 4784 /** 4785 * Get the HAL version with a specific service. 4786 * 4787 * @param service the service id to query 4788 * @return the current HalVersion for a specific service 4789 * 4790 */ getHalVersion(@alService int service)4791 public HalVersion getHalVersion(@HalService int service) { 4792 if (mCi != null && mCi instanceof RIL) { 4793 return ((RIL) mCi).getHalVersion(service); 4794 } 4795 return RIL.RADIO_HAL_VERSION_UNKNOWN; 4796 } 4797 4798 /** 4799 * Get the SIM's MCC/MNC 4800 * 4801 * @return MCC/MNC in string format, empty string if not available. 4802 */ 4803 @NonNull getOperatorNumeric()4804 public String getOperatorNumeric() { 4805 return ""; 4806 } 4807 4808 /** Returns the {@link VoiceCallSessionStats} for this phone ID. */ getVoiceCallSessionStats()4809 public VoiceCallSessionStats getVoiceCallSessionStats() { 4810 return mVoiceCallSessionStats; 4811 } 4812 4813 /** Sets the {@link VoiceCallSessionStats} mock for this phone ID during unit testing. */ 4814 @VisibleForTesting setVoiceCallSessionStats(VoiceCallSessionStats voiceCallSessionStats)4815 public void setVoiceCallSessionStats(VoiceCallSessionStats voiceCallSessionStats) { 4816 mVoiceCallSessionStats = voiceCallSessionStats; 4817 } 4818 4819 /** Returns the {@link SmsStats} for this phone ID. */ getSmsStats()4820 public SmsStats getSmsStats() { 4821 return mSmsStats; 4822 } 4823 4824 /** Sets the {@link SmsStats} mock for this phone ID during unit testing. */ 4825 @VisibleForTesting setSmsStats(SmsStats smsStats)4826 public void setSmsStats(SmsStats smsStats) { 4827 mSmsStats = smsStats; 4828 } 4829 4830 /** @hide */ getCarrierPrivilegesTracker()4831 public CarrierPrivilegesTracker getCarrierPrivilegesTracker() { 4832 return null; 4833 } 4834 useSsOverIms(Message onComplete)4835 public boolean useSsOverIms(Message onComplete) { 4836 return false; 4837 } 4838 4839 /** 4840 * Check if device is idle. Device is idle when it is not in high power consumption mode. 4841 * 4842 * @see DeviceStateMonitor#shouldEnableHighPowerConsumptionIndications() 4843 * 4844 * @return true if device is idle 4845 */ isDeviceIdle()4846 public boolean isDeviceIdle() { 4847 DeviceStateMonitor dsm = getDeviceStateMonitor(); 4848 if (dsm == null) { 4849 Rlog.e(LOG_TAG, "isDeviceIdle: DeviceStateMonitor is null"); 4850 return false; 4851 } 4852 return !dsm.shouldEnableHighPowerConsumptionIndications(); 4853 } 4854 4855 /** 4856 * Get notified when device idleness state has changed 4857 * 4858 * @param isIdle true if the new state is idle 4859 */ notifyDeviceIdleStateChanged(boolean isIdle)4860 public void notifyDeviceIdleStateChanged(boolean isIdle) { 4861 SignalStrengthController ssc = getSignalStrengthController(); 4862 if (ssc == null) { 4863 Rlog.e(LOG_TAG, "notifyDeviceIdleStateChanged: SignalStrengthController is null"); 4864 return; 4865 } 4866 ssc.onDeviceIdleStateChanged(isIdle); 4867 } 4868 4869 /** 4870 * Returns a list of the equivalent home PLMNs (EF_EHPLMN) from the USIM app. 4871 * 4872 * @return A list of equivalent home PLMNs. Returns an empty list if EF_EHPLMN is empty or 4873 * does not exist on the SIM card. 4874 */ getEquivalentHomePlmns()4875 public @NonNull List<String> getEquivalentHomePlmns() { 4876 return Collections.emptyList(); 4877 } 4878 4879 /** 4880 * 4881 * @return 4882 */ getDataServicePackages()4883 public @NonNull List<String> getDataServicePackages() { 4884 return Collections.emptyList(); 4885 } 4886 4887 /** 4888 * Return link bandwidth estimator 4889 */ getLinkBandwidthEstimator()4890 public LinkBandwidthEstimator getLinkBandwidthEstimator() { 4891 return mLinkBandwidthEstimator; 4892 } 4893 4894 /** 4895 * Request to get the current slicing configuration including URSP rules and 4896 * NSSAIs (configured, allowed and rejected). 4897 */ getSlicingConfig(Message response)4898 public void getSlicingConfig(Message response) { 4899 mCi.getSlicingConfig(response); 4900 } 4901 4902 /** 4903 * Returns the InboundSmsHandler object for this phone 4904 */ getInboundSmsHandler(boolean is3gpp2)4905 public InboundSmsHandler getInboundSmsHandler(boolean is3gpp2) { 4906 return null; 4907 } 4908 4909 /** 4910 * @return The data network controller 4911 */ getDataNetworkController()4912 public @Nullable DataNetworkController getDataNetworkController() { 4913 return mDataNetworkController; 4914 } 4915 4916 /** 4917 * @return The data settings manager 4918 */ getDataSettingsManager()4919 public @Nullable DataSettingsManager getDataSettingsManager() { 4920 if (mDataNetworkController == null) return null; 4921 return mDataNetworkController.getDataSettingsManager(); 4922 } 4923 4924 /** 4925 * Used in unit tests to set whether the AllowedNetworkTypes is loaded from Db. Should not 4926 * be used otherwise. 4927 * 4928 * @return {@code true} if the AllowedNetworkTypes is loaded from Db, 4929 * {@code false} otherwise. 4930 */ 4931 @VisibleForTesting isAllowedNetworkTypesLoadedFromDb()4932 public boolean isAllowedNetworkTypesLoadedFromDb() { 4933 return mIsAllowedNetworkTypesLoadedFromDb; 4934 } 4935 4936 /** 4937 * Returns the user's last setting for terminal-based call waiting 4938 * @param forCsOnly indicates the caller expects the result for CS calls only 4939 */ getTerminalBasedCallWaitingState(boolean forCsOnly)4940 public int getTerminalBasedCallWaitingState(boolean forCsOnly) { 4941 return CallWaitingController.TERMINAL_BASED_NOT_SUPPORTED; 4942 } 4943 4944 /** 4945 * Notifies the change of the user setting of the terminal-based call waiting service 4946 * to IMS service. 4947 */ setTerminalBasedCallWaitingStatus(int state)4948 public void setTerminalBasedCallWaitingStatus(int state) { 4949 } 4950 4951 /** 4952 * Notifies that the IMS service connected supports the terminal-based call waiting service 4953 */ setTerminalBasedCallWaitingSupported(boolean supported)4954 public void setTerminalBasedCallWaitingSupported(boolean supported) { 4955 } 4956 4957 /** 4958 * Notifies the NAS and RRC layers of the radio the type of upcoming IMS traffic. 4959 * 4960 * @param token A nonce to identify the request. 4961 * @param trafficType IMS traffic type like registration, voice, video, SMS, emergency, and etc. 4962 * @param accessNetworkType The type of the radio access network used. 4963 * @param trafficDirection Indicates whether traffic is originated by mobile originated or 4964 * mobile terminated use case eg. MO/MT call/SMS etc. 4965 * @param response is callback message. 4966 */ startImsTraffic(int token, @MmTelFeature.ImsTrafficType int trafficType, @AccessNetworkConstants.RadioAccessNetworkType int accessNetworkType, @MmTelFeature.ImsTrafficDirection int trafficDirection, Message response)4967 public void startImsTraffic(int token, 4968 @MmTelFeature.ImsTrafficType int trafficType, 4969 @AccessNetworkConstants.RadioAccessNetworkType int accessNetworkType, 4970 @MmTelFeature.ImsTrafficDirection int trafficDirection, Message response) { 4971 mCi.startImsTraffic(token, trafficType, accessNetworkType, trafficDirection, response); 4972 } 4973 4974 /** 4975 * Notifies IMS traffic has been stopped. 4976 * 4977 * @param token The token assigned by startImsTraffic. 4978 * @param response is callback message. 4979 */ stopImsTraffic(int token, Message response)4980 public void stopImsTraffic(int token, Message response) { 4981 mCi.stopImsTraffic(token, response); 4982 } 4983 4984 /** 4985 * Register for notifications of connection setup failure 4986 * 4987 * @param h Handler for notification message. 4988 * @param what User-defined message code. 4989 * @param obj User object. 4990 */ registerForConnectionSetupFailure(Handler h, int what, Object obj)4991 public void registerForConnectionSetupFailure(Handler h, int what, Object obj) { 4992 mCi.registerForConnectionSetupFailure(h, what, obj); 4993 } 4994 4995 /** 4996 * Unregister for notifications of connection setup failure 4997 * 4998 * @param h Handler to be removed from the registrant list. 4999 */ unregisterForConnectionSetupFailure(Handler h)5000 public void unregisterForConnectionSetupFailure(Handler h) { 5001 mCi.unregisterForConnectionSetupFailure(h); 5002 } 5003 5004 /** 5005 * Triggers the UE initiated EPS fallback procedure. 5006 * 5007 * @param reason specifies the reason for EPS fallback. 5008 * @param response is callback message. 5009 */ triggerEpsFallback(@mTelFeature.EpsFallbackReason int reason, Message response)5010 public void triggerEpsFallback(@MmTelFeature.EpsFallbackReason int reason, Message response) { 5011 mCi.triggerEpsFallback(reason, response); 5012 } 5013 5014 /** 5015 * Notifies the recommended bit rate for the indicated logical channel and direction. 5016 * 5017 * @param mediaType MediaType is used to identify media stream such as audio or video. 5018 * @param direction Direction of this packet stream (e.g. uplink or downlink). 5019 * @param bitsPerSecond The recommended bit rate for the UE for a specific logical channel and 5020 * a specific direction by NW. 5021 */ triggerNotifyAnbr(int mediaType, int direction, int bitsPerSecond)5022 public void triggerNotifyAnbr(int mediaType, int direction, int bitsPerSecond) { 5023 } 5024 5025 /** 5026 * Sets the emergency mode 5027 * 5028 * @param emcMode The radio emergency mode type. 5029 * @param result Callback message. 5030 */ setEmergencyMode(@mergencyConstants.EmergencyMode int emcMode, @Nullable Message result)5031 public void setEmergencyMode(@EmergencyConstants.EmergencyMode int emcMode, 5032 @Nullable Message result) { 5033 mCi.setEmergencyMode(emcMode, result); 5034 } 5035 5036 /** 5037 * Triggers an emergency network scan. 5038 * 5039 * @param accessNetwork Contains the list of access network types to be prioritized 5040 * during emergency scan. The 1st entry has the highest priority. 5041 * @param scanType Indicates the type of scans to be performed i.e. limited scan, 5042 * full service scan or any scan. 5043 * @param result Callback message. 5044 */ triggerEmergencyNetworkScan( @onNull @ccessNetworkConstants.RadioAccessNetworkType int[] accessNetwork, @DomainSelectionService.EmergencyScanType int scanType, @Nullable Message result)5045 public void triggerEmergencyNetworkScan( 5046 @NonNull @AccessNetworkConstants.RadioAccessNetworkType int[] accessNetwork, 5047 @DomainSelectionService.EmergencyScanType int scanType, @Nullable Message result) { 5048 mCi.triggerEmergencyNetworkScan(accessNetwork, scanType, result); 5049 } 5050 5051 /** 5052 * Cancels ongoing emergency network scan 5053 * @param resetScan Indicates how the next {@link #triggerEmergencyNetworkScan} should work. 5054 * If {@code true}, then the modem shall start the new scan from the beginning, 5055 * otherwise the modem shall resume from the last search. 5056 * @param result Callback message. 5057 */ cancelEmergencyNetworkScan(boolean resetScan, @Nullable Message result)5058 public void cancelEmergencyNetworkScan(boolean resetScan, @Nullable Message result) { 5059 mCi.cancelEmergencyNetworkScan(resetScan, result); 5060 } 5061 5062 /** 5063 * Exits ongoing emergency mode 5064 * @param result Callback message. 5065 */ exitEmergencyMode(@ullable Message result)5066 public void exitEmergencyMode(@Nullable Message result) { 5067 mCi.exitEmergencyMode(result); 5068 } 5069 5070 /** 5071 * Registers for emergency network scan result. 5072 * 5073 * @param h Handler for notification message. 5074 * @param what User-defined message code. 5075 * @param obj User object. 5076 */ registerForEmergencyNetworkScan(@onNull Handler h, int what, @Nullable Object obj)5077 public void registerForEmergencyNetworkScan(@NonNull Handler h, 5078 int what, @Nullable Object obj) { 5079 mCi.registerForEmergencyNetworkScan(h, what, obj); 5080 } 5081 5082 /** 5083 * Unregisters for emergency network scan result. 5084 * 5085 * @param h Handler to be removed from the registrant list. 5086 */ unregisterForEmergencyNetworkScan(@onNull Handler h)5087 public void unregisterForEmergencyNetworkScan(@NonNull Handler h) { 5088 mCi.unregisterForEmergencyNetworkScan(h); 5089 } 5090 5091 /** 5092 * Notifies that IMS deregistration is triggered. 5093 * 5094 * @param reason the reason why the deregistration is triggered. 5095 */ triggerImsDeregistration( @msRegistrationImplBase.ImsDeregistrationReason int reason)5096 public void triggerImsDeregistration( 5097 @ImsRegistrationImplBase.ImsDeregistrationReason int reason) { 5098 if (mImsPhone != null) { 5099 mImsPhone.triggerImsDeregistration(reason); 5100 } 5101 } 5102 5103 /** 5104 * Registers for the domain selected for emergency calls. 5105 * 5106 * @param h Handler for notification message. 5107 * @param what User-defined message code. 5108 * @param obj User object. 5109 */ registerForEmergencyDomainSelected( @onNull Handler h, int what, @Nullable Object obj)5110 public void registerForEmergencyDomainSelected( 5111 @NonNull Handler h, int what, @Nullable Object obj) { 5112 } 5113 5114 /** 5115 * Unregisters for the domain selected for emergency calls. 5116 * 5117 * @param h Handler to be removed from the registrant list. 5118 */ unregisterForEmergencyDomainSelected(@onNull Handler h)5119 public void unregisterForEmergencyDomainSelected(@NonNull Handler h) { 5120 } 5121 5122 /** 5123 * Notifies the domain selected. 5124 * 5125 * @param transportType The preferred transport type. 5126 */ notifyEmergencyDomainSelected( @ccessNetworkConstants.TransportType int transportType)5127 public void notifyEmergencyDomainSelected( 5128 @AccessNetworkConstants.TransportType int transportType) { 5129 } 5130 5131 /** 5132 * @return Telephony tester instance. 5133 */ getTelephonyTester()5134 public @Nullable TelephonyTester getTelephonyTester() { 5135 return mTelephonyTester; 5136 } 5137 5138 /** 5139 * @return User handle associated with the phone's subscription id. {@code null} if subscription 5140 * is invalid or not found. 5141 */ 5142 @Nullable getUserHandle()5143 public UserHandle getUserHandle() { 5144 int subId = getSubId(); 5145 5146 UserHandle userHandle = null; 5147 try { 5148 SubscriptionManager subManager = mContext.getSystemService(SubscriptionManager.class); 5149 if (subManager != null) { 5150 userHandle = subManager.getSubscriptionUserHandle(subId); 5151 } 5152 } catch (IllegalArgumentException ex) { 5153 loge("getUserHandle: ex=" + ex); 5154 } 5155 5156 return userHandle; 5157 } 5158 5159 /** 5160 * Checks if the context user is a managed profile. 5161 * 5162 * Note that this applies specifically to <em>managed</em> profiles. 5163 * 5164 * @return whether the context user is a managed profile. 5165 */ isManagedProfile()5166 public boolean isManagedProfile() { 5167 UserHandle userHandle = getUserHandle(); 5168 UserManager userManager = mContext.getSystemService(UserManager.class); 5169 if (userHandle == null || userManager == null) return false; 5170 return userManager.isManagedProfile(userHandle.getIdentifier()); 5171 } 5172 5173 /** 5174 * @return global null cipher and integrity enabled preference 5175 */ getNullCipherAndIntegrityEnabledPreference()5176 public boolean getNullCipherAndIntegrityEnabledPreference() { 5177 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 5178 return sp.getBoolean(PREF_NULL_CIPHER_AND_INTEGRITY_ENABLED, true); 5179 } 5180 5181 /** 5182 * @return whether or not this Phone interacts with a modem that supports the null cipher 5183 * and integrity feature. 5184 */ isNullCipherAndIntegritySupported()5185 public boolean isNullCipherAndIntegritySupported() { 5186 return false; 5187 } 5188 5189 /** 5190 * Override to implement handling of an update to the enablement of the null cipher and 5191 * integrity preference. 5192 * {@see #PREF_NULL_CIPHER_AND_INTEGRITY_ENABLED} 5193 */ handleNullCipherEnabledChange()5194 public void handleNullCipherEnabledChange() { 5195 } 5196 5197 /** 5198 * Notifies the IMS call status to the modem. 5199 * 5200 * @param imsCallInfo The list of {@link ImsCallInfo}. 5201 * @param response A callback to receive the response. 5202 */ updateImsCallStatus(@onNull List<ImsCallInfo> imsCallInfo, Message response)5203 public void updateImsCallStatus(@NonNull List<ImsCallInfo> imsCallInfo, Message response) { 5204 mCi.updateImsCallStatus(imsCallInfo, response); 5205 } 5206 5207 /** 5208 * Enables or disables N1 mode (access to 5G core network) in accordance with 5209 * 3GPP TS 24.501 4.9. 5210 * @param enable {@code true} to enable N1 mode, {@code false} to disable N1 mode. 5211 * @param result Callback message to receive the result. 5212 */ setN1ModeEnabled(boolean enable, Message result)5213 public void setN1ModeEnabled(boolean enable, Message result) { 5214 mCi.setN1ModeEnabled(enable, result); 5215 } 5216 5217 /** 5218 * Check whether N1 mode (access to 5G core network) is enabled or not. 5219 * @param result Callback message to receive the result. 5220 */ isN1ModeEnabled(Message result)5221 public void isN1ModeEnabled(Message result) { 5222 mCi.isN1ModeEnabled(result); 5223 } 5224 5225 /** 5226 * Return current cell broadcast ranges. 5227 */ getCellBroadcastIdRanges()5228 public List<CellBroadcastIdRange> getCellBroadcastIdRanges() { 5229 return new ArrayList<>(); 5230 } 5231 5232 /** 5233 * Set reception of cell broadcast messages with the list of the given ranges. 5234 */ setCellBroadcastIdRanges( @onNull List<CellBroadcastIdRange> ranges, Consumer<Integer> callback)5235 public void setCellBroadcastIdRanges( 5236 @NonNull List<CellBroadcastIdRange> ranges, Consumer<Integer> callback) { 5237 callback.accept(TelephonyManager.CELL_BROADCAST_RESULT_UNSUPPORTED); 5238 } 5239 5240 /** 5241 * Start receiving satellite position updates. 5242 * This can be called by the pointing UI when the user starts pointing to the satellite. 5243 * Modem should continue to report the pointing input as the device or satellite moves. 5244 * 5245 * @param result The Message to send to result of the operation to. 5246 **/ startSatellitePositionUpdates(Message result)5247 public void startSatellitePositionUpdates(Message result) { 5248 mCi.startSendingSatellitePointingInfo(result); 5249 } 5250 5251 /** 5252 * Stop receiving satellite position updates. 5253 * This can be called by the pointing UI when the user stops pointing to the satellite. 5254 * 5255 * @param result The Message to send to result of the operation to. 5256 **/ stopSatellitePositionUpdates(Message result)5257 public void stopSatellitePositionUpdates(Message result) { 5258 mCi.stopSendingSatellitePointingInfo(result); 5259 } 5260 5261 /** 5262 * Get maximum number of characters per text message on satellite. 5263 * @param result The Message to send the result of the operation to. 5264 */ getMaxCharactersPerSatelliteTextMessage(Message result)5265 public void getMaxCharactersPerSatelliteTextMessage(Message result) { 5266 mCi.getMaxCharactersPerSatelliteTextMessage(result); 5267 } 5268 5269 /** 5270 * Power on or off the satellite modem. 5271 * @param result The Message to send the result of the operation to. 5272 * @param powerOn {@code true} to power on the satellite modem and {@code false} to power off. 5273 */ setSatellitePower(Message result, boolean powerOn)5274 public void setSatellitePower(Message result, boolean powerOn) { 5275 mCi.setSatellitePower(result, powerOn); 5276 } 5277 5278 /** 5279 * Check whether the satellite modem is powered on. 5280 * @param result The Message to send the result of the operation to. 5281 */ isSatellitePowerOn(Message result)5282 public void isSatellitePowerOn(Message result) { 5283 mCi.getSatellitePowerState(result); 5284 } 5285 5286 /** 5287 * Check whether the satellite service is supported on the device. 5288 * @param result The Message to send the result of the operation to. 5289 */ isSatelliteSupported(Message result)5290 public void isSatelliteSupported(Message result) { 5291 mCi.isSatelliteSupported(result); 5292 } 5293 5294 /** 5295 * Check whether the satellite modem is provisioned. 5296 * @param result The Message to send the result of the operation to. 5297 */ isSatelliteProvisioned(Message result)5298 public void isSatelliteProvisioned(Message result) { 5299 mCi.getSatelliteProvisionState(result); 5300 } 5301 5302 /** 5303 * Get the satellite capabilities. 5304 * @param result The Message to send the result of the operation to. 5305 */ getSatelliteCapabilities(Message result)5306 public void getSatelliteCapabilities(Message result) { 5307 mCi.getSatelliteCapabilities(result); 5308 } 5309 5310 /** 5311 * Registers for pointing info changed from satellite modem. 5312 * 5313 * @param h Handler for notification message. 5314 * @param what User-defined message code. 5315 * @param obj User object. 5316 */ registerForSatellitePositionInfoChanged(@onNull Handler h, int what, @Nullable Object obj)5317 public void registerForSatellitePositionInfoChanged(@NonNull Handler h, 5318 int what, @Nullable Object obj) { 5319 //TODO: Rename CommandsInterface and other modules when updating HAL APIs. 5320 mCi.registerForSatellitePointingInfoChanged(h, what, obj); 5321 } 5322 5323 /** 5324 * Unregisters for pointing info changed from satellite modem. 5325 * 5326 * @param h Handler to be removed from the registrant list. 5327 */ unregisterForSatellitePositionInfoChanged(@onNull Handler h)5328 public void unregisterForSatellitePositionInfoChanged(@NonNull Handler h) { 5329 //TODO: Rename CommandsInterface and other modules when updating HAL APIs. 5330 mCi.unregisterForSatellitePointingInfoChanged(h); 5331 } 5332 5333 /** 5334 * Registers for datagrams delivered events from satellite modem. 5335 * 5336 * @param h Handler for notification message. 5337 * @param what User-defined message code. 5338 * @param obj User object. 5339 */ registerForSatelliteDatagramsDelivered(@onNull Handler h, int what, @Nullable Object obj)5340 public void registerForSatelliteDatagramsDelivered(@NonNull Handler h, 5341 int what, @Nullable Object obj) { 5342 //TODO: Remove. 5343 mCi.registerForSatelliteMessagesTransferComplete(h, what, obj); 5344 } 5345 5346 /** 5347 * Unregisters for datagrams delivered events from satellite modem. 5348 * 5349 * @param h Handler to be removed from the registrant list. 5350 */ unregisterForSatelliteDatagramsDelivered(@onNull Handler h)5351 public void unregisterForSatelliteDatagramsDelivered(@NonNull Handler h) { 5352 //TODO: Remove. 5353 mCi.unregisterForSatelliteMessagesTransferComplete(h); 5354 } 5355 5356 /** 5357 * Provision the subscription with a satellite provider. 5358 * This is needed to register the device/subscription if the provider allows dynamic 5359 * registration. 5360 * 5361 * @param result Callback message to receive the result. 5362 * @param token The token of the device/subscription to be provisioned. 5363 */ provisionSatelliteService(Message result, String token)5364 public void provisionSatelliteService(Message result, String token) { 5365 // TODO: update parameters in HAL 5366 // mCi.provisionSatelliteService(result, token); 5367 } 5368 5369 /** 5370 * Deprovision the device/subscription with a satellite provider. 5371 * This is needed to unregister the device/subscription if the provider allows dynamic 5372 * registration. 5373 * If provisioning is in progress for the given SIM, cancel the request. 5374 * If there is no request in progress, deprovision the given SIM. 5375 * 5376 * @param result Callback message to receive the result. 5377 * @param token The token of the device/subscription to be deprovisioned. 5378 */ deprovisionSatelliteService(Message result, String token)5379 public void deprovisionSatelliteService(Message result, String token) { 5380 //TODO (b/266126070): add implementation. 5381 } 5382 5383 /** 5384 * Register for a satellite provision state changed event. 5385 * 5386 * @param h Handler for notification message. 5387 * @param what User-defined message code. 5388 * @param obj User object. 5389 */ registerForSatelliteProvisionStateChanged(Handler h, int what, Object obj)5390 public void registerForSatelliteProvisionStateChanged(Handler h, int what, Object obj) { 5391 mCi.registerForSatelliteProvisionStateChanged(h, what, obj); 5392 } 5393 5394 /** 5395 * Unregister for a satellite provision state changed event. 5396 * 5397 * @param h Handler to be removed from the registrant list. 5398 */ unregisterForSatelliteProvisionStateChanged(Handler h)5399 public void unregisterForSatelliteProvisionStateChanged(Handler h) { 5400 mCi.unregisterForSatelliteProvisionStateChanged(h); 5401 } 5402 5403 /** 5404 * Get the list of provisioned satellite features. 5405 * 5406 * @param result Callback message to receive the result. 5407 */ getProvisionedSatelliteFeatures(Message result)5408 public void getProvisionedSatelliteFeatures(Message result) { 5409 //TODO (b/266126070): add implementation. 5410 } 5411 5412 /** 5413 * Registers for satellite state changed from satellite modem. 5414 * 5415 * @param h Handler for notification message. 5416 * @param what User-defined message code. 5417 * @param obj User object. 5418 */ registerForSatelliteModemStateChanged(@onNull Handler h, int what, @Nullable Object obj)5419 public void registerForSatelliteModemStateChanged(@NonNull Handler h, int what, 5420 @Nullable Object obj) { 5421 mCi.registerForSatelliteModeChanged(h, what, obj); 5422 } 5423 5424 /** 5425 * Unregisters for satellite state changed from satellite modem. 5426 * 5427 * @param h Handler to be removed from registrant list. 5428 */ unregisterForSatelliteModemStateChanged(@onNull Handler h)5429 public void unregisterForSatelliteModemStateChanged(@NonNull Handler h) { 5430 mCi.unregisterForSatelliteModeChanged(h); 5431 } 5432 5433 /** 5434 * Registers for pending datagram count info from satellite modem. 5435 * 5436 * @param h Handler for notification message. 5437 * @param what User-defined message code. 5438 * @param obj User object. 5439 */ registerForPendingDatagramCount(@onNull Handler h, int what, @Nullable Object obj)5440 public void registerForPendingDatagramCount(@NonNull Handler h, int what, 5441 @Nullable Object obj) { 5442 mCi.registerForPendingSatelliteMessageCount(h, what, obj); 5443 } 5444 5445 /** 5446 * Unregisters for pending datagram count info from satellite modem. 5447 * 5448 * @param h Handler to be removed from registrant list. 5449 */ unregisterForPendingDatagramCount(@onNull Handler h)5450 public void unregisterForPendingDatagramCount(@NonNull Handler h) { 5451 mCi.unregisterForPendingSatelliteMessageCount(h); 5452 } 5453 5454 /** 5455 * Register to receive incoming datagrams over satellite. 5456 * 5457 * @param h Handler for notification message. 5458 * @param what User-defined message code. 5459 * @param obj User object. 5460 */ registerForSatelliteDatagramsReceived(@onNull Handler h, int what, @Nullable Object obj)5461 public void registerForSatelliteDatagramsReceived(@NonNull Handler h, int what, 5462 @Nullable Object obj) { 5463 // TODO: rename 5464 mCi.registerForNewSatelliteMessages(h, what, obj); 5465 } 5466 5467 /** 5468 * Unregister to stop receiving incoming datagrams over satellite. 5469 * 5470 * @param h Handler to be removed from registrant list. 5471 */ unregisterForSatelliteDatagramsReceived(@onNull Handler h)5472 public void unregisterForSatelliteDatagramsReceived(@NonNull Handler h) { 5473 // TODO: rename 5474 mCi.unregisterForNewSatelliteMessages(h); 5475 } 5476 5477 /** 5478 * Poll pending datagrams over satellite. 5479 * @param result The Message to send the result of the operation to. 5480 */ pollPendingSatelliteDatagrams(Message result)5481 public void pollPendingSatelliteDatagrams(Message result) { 5482 //mCi.pollPendingSatelliteDatagrams(result); 5483 } 5484 5485 /** 5486 * Send datagram over satellite. 5487 * @param result The Message to send the result of the operation to. 5488 * @param datagram Datagram to send over satellite. 5489 * @param needFullScreenPointingUI this is used to indicate pointingUI app to open in 5490 * full screen mode. 5491 */ sendSatelliteDatagram(Message result, SatelliteDatagram datagram, boolean needFullScreenPointingUI)5492 public void sendSatelliteDatagram(Message result, SatelliteDatagram datagram, 5493 boolean needFullScreenPointingUI) { 5494 //mCi.sendSatelliteDatagram(result, datagram); 5495 } 5496 5497 /** 5498 * Check whether satellite communication is allowed for the current location. 5499 * @param result The Message to send the result of the operation to. 5500 */ isSatelliteCommunicationAllowedForCurrentLocation(Message result)5501 public void isSatelliteCommunicationAllowedForCurrentLocation(Message result) { 5502 mCi.isSatelliteCommunicationAllowedForCurrentLocation(result); 5503 } 5504 5505 /** 5506 * Get the time after which the satellite will be visible. 5507 * @param result The Message to send the result of the operation to. 5508 */ requestTimeForNextSatelliteVisibility(Message result)5509 public void requestTimeForNextSatelliteVisibility(Message result) { 5510 mCi.getTimeForNextSatelliteVisibility(result); 5511 } 5512 5513 /** 5514 * Start callback mode 5515 * @param type for callback mode entry. 5516 */ startCallbackMode(@elephonyManager.EmergencyCallbackModeType int type)5517 public void startCallbackMode(@TelephonyManager.EmergencyCallbackModeType int type) { 5518 Rlog.d(LOG_TAG, "startCallbackMode:type=" + type); 5519 mNotifier.notifyCallbackModeStarted(this, type); 5520 } 5521 5522 /** 5523 * Stop callback mode 5524 * @param type for callback mode exit. 5525 * @param reason for stopping callback mode. 5526 */ stopCallbackMode(@elephonyManager.EmergencyCallbackModeType int type, @TelephonyManager.EmergencyCallbackModeStopReason int reason)5527 public void stopCallbackMode(@TelephonyManager.EmergencyCallbackModeType int type, 5528 @TelephonyManager.EmergencyCallbackModeStopReason int reason) { 5529 Rlog.d(LOG_TAG, "stopCallbackMode:type=" + type + ", reason=" + reason); 5530 mNotifier.notifyCallbackModeStopped(this, type, reason); 5531 } 5532 dump(FileDescriptor fd, PrintWriter pw, String[] args)5533 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 5534 pw.println("Phone: subId=" + getSubId()); 5535 pw.println(" mPhoneId=" + mPhoneId); 5536 pw.println(" mCi=" + mCi); 5537 pw.println(" mDnsCheckDisabled=" + mDnsCheckDisabled); 5538 pw.println(" mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing); 5539 pw.println(" mCallRingContinueToken=" + mCallRingContinueToken); 5540 pw.println(" mCallRingDelay=" + mCallRingDelay); 5541 pw.println(" mIsVoiceCapable=" + mIsVoiceCapable); 5542 pw.println(" mIccRecords=" + mIccRecords.get()); 5543 pw.println(" mUiccApplication=" + mUiccApplication.get()); 5544 pw.println(" mSmsStorageMonitor=" + mSmsStorageMonitor); 5545 pw.println(" mSmsUsageMonitor=" + mSmsUsageMonitor); 5546 pw.flush(); 5547 pw.println(" mLooper=" + mLooper); 5548 pw.println(" mContext=" + mContext); 5549 pw.println(" mNotifier=" + mNotifier); 5550 pw.println(" mSimulatedRadioControl=" + mSimulatedRadioControl); 5551 pw.println(" mUnitTestMode=" + mUnitTestMode); 5552 pw.println(" isDnsCheckDisabled()=" + isDnsCheckDisabled()); 5553 pw.println(" getUnitTestMode()=" + getUnitTestMode()); 5554 pw.println(" getState()=" + getState()); 5555 pw.println(" getIccSerialNumber()=" + Rlog.pii(LOG_TAG, getIccSerialNumber())); 5556 pw.println(" getIccRecordsLoaded()=" + getIccRecordsLoaded()); 5557 pw.println(" getMessageWaitingIndicator()=" + getMessageWaitingIndicator()); 5558 pw.println(" getCallForwardingIndicator()=" + getCallForwardingIndicator()); 5559 pw.println(" isInEmergencyCall()=" + isInEmergencyCall()); 5560 pw.flush(); 5561 pw.println(" isInEcm()=" + isInEcm()); 5562 pw.println(" getPhoneName()=" + getPhoneName()); 5563 pw.println(" getPhoneType()=" + getPhoneType()); 5564 pw.println(" getVoiceMessageCount()=" + getVoiceMessageCount()); 5565 pw.println(" needsOtaServiceProvisioning=" + needsOtaServiceProvisioning()); 5566 pw.println(" isInEmergencySmsMode=" + isInEmergencySmsMode()); 5567 pw.println(" isEcmCanceledForEmergency=" + isEcmCanceledForEmergency()); 5568 pw.println(" service state=" + getServiceState()); 5569 pw.flush(); 5570 pw.println("++++++++++++++++++++++++++++++++"); 5571 5572 if (mImsPhone != null) { 5573 try { 5574 mImsPhone.dump(fd, pw, args); 5575 } catch (Exception e) { 5576 e.printStackTrace(); 5577 } 5578 5579 pw.flush(); 5580 pw.println("++++++++++++++++++++++++++++++++"); 5581 } 5582 5583 if (mDataNetworkController != null) { 5584 try { 5585 mDataNetworkController.dump(fd, pw, args); 5586 } catch (Exception e) { 5587 e.printStackTrace(); 5588 } 5589 pw.flush(); 5590 pw.println("++++++++++++++++++++++++++++++++"); 5591 } 5592 5593 if (getServiceStateTracker() != null) { 5594 try { 5595 getServiceStateTracker().dump(fd, pw, args); 5596 } catch (Exception e) { 5597 e.printStackTrace(); 5598 } 5599 5600 pw.flush(); 5601 pw.println("++++++++++++++++++++++++++++++++"); 5602 } 5603 5604 if (getEmergencyNumberTracker() != null) { 5605 try { 5606 getEmergencyNumberTracker().dump(fd, pw, args); 5607 } catch (Exception e) { 5608 e.printStackTrace(); 5609 } 5610 5611 pw.flush(); 5612 pw.println("++++++++++++++++++++++++++++++++"); 5613 } 5614 5615 if (getDisplayInfoController() != null) { 5616 try { 5617 getDisplayInfoController().dump(fd, pw, args); 5618 } catch (Exception e) { 5619 e.printStackTrace(); 5620 } 5621 5622 pw.flush(); 5623 pw.println("++++++++++++++++++++++++++++++++"); 5624 } 5625 5626 if (mCarrierResolver != null) { 5627 try { 5628 mCarrierResolver.dump(fd, pw, args); 5629 } catch (Exception e) { 5630 e.printStackTrace(); 5631 } 5632 5633 pw.flush(); 5634 pw.println("++++++++++++++++++++++++++++++++"); 5635 } 5636 5637 if (mCarrierActionAgent != null) { 5638 try { 5639 mCarrierActionAgent.dump(fd, pw, args); 5640 } catch (Exception e) { 5641 e.printStackTrace(); 5642 } 5643 5644 pw.flush(); 5645 pw.println("++++++++++++++++++++++++++++++++"); 5646 } 5647 5648 if (mCarrierSignalAgent != null) { 5649 try { 5650 mCarrierSignalAgent.dump(fd, pw, args); 5651 } catch (Exception e) { 5652 e.printStackTrace(); 5653 } 5654 5655 pw.flush(); 5656 pw.println("++++++++++++++++++++++++++++++++"); 5657 } 5658 5659 if (getCallTracker() != null) { 5660 try { 5661 getCallTracker().dump(fd, pw, args); 5662 } catch (Exception e) { 5663 e.printStackTrace(); 5664 } 5665 5666 pw.flush(); 5667 pw.println("++++++++++++++++++++++++++++++++"); 5668 } 5669 5670 if (mSimActivationTracker != null) { 5671 try { 5672 mSimActivationTracker.dump(fd, pw, args); 5673 } catch (Exception e) { 5674 e.printStackTrace(); 5675 } 5676 5677 pw.flush(); 5678 pw.println("++++++++++++++++++++++++++++++++"); 5679 } 5680 5681 if (mDeviceStateMonitor != null) { 5682 pw.println("DeviceStateMonitor:"); 5683 mDeviceStateMonitor.dump(fd, pw, args); 5684 pw.println("++++++++++++++++++++++++++++++++"); 5685 } 5686 5687 if (mSignalStrengthController != null) { 5688 pw.println("SignalStrengthController:"); 5689 mSignalStrengthController.dump(fd, pw, args); 5690 pw.println("++++++++++++++++++++++++++++++++"); 5691 } 5692 5693 if (mAccessNetworksManager != null) { 5694 mAccessNetworksManager.dump(fd, pw, args); 5695 } 5696 5697 if (mCi != null && mCi instanceof RIL) { 5698 try { 5699 ((RIL)mCi).dump(fd, pw, args); 5700 } catch (Exception e) { 5701 e.printStackTrace(); 5702 } 5703 5704 pw.flush(); 5705 pw.println("++++++++++++++++++++++++++++++++"); 5706 } 5707 5708 if (getCarrierPrivilegesTracker() != null) { 5709 pw.println("CarrierPrivilegesTracker:"); 5710 getCarrierPrivilegesTracker().dump(fd, pw, args); 5711 pw.println("++++++++++++++++++++++++++++++++"); 5712 } 5713 5714 if (getLinkBandwidthEstimator() != null) { 5715 pw.println("LinkBandwidthEstimator:"); 5716 getLinkBandwidthEstimator().dump(fd, pw, args); 5717 pw.println("++++++++++++++++++++++++++++++++"); 5718 } 5719 5720 pw.println("Phone Local Log: "); 5721 if (mLocalLog != null) { 5722 try { 5723 mLocalLog.dump(fd, pw, args); 5724 } catch (Exception e) { 5725 e.printStackTrace(); 5726 } 5727 pw.flush(); 5728 pw.println("++++++++++++++++++++++++++++++++"); 5729 } 5730 } 5731 logd(String s)5732 private void logd(String s) { 5733 Rlog.d(LOG_TAG, "[" + mPhoneId + "] " + s); 5734 } 5735 logi(String s)5736 private void logi(String s) { 5737 Rlog.i(LOG_TAG, "[" + mPhoneId + "] " + s); 5738 } 5739 loge(String s)5740 private void loge(String s) { 5741 Rlog.e(LOG_TAG, "[" + mPhoneId + "] " + s); 5742 } 5743 pii(String s)5744 private static String pii(String s) { 5745 return Rlog.pii(LOG_TAG, s); 5746 } 5747 } 5748