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