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.content.BroadcastReceiver; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.content.IntentFilter; 23 import android.content.SharedPreferences; 24 import android.net.LinkProperties; 25 import android.net.NetworkCapabilities; 26 import android.net.NetworkStats; 27 import android.net.Uri; 28 import android.net.wifi.WifiManager; 29 import android.os.AsyncResult; 30 import android.os.Build; 31 import android.os.Bundle; 32 import android.os.Handler; 33 import android.os.Looper; 34 import android.os.Message; 35 import android.os.PersistableBundle; 36 import android.os.Registrant; 37 import android.os.RegistrantList; 38 import android.os.SystemProperties; 39 import android.os.WorkSource; 40 import android.preference.PreferenceManager; 41 import android.provider.Settings; 42 import android.service.carrier.CarrierIdentifier; 43 import android.telecom.VideoProfile; 44 import android.telephony.CarrierConfigManager; 45 import android.telephony.CellIdentityCdma; 46 import android.telephony.CellInfo; 47 import android.telephony.CellInfoCdma; 48 import android.telephony.CellLocation; 49 import android.telephony.ClientRequestStats; 50 import android.telephony.ImsiEncryptionInfo; 51 import android.telephony.PhoneStateListener; 52 import android.telephony.RadioAccessFamily; 53 import android.telephony.Rlog; 54 import android.telephony.ServiceState; 55 import android.telephony.SignalStrength; 56 import android.telephony.SubscriptionManager; 57 import android.telephony.VoLteServiceState; 58 import android.text.TextUtils; 59 import android.util.Log; 60 61 import com.android.ims.ImsCall; 62 import com.android.ims.ImsConfig; 63 import com.android.ims.ImsManager; 64 import com.android.internal.R; 65 import com.android.internal.telephony.dataconnection.DataConnectionReasons; 66 import com.android.internal.telephony.dataconnection.DcTracker; 67 import com.android.internal.telephony.imsphone.ImsPhoneCall; 68 import com.android.internal.telephony.test.SimulatedRadioControl; 69 import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType; 70 import com.android.internal.telephony.uicc.IccFileHandler; 71 import com.android.internal.telephony.uicc.IccRecords; 72 import com.android.internal.telephony.uicc.IsimRecords; 73 import com.android.internal.telephony.uicc.UiccCard; 74 import com.android.internal.telephony.uicc.UiccCardApplication; 75 import com.android.internal.telephony.uicc.UiccController; 76 import com.android.internal.telephony.uicc.UsimServiceTable; 77 78 import java.io.FileDescriptor; 79 import java.io.PrintWriter; 80 import java.util.ArrayList; 81 import java.util.HashSet; 82 import java.util.List; 83 import java.util.Locale; 84 import java.util.Set; 85 import java.util.concurrent.atomic.AtomicReference; 86 87 /** 88 * (<em>Not for SDK use</em>) 89 * A base implementation for the com.android.internal.telephony.Phone interface. 90 * 91 * Note that implementations of Phone.java are expected to be used 92 * from a single application thread. This should be the same thread that 93 * originally called PhoneFactory to obtain the interface. 94 * 95 * {@hide} 96 * 97 */ 98 99 public abstract class Phone extends Handler implements PhoneInternalInterface { 100 private static final String LOG_TAG = "Phone"; 101 102 protected final static Object lockForRadioTechnologyChange = new Object(); 103 104 protected final int USSD_MAX_QUEUE = 10; 105 106 private BroadcastReceiver mImsIntentReceiver = new BroadcastReceiver() { 107 @Override 108 public void onReceive(Context context, Intent intent) { 109 Rlog.d(LOG_TAG, "mImsIntentReceiver: action " + intent.getAction()); 110 if (intent.hasExtra(ImsManager.EXTRA_PHONE_ID)) { 111 int extraPhoneId = intent.getIntExtra(ImsManager.EXTRA_PHONE_ID, 112 SubscriptionManager.INVALID_PHONE_INDEX); 113 Rlog.d(LOG_TAG, "mImsIntentReceiver: extraPhoneId = " + extraPhoneId); 114 if (extraPhoneId == SubscriptionManager.INVALID_PHONE_INDEX || 115 extraPhoneId != getPhoneId()) { 116 return; 117 } 118 } 119 120 synchronized (Phone.lockForRadioTechnologyChange) { 121 if (intent.getAction().equals(ImsManager.ACTION_IMS_SERVICE_UP)) { 122 mImsServiceReady = true; 123 updateImsPhone(); 124 ImsManager.updateImsServiceConfig(mContext, mPhoneId, false); 125 } else if (intent.getAction().equals(ImsManager.ACTION_IMS_SERVICE_DOWN)) { 126 mImsServiceReady = false; 127 updateImsPhone(); 128 } else if (intent.getAction().equals(ImsConfig.ACTION_IMS_CONFIG_CHANGED)) { 129 int item = intent.getIntExtra(ImsConfig.EXTRA_CHANGED_ITEM, -1); 130 String value = intent.getStringExtra(ImsConfig.EXTRA_NEW_VALUE); 131 ImsManager.onProvisionedValueChanged(context, item, value); 132 } 133 } 134 } 135 }; 136 137 // Key used to read and write the saved network selection numeric value 138 public static final String NETWORK_SELECTION_KEY = "network_selection_key"; 139 // Key used to read and write the saved network selection operator name 140 public static final String NETWORK_SELECTION_NAME_KEY = "network_selection_name_key"; 141 // Key used to read and write the saved network selection operator short name 142 public static final String NETWORK_SELECTION_SHORT_KEY = "network_selection_short_key"; 143 144 145 // Key used to read/write "disable data connection on boot" pref (used for testing) 146 public static final String DATA_DISABLED_ON_BOOT_KEY = "disabled_on_boot_key"; 147 148 // Key used to read/write data_roaming_is_user_setting pref 149 public static final String DATA_ROAMING_IS_USER_SETTING_KEY = "data_roaming_is_user_setting_key"; 150 151 /* Event Constants */ 152 protected static final int EVENT_RADIO_AVAILABLE = 1; 153 /** Supplementary Service Notification received. */ 154 protected static final int EVENT_SSN = 2; 155 protected static final int EVENT_SIM_RECORDS_LOADED = 3; 156 private static final int EVENT_MMI_DONE = 4; 157 protected static final int EVENT_RADIO_ON = 5; 158 protected static final int EVENT_GET_BASEBAND_VERSION_DONE = 6; 159 protected static final int EVENT_USSD = 7; 160 protected static final int EVENT_RADIO_OFF_OR_NOT_AVAILABLE = 8; 161 protected static final int EVENT_GET_IMEI_DONE = 9; 162 protected static final int EVENT_GET_IMEISV_DONE = 10; 163 private static final int EVENT_GET_SIM_STATUS_DONE = 11; 164 protected static final int EVENT_SET_CALL_FORWARD_DONE = 12; 165 protected static final int EVENT_GET_CALL_FORWARD_DONE = 13; 166 protected static final int EVENT_CALL_RING = 14; 167 private static final int EVENT_CALL_RING_CONTINUE = 15; 168 169 // Used to intercept the carrier selection calls so that 170 // we can save the values. 171 private static final int EVENT_SET_NETWORK_MANUAL_COMPLETE = 16; 172 private static final int EVENT_SET_NETWORK_AUTOMATIC_COMPLETE = 17; 173 protected static final int EVENT_SET_CLIR_COMPLETE = 18; 174 protected static final int EVENT_REGISTERED_TO_NETWORK = 19; 175 protected static final int EVENT_SET_VM_NUMBER_DONE = 20; 176 // Events for CDMA support 177 protected static final int EVENT_GET_DEVICE_IDENTITY_DONE = 21; 178 protected static final int EVENT_RUIM_RECORDS_LOADED = 22; 179 protected static final int EVENT_NV_READY = 23; 180 private static final int EVENT_SET_ENHANCED_VP = 24; 181 protected static final int EVENT_EMERGENCY_CALLBACK_MODE_ENTER = 25; 182 protected static final int EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE = 26; 183 protected static final int EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED = 27; 184 // other 185 protected static final int EVENT_SET_NETWORK_AUTOMATIC = 28; 186 protected static final int EVENT_ICC_RECORD_EVENTS = 29; 187 private static final int EVENT_ICC_CHANGED = 30; 188 // Single Radio Voice Call Continuity 189 private static final int EVENT_SRVCC_STATE_CHANGED = 31; 190 private static final int EVENT_INITIATE_SILENT_REDIAL = 32; 191 private static final int EVENT_RADIO_NOT_AVAILABLE = 33; 192 private static final int EVENT_UNSOL_OEM_HOOK_RAW = 34; 193 protected static final int EVENT_GET_RADIO_CAPABILITY = 35; 194 protected static final int EVENT_SS = 36; 195 private static final int EVENT_CONFIG_LCE = 37; 196 private static final int EVENT_CHECK_FOR_NETWORK_AUTOMATIC = 38; 197 protected static final int EVENT_VOICE_RADIO_TECH_CHANGED = 39; 198 protected static final int EVENT_REQUEST_VOICE_RADIO_TECH_DONE = 40; 199 protected static final int EVENT_RIL_CONNECTED = 41; 200 protected static final int EVENT_UPDATE_PHONE_OBJECT = 42; 201 protected static final int EVENT_CARRIER_CONFIG_CHANGED = 43; 202 // Carrier's CDMA prefer mode setting 203 protected static final int EVENT_SET_ROAMING_PREFERENCE_DONE = 44; 204 protected static final int EVENT_MODEM_RESET = 45; 205 206 protected static final int EVENT_LAST = EVENT_MODEM_RESET; 207 208 // For shared prefs. 209 private static final String GSM_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_roaming_list_"; 210 private static final String GSM_NON_ROAMING_LIST_OVERRIDE_PREFIX = "gsm_non_roaming_list_"; 211 private static final String CDMA_ROAMING_LIST_OVERRIDE_PREFIX = "cdma_roaming_list_"; 212 private static final String CDMA_NON_ROAMING_LIST_OVERRIDE_PREFIX = "cdma_non_roaming_list_"; 213 214 // Key used to read/write current CLIR setting 215 public static final String CLIR_KEY = "clir_key"; 216 217 // Key used for storing voice mail count 218 private static final String VM_COUNT = "vm_count_key"; 219 // Key used to read/write the ID for storing the voice mail 220 private static final String VM_ID = "vm_id_key"; 221 222 // Key used for storing call forwarding status 223 public static final String CF_STATUS = "cf_status_key"; 224 // Key used to read/write the ID for storing the call forwarding status 225 public static final String CF_ID = "cf_id_key"; 226 227 // Key used to read/write "disable DNS server check" pref (used for testing) 228 private static final String DNS_SERVER_CHECK_DISABLED_KEY = "dns_server_check_disabled_key"; 229 230 /** 231 * This method is invoked when the Phone exits Emergency Callback Mode. 232 */ handleExitEmergencyCallbackMode()233 protected void handleExitEmergencyCallbackMode() { 234 } 235 236 /** 237 * Small container class used to hold information relevant to 238 * the carrier selection process. operatorNumeric can be "" 239 * if we are looking for automatic selection. operatorAlphaLong is the 240 * corresponding operator name. 241 */ 242 private static class NetworkSelectMessage { 243 public Message message; 244 public String operatorNumeric; 245 public String operatorAlphaLong; 246 public String operatorAlphaShort; 247 } 248 249 /* Instance Variables */ 250 public CommandsInterface mCi; 251 protected int mVmCount = 0; 252 private boolean mDnsCheckDisabled; 253 public DcTracker mDcTracker; 254 /* Used for dispatching signals to configured carrier apps */ 255 protected CarrierSignalAgent mCarrierSignalAgent; 256 /* Used for dispatching carrier action from carrier apps */ 257 protected CarrierActionAgent mCarrierActionAgent; 258 private boolean mDoesRilSendMultipleCallRing; 259 private int mCallRingContinueToken; 260 private int mCallRingDelay; 261 private boolean mIsVoiceCapable = true; 262 private final AppSmsManager mAppSmsManager; 263 private SimActivationTracker mSimActivationTracker; 264 // Keep track of whether or not the phone is in Emergency Callback Mode for Phone and 265 // subclasses 266 protected boolean mIsPhoneInEcmState = false; 267 268 // Variable to cache the video capability. When RAT changes, we lose this info and are unable 269 // to recover from the state. We cache it and notify listeners when they register. 270 protected boolean mIsVideoCapable = false; 271 protected UiccController mUiccController = null; 272 protected final AtomicReference<IccRecords> mIccRecords = new AtomicReference<IccRecords>(); 273 public SmsStorageMonitor mSmsStorageMonitor; 274 public SmsUsageMonitor mSmsUsageMonitor; 275 protected AtomicReference<UiccCardApplication> mUiccApplication = 276 new AtomicReference<UiccCardApplication>(); 277 278 private TelephonyTester mTelephonyTester; 279 private String mName; 280 private final String mActionDetached; 281 private final String mActionAttached; 282 283 protected int mPhoneId; 284 285 private boolean mImsServiceReady = false; 286 protected Phone mImsPhone = null; 287 288 private final AtomicReference<RadioCapability> mRadioCapability = 289 new AtomicReference<RadioCapability>(); 290 291 private static final int DEFAULT_REPORT_INTERVAL_MS = 200; 292 private static final boolean LCE_PULL_MODE = true; 293 private int mLceStatus = RILConstants.LCE_NOT_AVAILABLE; 294 protected TelephonyComponentFactory mTelephonyComponentFactory; 295 296 //IMS 297 /** 298 * {@link CallStateException} message text used to indicate that an IMS call has failed because 299 * it needs to be retried using GSM or CDMA (e.g. CS fallback). 300 * TODO: Replace this with a proper exception; {@link CallStateException} doesn't make sense. 301 */ 302 public static final String CS_FALLBACK = "cs_fallback"; 303 public static final String EXTRA_KEY_ALERT_TITLE = "alertTitle"; 304 public static final String EXTRA_KEY_ALERT_MESSAGE = "alertMessage"; 305 public static final String EXTRA_KEY_ALERT_SHOW = "alertShow"; 306 public static final String EXTRA_KEY_NOTIFICATION_MESSAGE = "notificationMessage"; 307 308 private final RegistrantList mPreciseCallStateRegistrants 309 = new RegistrantList(); 310 311 private final RegistrantList mHandoverRegistrants 312 = new RegistrantList(); 313 314 private final RegistrantList mNewRingingConnectionRegistrants 315 = new RegistrantList(); 316 317 private final RegistrantList mIncomingRingRegistrants 318 = new RegistrantList(); 319 320 protected final RegistrantList mDisconnectRegistrants 321 = new RegistrantList(); 322 323 private final RegistrantList mServiceStateRegistrants 324 = new RegistrantList(); 325 326 protected final RegistrantList mMmiCompleteRegistrants 327 = new RegistrantList(); 328 329 protected final RegistrantList mMmiRegistrants 330 = new RegistrantList(); 331 332 protected final RegistrantList mUnknownConnectionRegistrants 333 = new RegistrantList(); 334 335 protected final RegistrantList mSuppServiceFailedRegistrants 336 = new RegistrantList(); 337 338 protected final RegistrantList mRadioOffOrNotAvailableRegistrants 339 = new RegistrantList(); 340 341 protected final RegistrantList mSimRecordsLoadedRegistrants 342 = new RegistrantList(); 343 344 private final RegistrantList mVideoCapabilityChangedRegistrants 345 = new RegistrantList(); 346 347 protected final RegistrantList mEmergencyCallToggledRegistrants 348 = new RegistrantList(); 349 350 protected Registrant mPostDialHandler; 351 352 private Looper mLooper; /* to insure registrants are in correct thread*/ 353 354 protected final Context mContext; 355 356 /** 357 * PhoneNotifier is an abstraction for all system-wide 358 * state change notification. DefaultPhoneNotifier is 359 * used here unless running we're inside a unit test. 360 */ 361 protected PhoneNotifier mNotifier; 362 363 protected SimulatedRadioControl mSimulatedRadioControl; 364 365 private boolean mUnitTestMode; 366 getIccRecords()367 public IccRecords getIccRecords() { 368 return mIccRecords.get(); 369 } 370 371 /** 372 * Returns a string identifier for this phone interface for parties 373 * outside the phone app process. 374 * @return The string name. 375 */ getPhoneName()376 public String getPhoneName() { 377 return mName; 378 } 379 setPhoneName(String name)380 protected void setPhoneName(String name) { 381 mName = name; 382 } 383 384 /** 385 * Retrieves Nai for phones. Returns null if Nai is not set. 386 */ getNai()387 public String getNai(){ 388 return null; 389 } 390 391 /** 392 * Return the ActionDetached string. When this action is received by components 393 * they are to simulate detaching from the network. 394 * 395 * @return com.android.internal.telephony.{mName}.action_detached 396 * {mName} is GSM, CDMA ... 397 */ getActionDetached()398 public String getActionDetached() { 399 return mActionDetached; 400 } 401 402 /** 403 * Return the ActionAttached string. When this action is received by components 404 * they are to simulate attaching to the network. 405 * 406 * @return com.android.internal.telephony.{mName}.action_detached 407 * {mName} is GSM, CDMA ... 408 */ getActionAttached()409 public String getActionAttached() { 410 return mActionAttached; 411 } 412 413 /** 414 * Set a system property, unless we're in unit test mode 415 */ 416 // CAF_MSIM TODO this need to be replated with TelephonyManager API ? setSystemProperty(String property, String value)417 public void setSystemProperty(String property, String value) { 418 if(getUnitTestMode()) { 419 return; 420 } 421 SystemProperties.set(property, value); 422 } 423 424 /** 425 * Set a system property, unless we're in unit test mode 426 */ 427 // CAF_MSIM TODO this need to be replated with TelephonyManager API ? getSystemProperty(String property, String defValue)428 public String getSystemProperty(String property, String defValue) { 429 if(getUnitTestMode()) { 430 return null; 431 } 432 return SystemProperties.get(property, defValue); 433 } 434 435 /** 436 * Constructs a Phone in normal (non-unit test) mode. 437 * 438 * @param notifier An instance of DefaultPhoneNotifier, 439 * @param context Context object from hosting application 440 * unless unit testing. 441 * @param ci is CommandsInterface 442 * @param unitTestMode when true, prevents notifications 443 * of state change events 444 */ Phone(String name, PhoneNotifier notifier, Context context, CommandsInterface ci, boolean unitTestMode)445 protected Phone(String name, PhoneNotifier notifier, Context context, CommandsInterface ci, 446 boolean unitTestMode) { 447 this(name, notifier, context, ci, unitTestMode, SubscriptionManager.DEFAULT_PHONE_INDEX, 448 TelephonyComponentFactory.getInstance()); 449 } 450 451 /** 452 * Constructs a Phone in normal (non-unit test) mode. 453 * 454 * @param notifier An instance of DefaultPhoneNotifier, 455 * @param context Context object from hosting application 456 * unless unit testing. 457 * @param ci is CommandsInterface 458 * @param unitTestMode when true, prevents notifications 459 * of state change events 460 * @param phoneId the phone-id of this phone. 461 */ Phone(String name, PhoneNotifier notifier, Context context, CommandsInterface ci, boolean unitTestMode, int phoneId, TelephonyComponentFactory telephonyComponentFactory)462 protected Phone(String name, PhoneNotifier notifier, Context context, CommandsInterface ci, 463 boolean unitTestMode, int phoneId, 464 TelephonyComponentFactory telephonyComponentFactory) { 465 mPhoneId = phoneId; 466 mName = name; 467 mNotifier = notifier; 468 mContext = context; 469 mLooper = Looper.myLooper(); 470 mCi = ci; 471 mActionDetached = this.getClass().getPackage().getName() + ".action_detached"; 472 mActionAttached = this.getClass().getPackage().getName() + ".action_attached"; 473 mAppSmsManager = telephonyComponentFactory.makeAppSmsManager(context); 474 475 if (Build.IS_DEBUGGABLE) { 476 mTelephonyTester = new TelephonyTester(this); 477 } 478 479 setUnitTestMode(unitTestMode); 480 481 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); 482 mDnsCheckDisabled = sp.getBoolean(DNS_SERVER_CHECK_DISABLED_KEY, false); 483 mCi.setOnCallRing(this, EVENT_CALL_RING, null); 484 485 /* "Voice capable" means that this device supports circuit-switched 486 * (i.e. voice) phone calls over the telephony network, and is allowed 487 * to display the in-call UI while a cellular voice call is active. 488 * This will be false on "data only" devices which can't make voice 489 * calls and don't support any in-call UI. 490 */ 491 mIsVoiceCapable = mContext.getResources().getBoolean( 492 com.android.internal.R.bool.config_voice_capable); 493 494 /** 495 * Some RIL's don't always send RIL_UNSOL_CALL_RING so it needs 496 * to be generated locally. Ideally all ring tones should be loops 497 * and this wouldn't be necessary. But to minimize changes to upper 498 * layers it is requested that it be generated by lower layers. 499 * 500 * By default old phones won't have the property set but do generate 501 * the RIL_UNSOL_CALL_RING so the default if there is no property is 502 * true. 503 */ 504 mDoesRilSendMultipleCallRing = SystemProperties.getBoolean( 505 TelephonyProperties.PROPERTY_RIL_SENDS_MULTIPLE_CALL_RING, true); 506 Rlog.d(LOG_TAG, "mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing); 507 508 mCallRingDelay = SystemProperties.getInt( 509 TelephonyProperties.PROPERTY_CALL_RING_DELAY, 3000); 510 Rlog.d(LOG_TAG, "mCallRingDelay=" + mCallRingDelay); 511 512 if (getPhoneType() == PhoneConstants.PHONE_TYPE_IMS) { 513 return; 514 } 515 516 // The locale from the "ro.carrier" system property or R.array.carrier_properties. 517 // This will be overwritten by the Locale from the SIM language settings (EF-PL, EF-LI) 518 // if applicable. 519 final Locale carrierLocale = getLocaleFromCarrierProperties(mContext); 520 if (carrierLocale != null && !TextUtils.isEmpty(carrierLocale.getCountry())) { 521 final String country = carrierLocale.getCountry(); 522 try { 523 Settings.Global.getInt(mContext.getContentResolver(), 524 Settings.Global.WIFI_COUNTRY_CODE); 525 } catch (Settings.SettingNotFoundException e) { 526 // note this is not persisting 527 WifiManager wM = (WifiManager) 528 mContext.getSystemService(Context.WIFI_SERVICE); 529 wM.setCountryCode(country, false); 530 } 531 } 532 533 // Initialize device storage and outgoing SMS usage monitors for SMSDispatchers. 534 mTelephonyComponentFactory = telephonyComponentFactory; 535 mSmsStorageMonitor = mTelephonyComponentFactory.makeSmsStorageMonitor(this); 536 mSmsUsageMonitor = mTelephonyComponentFactory.makeSmsUsageMonitor(context); 537 mUiccController = UiccController.getInstance(); 538 mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null); 539 mSimActivationTracker = mTelephonyComponentFactory.makeSimActivationTracker(this); 540 if (getPhoneType() != PhoneConstants.PHONE_TYPE_SIP) { 541 mCi.registerForSrvccStateChanged(this, EVENT_SRVCC_STATE_CHANGED, null); 542 } 543 mCi.setOnUnsolOemHookRaw(this, EVENT_UNSOL_OEM_HOOK_RAW, null); 544 mCi.startLceService(DEFAULT_REPORT_INTERVAL_MS, LCE_PULL_MODE, 545 obtainMessage(EVENT_CONFIG_LCE)); 546 } 547 548 /** 549 * Start listening for IMS service UP/DOWN events. If using the new ImsResolver APIs, we should 550 * always be setting up ImsPhones. 551 */ startMonitoringImsService()552 public void startMonitoringImsService() { 553 if (getPhoneType() == PhoneConstants.PHONE_TYPE_SIP) { 554 return; 555 } 556 557 synchronized(Phone.lockForRadioTechnologyChange) { 558 IntentFilter filter = new IntentFilter(); 559 ImsManager imsManager = ImsManager.getInstance(mContext, getPhoneId()); 560 // Don't listen to deprecated intents using the new dynamic binding. 561 if (imsManager != null && !imsManager.isDynamicBinding()) { 562 filter.addAction(ImsManager.ACTION_IMS_SERVICE_UP); 563 filter.addAction(ImsManager.ACTION_IMS_SERVICE_DOWN); 564 } 565 filter.addAction(ImsConfig.ACTION_IMS_CONFIG_CHANGED); 566 mContext.registerReceiver(mImsIntentReceiver, filter); 567 568 // Monitor IMS service - but first poll to see if already up (could miss 569 // intent). Also, when using new ImsResolver APIs, the service will be available soon, 570 // so start trying to bind. 571 if (imsManager != null) { 572 // If it is dynamic binding, kick off ImsPhone creation now instead of waiting for 573 // the service to be available. 574 if (imsManager.isDynamicBinding() || imsManager.isServiceAvailable()) { 575 mImsServiceReady = true; 576 updateImsPhone(); 577 } 578 } 579 } 580 } 581 582 /** 583 * Checks if device should convert CDMA Caller ID restriction related MMI codes to 584 * equivalent 3GPP MMI Codes that provide same functionality when device is roaming. 585 * This method should only return true on multi-mode devices when carrier requires this 586 * conversion to be done on the device. 587 * 588 * @return true when carrier config 589 * "KEY_CONVERT_CDMA_CALLER_ID_MMI_CODES_WHILE_ROAMING_ON_3GPP_BOOL" is set to true 590 */ supportsConversionOfCdmaCallerIdMmiCodesWhileRoaming()591 public boolean supportsConversionOfCdmaCallerIdMmiCodesWhileRoaming() { 592 CarrierConfigManager configManager = (CarrierConfigManager) 593 getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); 594 PersistableBundle b = configManager.getConfig(); 595 if (b != null) { 596 return b.getBoolean( 597 CarrierConfigManager 598 .KEY_CONVERT_CDMA_CALLER_ID_MMI_CODES_WHILE_ROAMING_ON_3GPP_BOOL, 599 false); 600 } else { 601 // Default value set in CarrierConfigManager 602 return false; 603 } 604 } 605 606 /** 607 * When overridden the derived class needs to call 608 * super.handleMessage(msg) so this method has a 609 * a chance to process the message. 610 * 611 * @param msg 612 */ 613 @Override handleMessage(Message msg)614 public void handleMessage(Message msg) { 615 AsyncResult ar; 616 617 // messages to be handled whether or not the phone is being destroyed 618 // should only include messages which are being re-directed and do not use 619 // resources of the phone being destroyed 620 switch (msg.what) { 621 // handle the select network completion callbacks. 622 case EVENT_SET_NETWORK_MANUAL_COMPLETE: 623 case EVENT_SET_NETWORK_AUTOMATIC_COMPLETE: 624 handleSetSelectNetwork((AsyncResult) msg.obj); 625 return; 626 } 627 628 switch(msg.what) { 629 case EVENT_CALL_RING: 630 Rlog.d(LOG_TAG, "Event EVENT_CALL_RING Received state=" + getState()); 631 ar = (AsyncResult)msg.obj; 632 if (ar.exception == null) { 633 PhoneConstants.State state = getState(); 634 if ((!mDoesRilSendMultipleCallRing) 635 && ((state == PhoneConstants.State.RINGING) || 636 (state == PhoneConstants.State.IDLE))) { 637 mCallRingContinueToken += 1; 638 sendIncomingCallRingNotification(mCallRingContinueToken); 639 } else { 640 notifyIncomingRing(); 641 } 642 } 643 break; 644 645 case EVENT_CALL_RING_CONTINUE: 646 Rlog.d(LOG_TAG, "Event EVENT_CALL_RING_CONTINUE Received state=" + getState()); 647 if (getState() == PhoneConstants.State.RINGING) { 648 sendIncomingCallRingNotification(msg.arg1); 649 } 650 break; 651 652 case EVENT_ICC_CHANGED: 653 onUpdateIccAvailability(); 654 break; 655 656 case EVENT_INITIATE_SILENT_REDIAL: 657 Rlog.d(LOG_TAG, "Event EVENT_INITIATE_SILENT_REDIAL Received"); 658 ar = (AsyncResult) msg.obj; 659 if ((ar.exception == null) && (ar.result != null)) { 660 String dialString = (String) ar.result; 661 if (TextUtils.isEmpty(dialString)) return; 662 try { 663 dialInternal(dialString, null, VideoProfile.STATE_AUDIO_ONLY, null); 664 } catch (CallStateException e) { 665 Rlog.e(LOG_TAG, "silent redial failed: " + e); 666 } 667 } 668 break; 669 670 case EVENT_SRVCC_STATE_CHANGED: 671 ar = (AsyncResult)msg.obj; 672 if (ar.exception == null) { 673 handleSrvccStateChanged((int[]) ar.result); 674 } else { 675 Rlog.e(LOG_TAG, "Srvcc exception: " + ar.exception); 676 } 677 break; 678 679 case EVENT_UNSOL_OEM_HOOK_RAW: 680 ar = (AsyncResult)msg.obj; 681 if (ar.exception == null) { 682 byte[] data = (byte[])ar.result; 683 mNotifier.notifyOemHookRawEventForSubscriber(getSubId(), data); 684 } else { 685 Rlog.e(LOG_TAG, "OEM hook raw exception: " + ar.exception); 686 } 687 break; 688 689 case EVENT_CONFIG_LCE: 690 ar = (AsyncResult) msg.obj; 691 if (ar.exception != null) { 692 Rlog.d(LOG_TAG, "config LCE service failed: " + ar.exception); 693 } else { 694 final ArrayList<Integer> statusInfo = (ArrayList<Integer>)ar.result; 695 mLceStatus = statusInfo.get(0); 696 } 697 break; 698 699 case EVENT_CHECK_FOR_NETWORK_AUTOMATIC: { 700 onCheckForNetworkSelectionModeAutomatic(msg); 701 break; 702 } 703 default: 704 throw new RuntimeException("unexpected event not handled"); 705 } 706 } 707 getHandoverConnection()708 public ArrayList<Connection> getHandoverConnection() { 709 return null; 710 } 711 notifySrvccState(Call.SrvccState state)712 public void notifySrvccState(Call.SrvccState state) { 713 } 714 registerForSilentRedial(Handler h, int what, Object obj)715 public void registerForSilentRedial(Handler h, int what, Object obj) { 716 } 717 unregisterForSilentRedial(Handler h)718 public void unregisterForSilentRedial(Handler h) { 719 } 720 handleSrvccStateChanged(int[] ret)721 private void handleSrvccStateChanged(int[] ret) { 722 Rlog.d(LOG_TAG, "handleSrvccStateChanged"); 723 724 ArrayList<Connection> conn = null; 725 Phone imsPhone = mImsPhone; 726 Call.SrvccState srvccState = Call.SrvccState.NONE; 727 if (ret != null && ret.length != 0) { 728 int state = ret[0]; 729 switch(state) { 730 case VoLteServiceState.HANDOVER_STARTED: 731 srvccState = Call.SrvccState.STARTED; 732 if (imsPhone != null) { 733 conn = imsPhone.getHandoverConnection(); 734 migrateFrom(imsPhone); 735 } else { 736 Rlog.d(LOG_TAG, "HANDOVER_STARTED: mImsPhone null"); 737 } 738 break; 739 case VoLteServiceState.HANDOVER_COMPLETED: 740 srvccState = Call.SrvccState.COMPLETED; 741 if (imsPhone != null) { 742 imsPhone.notifySrvccState(srvccState); 743 } else { 744 Rlog.d(LOG_TAG, "HANDOVER_COMPLETED: mImsPhone null"); 745 } 746 break; 747 case VoLteServiceState.HANDOVER_FAILED: 748 case VoLteServiceState.HANDOVER_CANCELED: 749 srvccState = Call.SrvccState.FAILED; 750 break; 751 752 default: 753 //ignore invalid state 754 return; 755 } 756 757 getCallTracker().notifySrvccState(srvccState, conn); 758 759 VoLteServiceState lteState = new VoLteServiceState(state); 760 notifyVoLteServiceStateChanged(lteState); 761 } 762 } 763 764 /** 765 * Gets the context for the phone, as set at initialization time. 766 */ getContext()767 public Context getContext() { 768 return mContext; 769 } 770 771 // Will be called when icc changed onUpdateIccAvailability()772 protected abstract void onUpdateIccAvailability(); 773 774 /** 775 * Disables the DNS check (i.e., allows "0.0.0.0"). 776 * Useful for lab testing environment. 777 * @param b true disables the check, false enables. 778 */ disableDnsCheck(boolean b)779 public void disableDnsCheck(boolean b) { 780 mDnsCheckDisabled = b; 781 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 782 SharedPreferences.Editor editor = sp.edit(); 783 editor.putBoolean(DNS_SERVER_CHECK_DISABLED_KEY, b); 784 editor.apply(); 785 } 786 787 /** 788 * Returns true if the DNS check is currently disabled. 789 */ isDnsCheckDisabled()790 public boolean isDnsCheckDisabled() { 791 return mDnsCheckDisabled; 792 } 793 794 /** 795 * Register for getting notifications for change in the Call State {@link Call.State} 796 * This is called PreciseCallState because the call state is more precise than the 797 * {@link PhoneConstants.State} which can be obtained using the {@link PhoneStateListener} 798 * 799 * Resulting events will have an AsyncResult in <code>Message.obj</code>. 800 * AsyncResult.userData will be set to the obj argument here. 801 * The <em>h</em> parameter is held only by a weak reference. 802 */ registerForPreciseCallStateChanged(Handler h, int what, Object obj)803 public void registerForPreciseCallStateChanged(Handler h, int what, Object obj) { 804 checkCorrectThread(h); 805 806 mPreciseCallStateRegistrants.addUnique(h, what, obj); 807 } 808 809 /** 810 * Unregisters for voice call state change notifications. 811 * Extraneous calls are tolerated silently. 812 */ unregisterForPreciseCallStateChanged(Handler h)813 public void unregisterForPreciseCallStateChanged(Handler h) { 814 mPreciseCallStateRegistrants.remove(h); 815 } 816 817 /** 818 * Subclasses of Phone probably want to replace this with a 819 * version scoped to their packages 820 */ notifyPreciseCallStateChangedP()821 protected void notifyPreciseCallStateChangedP() { 822 AsyncResult ar = new AsyncResult(null, this, null); 823 mPreciseCallStateRegistrants.notifyRegistrants(ar); 824 825 mNotifier.notifyPreciseCallState(this); 826 } 827 828 /** 829 * Notifies when a Handover happens due to SRVCC or Silent Redial 830 */ registerForHandoverStateChanged(Handler h, int what, Object obj)831 public void registerForHandoverStateChanged(Handler h, int what, Object obj) { 832 checkCorrectThread(h); 833 mHandoverRegistrants.addUnique(h, what, obj); 834 } 835 836 /** 837 * Unregisters for handover state notifications 838 */ unregisterForHandoverStateChanged(Handler h)839 public void unregisterForHandoverStateChanged(Handler h) { 840 mHandoverRegistrants.remove(h); 841 } 842 843 /** 844 * Subclasses of Phone probably want to replace this with a 845 * version scoped to their packages 846 */ notifyHandoverStateChanged(Connection cn)847 public void notifyHandoverStateChanged(Connection cn) { 848 AsyncResult ar = new AsyncResult(null, cn, null); 849 mHandoverRegistrants.notifyRegistrants(ar); 850 } 851 setIsInEmergencyCall()852 protected void setIsInEmergencyCall() { 853 } 854 migrateFrom(Phone from)855 protected void migrateFrom(Phone from) { 856 migrate(mHandoverRegistrants, from.mHandoverRegistrants); 857 migrate(mPreciseCallStateRegistrants, from.mPreciseCallStateRegistrants); 858 migrate(mNewRingingConnectionRegistrants, from.mNewRingingConnectionRegistrants); 859 migrate(mIncomingRingRegistrants, from.mIncomingRingRegistrants); 860 migrate(mDisconnectRegistrants, from.mDisconnectRegistrants); 861 migrate(mServiceStateRegistrants, from.mServiceStateRegistrants); 862 migrate(mMmiCompleteRegistrants, from.mMmiCompleteRegistrants); 863 migrate(mMmiRegistrants, from.mMmiRegistrants); 864 migrate(mUnknownConnectionRegistrants, from.mUnknownConnectionRegistrants); 865 migrate(mSuppServiceFailedRegistrants, from.mSuppServiceFailedRegistrants); 866 if (from.isInEmergencyCall()) { 867 setIsInEmergencyCall(); 868 } 869 } 870 migrate(RegistrantList to, RegistrantList from)871 protected void migrate(RegistrantList to, RegistrantList from) { 872 from.removeCleared(); 873 for (int i = 0, n = from.size(); i < n; i++) { 874 Registrant r = (Registrant) from.get(i); 875 Message msg = r.messageForRegistrant(); 876 // Since CallManager has already registered with both CS and IMS phones, 877 // the migrate should happen only for those registrants which are not 878 // registered with CallManager.Hence the below check is needed to add 879 // only those registrants to the registrant list which are not 880 // coming from the CallManager. 881 if (msg != null) { 882 if (msg.obj == CallManager.getInstance().getRegistrantIdentifier()) { 883 continue; 884 } else { 885 to.add((Registrant) from.get(i)); 886 } 887 } else { 888 Rlog.d(LOG_TAG, "msg is null"); 889 } 890 } 891 } 892 893 /** 894 * Notifies when a previously untracked non-ringing/waiting connection has appeared. 895 * This is likely due to some other entity (eg, SIM card application) initiating a call. 896 */ registerForUnknownConnection(Handler h, int what, Object obj)897 public void registerForUnknownConnection(Handler h, int what, Object obj) { 898 checkCorrectThread(h); 899 900 mUnknownConnectionRegistrants.addUnique(h, what, obj); 901 } 902 903 /** 904 * Unregisters for unknown connection notifications. 905 */ unregisterForUnknownConnection(Handler h)906 public void unregisterForUnknownConnection(Handler h) { 907 mUnknownConnectionRegistrants.remove(h); 908 } 909 910 /** 911 * Notifies when a new ringing or waiting connection has appeared.<p> 912 * 913 * Messages received from this: 914 * Message.obj will be an AsyncResult 915 * AsyncResult.userObj = obj 916 * AsyncResult.result = a Connection. <p> 917 * Please check Connection.isRinging() to make sure the Connection 918 * has not dropped since this message was posted. 919 * If Connection.isRinging() is true, then 920 * Connection.getCall() == Phone.getRingingCall() 921 */ registerForNewRingingConnection( Handler h, int what, Object obj)922 public void registerForNewRingingConnection( 923 Handler h, int what, Object obj) { 924 checkCorrectThread(h); 925 926 mNewRingingConnectionRegistrants.addUnique(h, what, obj); 927 } 928 929 /** 930 * Unregisters for new ringing connection notification. 931 * Extraneous calls are tolerated silently 932 */ unregisterForNewRingingConnection(Handler h)933 public void unregisterForNewRingingConnection(Handler h) { 934 mNewRingingConnectionRegistrants.remove(h); 935 } 936 937 /** 938 * Notifies when phone's video capabilities changes <p> 939 * 940 * Messages received from this: 941 * Message.obj will be an AsyncResult 942 * AsyncResult.userObj = obj 943 * AsyncResult.result = true if phone supports video calling <p> 944 */ registerForVideoCapabilityChanged( Handler h, int what, Object obj)945 public void registerForVideoCapabilityChanged( 946 Handler h, int what, Object obj) { 947 checkCorrectThread(h); 948 949 mVideoCapabilityChangedRegistrants.addUnique(h, what, obj); 950 951 // Notify any registrants of the cached video capability as soon as they register. 952 notifyForVideoCapabilityChanged(mIsVideoCapable); 953 } 954 955 /** 956 * Unregisters for video capability changed notification. 957 * Extraneous calls are tolerated silently 958 */ unregisterForVideoCapabilityChanged(Handler h)959 public void unregisterForVideoCapabilityChanged(Handler h) { 960 mVideoCapabilityChangedRegistrants.remove(h); 961 } 962 963 /** 964 * Register for notifications when a sInCall VoicePrivacy is enabled 965 * 966 * @param h Handler that receives the notification message. 967 * @param what User-defined message code. 968 * @param obj User object. 969 */ registerForInCallVoicePrivacyOn(Handler h, int what, Object obj)970 public void registerForInCallVoicePrivacyOn(Handler h, int what, Object obj){ 971 mCi.registerForInCallVoicePrivacyOn(h, what, obj); 972 } 973 974 /** 975 * Unegister for notifications when a sInCall VoicePrivacy is enabled 976 * 977 * @param h Handler to be removed from the registrant list. 978 */ unregisterForInCallVoicePrivacyOn(Handler h)979 public void unregisterForInCallVoicePrivacyOn(Handler h){ 980 mCi.unregisterForInCallVoicePrivacyOn(h); 981 } 982 983 /** 984 * Register for notifications when a sInCall VoicePrivacy is disabled 985 * 986 * @param h Handler that receives the notification message. 987 * @param what User-defined message code. 988 * @param obj User object. 989 */ registerForInCallVoicePrivacyOff(Handler h, int what, Object obj)990 public void registerForInCallVoicePrivacyOff(Handler h, int what, Object obj){ 991 mCi.registerForInCallVoicePrivacyOff(h, what, obj); 992 } 993 994 /** 995 * Unregister for notifications when a sInCall VoicePrivacy is disabled 996 * 997 * @param h Handler to be removed from the registrant list. 998 */ unregisterForInCallVoicePrivacyOff(Handler h)999 public void unregisterForInCallVoicePrivacyOff(Handler h){ 1000 mCi.unregisterForInCallVoicePrivacyOff(h); 1001 } 1002 1003 /** 1004 * Notifies when an incoming call rings.<p> 1005 * 1006 * Messages received from this: 1007 * Message.obj will be an AsyncResult 1008 * AsyncResult.userObj = obj 1009 * AsyncResult.result = a Connection. <p> 1010 */ registerForIncomingRing( Handler h, int what, Object obj)1011 public void registerForIncomingRing( 1012 Handler h, int what, Object obj) { 1013 checkCorrectThread(h); 1014 1015 mIncomingRingRegistrants.addUnique(h, what, obj); 1016 } 1017 1018 /** 1019 * Unregisters for ring notification. 1020 * Extraneous calls are tolerated silently 1021 */ unregisterForIncomingRing(Handler h)1022 public void unregisterForIncomingRing(Handler h) { 1023 mIncomingRingRegistrants.remove(h); 1024 } 1025 1026 /** 1027 * Notifies when a voice connection has disconnected, either due to local 1028 * or remote hangup or error. 1029 * 1030 * Messages received from this will have the following members:<p> 1031 * <ul><li>Message.obj will be an AsyncResult</li> 1032 * <li>AsyncResult.userObj = obj</li> 1033 * <li>AsyncResult.result = a Connection object that is 1034 * no longer connected.</li></ul> 1035 */ registerForDisconnect(Handler h, int what, Object obj)1036 public void registerForDisconnect(Handler h, int what, Object obj) { 1037 checkCorrectThread(h); 1038 1039 mDisconnectRegistrants.addUnique(h, what, obj); 1040 } 1041 1042 /** 1043 * Unregisters for voice disconnection notification. 1044 * Extraneous calls are tolerated silently 1045 */ unregisterForDisconnect(Handler h)1046 public void unregisterForDisconnect(Handler h) { 1047 mDisconnectRegistrants.remove(h); 1048 } 1049 1050 /** 1051 * Register for notifications when a supplementary service attempt fails. 1052 * Message.obj will contain an AsyncResult. 1053 * 1054 * @param h Handler that receives the notification message. 1055 * @param what User-defined message code. 1056 * @param obj User object. 1057 */ registerForSuppServiceFailed(Handler h, int what, Object obj)1058 public void registerForSuppServiceFailed(Handler h, int what, Object obj) { 1059 checkCorrectThread(h); 1060 1061 mSuppServiceFailedRegistrants.addUnique(h, what, obj); 1062 } 1063 1064 /** 1065 * Unregister for notifications when a supplementary service attempt fails. 1066 * Extraneous calls are tolerated silently 1067 * 1068 * @param h Handler to be removed from the registrant list. 1069 */ unregisterForSuppServiceFailed(Handler h)1070 public void unregisterForSuppServiceFailed(Handler h) { 1071 mSuppServiceFailedRegistrants.remove(h); 1072 } 1073 1074 /** 1075 * Register for notifications of initiation of a new MMI code request. 1076 * MMI codes for GSM are discussed in 3GPP TS 22.030.<p> 1077 * 1078 * Example: If Phone.dial is called with "*#31#", then the app will 1079 * be notified here.<p> 1080 * 1081 * The returned <code>Message.obj</code> will contain an AsyncResult. 1082 * 1083 * <code>obj.result</code> will be an "MmiCode" object. 1084 */ registerForMmiInitiate(Handler h, int what, Object obj)1085 public void registerForMmiInitiate(Handler h, int what, Object obj) { 1086 checkCorrectThread(h); 1087 1088 mMmiRegistrants.addUnique(h, what, obj); 1089 } 1090 1091 /** 1092 * Unregisters for new MMI initiate notification. 1093 * Extraneous calls are tolerated silently 1094 */ unregisterForMmiInitiate(Handler h)1095 public void unregisterForMmiInitiate(Handler h) { 1096 mMmiRegistrants.remove(h); 1097 } 1098 1099 /** 1100 * Register for notifications that an MMI request has completed 1101 * its network activity and is in its final state. This may mean a state 1102 * of COMPLETE, FAILED, or CANCELLED. 1103 * 1104 * <code>Message.obj</code> will contain an AsyncResult. 1105 * <code>obj.result</code> will be an "MmiCode" object 1106 */ registerForMmiComplete(Handler h, int what, Object obj)1107 public void registerForMmiComplete(Handler h, int what, Object obj) { 1108 checkCorrectThread(h); 1109 1110 mMmiCompleteRegistrants.addUnique(h, what, obj); 1111 } 1112 1113 /** 1114 * Unregisters for MMI complete notification. 1115 * Extraneous calls are tolerated silently 1116 */ unregisterForMmiComplete(Handler h)1117 public void unregisterForMmiComplete(Handler h) { 1118 checkCorrectThread(h); 1119 1120 mMmiCompleteRegistrants.remove(h); 1121 } 1122 1123 /** 1124 * Registration point for Sim records loaded 1125 * @param h handler to notify 1126 * @param what what code of message when delivered 1127 * @param obj placed in Message.obj 1128 */ registerForSimRecordsLoaded(Handler h, int what, Object obj)1129 public void registerForSimRecordsLoaded(Handler h, int what, Object obj) { 1130 } 1131 1132 /** 1133 * Unregister for notifications for Sim records loaded 1134 * @param h Handler to be removed from the registrant list. 1135 */ unregisterForSimRecordsLoaded(Handler h)1136 public void unregisterForSimRecordsLoaded(Handler h) { 1137 } 1138 1139 /** 1140 * Register for TTY mode change notifications from the network. 1141 * Message.obj will contain an AsyncResult. 1142 * AsyncResult.result will be an Integer containing new mode. 1143 * 1144 * @param h Handler that receives the notification message. 1145 * @param what User-defined message code. 1146 * @param obj User object. 1147 */ registerForTtyModeReceived(Handler h, int what, Object obj)1148 public void registerForTtyModeReceived(Handler h, int what, Object obj) { 1149 } 1150 1151 /** 1152 * Unregisters for TTY mode change notifications. 1153 * Extraneous calls are tolerated silently 1154 * 1155 * @param h Handler to be removed from the registrant list. 1156 */ unregisterForTtyModeReceived(Handler h)1157 public void unregisterForTtyModeReceived(Handler h) { 1158 } 1159 1160 /** 1161 * Switches network selection mode to "automatic", re-scanning and 1162 * re-selecting a network if appropriate. 1163 * 1164 * @param response The message to dispatch when the network selection 1165 * is complete. 1166 * 1167 * @see #selectNetworkManually(OperatorInfo, boolean, android.os.Message) 1168 */ setNetworkSelectionModeAutomatic(Message response)1169 public void setNetworkSelectionModeAutomatic(Message response) { 1170 Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic, querying current mode"); 1171 // we don't want to do this unecesarily - it acutally causes 1172 // the radio to repeate network selection and is costly 1173 // first check if we're already in automatic mode 1174 Message msg = obtainMessage(EVENT_CHECK_FOR_NETWORK_AUTOMATIC); 1175 msg.obj = response; 1176 mCi.getNetworkSelectionMode(msg); 1177 } 1178 onCheckForNetworkSelectionModeAutomatic(Message fromRil)1179 private void onCheckForNetworkSelectionModeAutomatic(Message fromRil) { 1180 AsyncResult ar = (AsyncResult)fromRil.obj; 1181 Message response = (Message)ar.userObj; 1182 boolean doAutomatic = true; 1183 if (ar.exception == null && ar.result != null) { 1184 try { 1185 int[] modes = (int[])ar.result; 1186 if (modes[0] == 0) { 1187 // already confirmed to be in automatic mode - don't resend 1188 doAutomatic = false; 1189 } 1190 } catch (Exception e) { 1191 // send the setting on error 1192 } 1193 } 1194 1195 // wrap the response message in our own message along with 1196 // an empty string (to indicate automatic selection) for the 1197 // operator's id. 1198 NetworkSelectMessage nsm = new NetworkSelectMessage(); 1199 nsm.message = response; 1200 nsm.operatorNumeric = ""; 1201 nsm.operatorAlphaLong = ""; 1202 nsm.operatorAlphaShort = ""; 1203 1204 if (doAutomatic) { 1205 Message msg = obtainMessage(EVENT_SET_NETWORK_AUTOMATIC_COMPLETE, nsm); 1206 mCi.setNetworkSelectionModeAutomatic(msg); 1207 } else { 1208 Rlog.d(LOG_TAG, "setNetworkSelectionModeAutomatic - already auto, ignoring"); 1209 ar.userObj = nsm; 1210 handleSetSelectNetwork(ar); 1211 } 1212 1213 updateSavedNetworkOperator(nsm); 1214 } 1215 1216 /** 1217 * Query the radio for the current network selection mode. 1218 * 1219 * Return values: 1220 * 0 - automatic. 1221 * 1 - manual. 1222 */ getNetworkSelectionMode(Message message)1223 public void getNetworkSelectionMode(Message message) { 1224 mCi.getNetworkSelectionMode(message); 1225 } 1226 getClientRequestStats()1227 public List<ClientRequestStats> getClientRequestStats() { 1228 return mCi.getClientRequestStats(); 1229 } 1230 1231 /** 1232 * Manually selects a network. <code>response</code> is 1233 * dispatched when this is complete. <code>response.obj</code> will be 1234 * an AsyncResult, and <code>response.obj.exception</code> will be non-null 1235 * on failure. 1236 * 1237 * @see #setNetworkSelectionModeAutomatic(Message) 1238 */ selectNetworkManually(OperatorInfo network, boolean persistSelection, Message response)1239 public void selectNetworkManually(OperatorInfo network, boolean persistSelection, 1240 Message response) { 1241 // wrap the response message in our own message along with 1242 // the operator's id. 1243 NetworkSelectMessage nsm = new NetworkSelectMessage(); 1244 nsm.message = response; 1245 nsm.operatorNumeric = network.getOperatorNumeric(); 1246 nsm.operatorAlphaLong = network.getOperatorAlphaLong(); 1247 nsm.operatorAlphaShort = network.getOperatorAlphaShort(); 1248 1249 Message msg = obtainMessage(EVENT_SET_NETWORK_MANUAL_COMPLETE, nsm); 1250 mCi.setNetworkSelectionModeManual(network.getOperatorNumeric(), msg); 1251 1252 if (persistSelection) { 1253 updateSavedNetworkOperator(nsm); 1254 } else { 1255 clearSavedNetworkSelection(); 1256 } 1257 } 1258 1259 /** 1260 * Registration point for emergency call/callback mode start. Message.obj is AsyncResult and 1261 * Message.obj.result will be Integer indicating start of call by value 1 or end of call by 1262 * value 0 1263 * @param h handler to notify 1264 * @param what what code of message when delivered 1265 * @param obj placed in Message.obj.userObj 1266 */ registerForEmergencyCallToggle(Handler h, int what, Object obj)1267 public void registerForEmergencyCallToggle(Handler h, int what, Object obj) { 1268 Registrant r = new Registrant(h, what, obj); 1269 mEmergencyCallToggledRegistrants.add(r); 1270 } 1271 unregisterForEmergencyCallToggle(Handler h)1272 public void unregisterForEmergencyCallToggle(Handler h) { 1273 mEmergencyCallToggledRegistrants.remove(h); 1274 } 1275 updateSavedNetworkOperator(NetworkSelectMessage nsm)1276 private void updateSavedNetworkOperator(NetworkSelectMessage nsm) { 1277 int subId = getSubId(); 1278 if (SubscriptionManager.isValidSubscriptionId(subId)) { 1279 // open the shared preferences editor, and write the value. 1280 // nsm.operatorNumeric is "" if we're in automatic.selection. 1281 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 1282 SharedPreferences.Editor editor = sp.edit(); 1283 editor.putString(NETWORK_SELECTION_KEY + subId, nsm.operatorNumeric); 1284 editor.putString(NETWORK_SELECTION_NAME_KEY + subId, nsm.operatorAlphaLong); 1285 editor.putString(NETWORK_SELECTION_SHORT_KEY + subId, nsm.operatorAlphaShort); 1286 1287 // commit and log the result. 1288 if (!editor.commit()) { 1289 Rlog.e(LOG_TAG, "failed to commit network selection preference"); 1290 } 1291 } else { 1292 Rlog.e(LOG_TAG, "Cannot update network selection preference due to invalid subId " + 1293 subId); 1294 } 1295 } 1296 1297 /** 1298 * Used to track the settings upon completion of the network change. 1299 */ handleSetSelectNetwork(AsyncResult ar)1300 private void handleSetSelectNetwork(AsyncResult ar) { 1301 // look for our wrapper within the asyncresult, skip the rest if it 1302 // is null. 1303 if (!(ar.userObj instanceof NetworkSelectMessage)) { 1304 Rlog.e(LOG_TAG, "unexpected result from user object."); 1305 return; 1306 } 1307 1308 NetworkSelectMessage nsm = (NetworkSelectMessage) ar.userObj; 1309 1310 // found the object, now we send off the message we had originally 1311 // attached to the request. 1312 if (nsm.message != null) { 1313 AsyncResult.forMessage(nsm.message, ar.result, ar.exception); 1314 nsm.message.sendToTarget(); 1315 } 1316 } 1317 1318 /** 1319 * Method to retrieve the saved operator from the Shared Preferences 1320 */ getSavedNetworkSelection()1321 private OperatorInfo getSavedNetworkSelection() { 1322 // open the shared preferences and search with our key. 1323 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 1324 String numeric = sp.getString(NETWORK_SELECTION_KEY + getSubId(), ""); 1325 String name = sp.getString(NETWORK_SELECTION_NAME_KEY + getSubId(), ""); 1326 String shrt = sp.getString(NETWORK_SELECTION_SHORT_KEY + getSubId(), ""); 1327 return new OperatorInfo(name, shrt, numeric); 1328 } 1329 1330 /** 1331 * Clears the saved network selection. 1332 */ clearSavedNetworkSelection()1333 private void clearSavedNetworkSelection() { 1334 // open the shared preferences and search with our key. 1335 PreferenceManager.getDefaultSharedPreferences(getContext()).edit(). 1336 remove(NETWORK_SELECTION_KEY + getSubId()). 1337 remove(NETWORK_SELECTION_NAME_KEY + getSubId()). 1338 remove(NETWORK_SELECTION_SHORT_KEY + getSubId()).commit(); 1339 } 1340 1341 /** 1342 * Method to restore the previously saved operator id, or reset to 1343 * automatic selection, all depending upon the value in the shared 1344 * preferences. 1345 */ restoreSavedNetworkSelection(Message response)1346 private void restoreSavedNetworkSelection(Message response) { 1347 // retrieve the operator 1348 OperatorInfo networkSelection = getSavedNetworkSelection(); 1349 1350 // set to auto if the id is empty, otherwise select the network. 1351 if (networkSelection == null || TextUtils.isEmpty(networkSelection.getOperatorNumeric())) { 1352 setNetworkSelectionModeAutomatic(response); 1353 } else { 1354 selectNetworkManually(networkSelection, true, response); 1355 } 1356 } 1357 1358 /** 1359 * Saves CLIR setting so that we can re-apply it as necessary 1360 * (in case the RIL resets it across reboots). 1361 */ saveClirSetting(int commandInterfaceCLIRMode)1362 public void saveClirSetting(int commandInterfaceCLIRMode) { 1363 // Open the shared preferences editor, and write the value. 1364 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 1365 SharedPreferences.Editor editor = sp.edit(); 1366 editor.putInt(CLIR_KEY + getPhoneId(), commandInterfaceCLIRMode); 1367 Rlog.i(LOG_TAG, "saveClirSetting: " + CLIR_KEY + getPhoneId() + "=" + 1368 commandInterfaceCLIRMode); 1369 1370 // Commit and log the result. 1371 if (!editor.commit()) { 1372 Rlog.e(LOG_TAG, "Failed to commit CLIR preference"); 1373 } 1374 } 1375 1376 /** 1377 * For unit tests; don't send notifications to "Phone" 1378 * mailbox registrants if true. 1379 */ setUnitTestMode(boolean f)1380 private void setUnitTestMode(boolean f) { 1381 mUnitTestMode = f; 1382 } 1383 1384 /** 1385 * @return true If unit test mode is enabled 1386 */ getUnitTestMode()1387 public boolean getUnitTestMode() { 1388 return mUnitTestMode; 1389 } 1390 1391 /** 1392 * To be invoked when a voice call Connection disconnects. 1393 * 1394 * Subclasses of Phone probably want to replace this with a 1395 * version scoped to their packages 1396 */ notifyDisconnectP(Connection cn)1397 protected void notifyDisconnectP(Connection cn) { 1398 AsyncResult ar = new AsyncResult(null, cn, null); 1399 mDisconnectRegistrants.notifyRegistrants(ar); 1400 } 1401 1402 /** 1403 * Register for ServiceState changed. 1404 * Message.obj will contain an AsyncResult. 1405 * AsyncResult.result will be a ServiceState instance 1406 */ registerForServiceStateChanged( Handler h, int what, Object obj)1407 public void registerForServiceStateChanged( 1408 Handler h, int what, Object obj) { 1409 checkCorrectThread(h); 1410 1411 mServiceStateRegistrants.add(h, what, obj); 1412 } 1413 1414 /** 1415 * Unregisters for ServiceStateChange notification. 1416 * Extraneous calls are tolerated silently 1417 */ unregisterForServiceStateChanged(Handler h)1418 public void unregisterForServiceStateChanged(Handler h) { 1419 mServiceStateRegistrants.remove(h); 1420 } 1421 1422 /** 1423 * Notifies when out-band ringback tone is needed.<p> 1424 * 1425 * Messages received from this: 1426 * Message.obj will be an AsyncResult 1427 * AsyncResult.userObj = obj 1428 * AsyncResult.result = boolean, true to start play ringback tone 1429 * and false to stop. <p> 1430 */ registerForRingbackTone(Handler h, int what, Object obj)1431 public void registerForRingbackTone(Handler h, int what, Object obj) { 1432 mCi.registerForRingbackTone(h, what, obj); 1433 } 1434 1435 /** 1436 * Unregisters for ringback tone notification. 1437 */ unregisterForRingbackTone(Handler h)1438 public void unregisterForRingbackTone(Handler h) { 1439 mCi.unregisterForRingbackTone(h); 1440 } 1441 1442 /** 1443 * Notifies when out-band on-hold tone is needed.<p> 1444 * 1445 * Messages received from this: 1446 * Message.obj will be an AsyncResult 1447 * AsyncResult.userObj = obj 1448 * AsyncResult.result = boolean, true to start play on-hold tone 1449 * and false to stop. <p> 1450 */ registerForOnHoldTone(Handler h, int what, Object obj)1451 public void registerForOnHoldTone(Handler h, int what, Object obj) { 1452 } 1453 1454 /** 1455 * Unregisters for on-hold tone notification. 1456 */ unregisterForOnHoldTone(Handler h)1457 public void unregisterForOnHoldTone(Handler h) { 1458 } 1459 1460 /** 1461 * Registers the handler to reset the uplink mute state to get 1462 * uplink audio. 1463 */ registerForResendIncallMute(Handler h, int what, Object obj)1464 public void registerForResendIncallMute(Handler h, int what, Object obj) { 1465 mCi.registerForResendIncallMute(h, what, obj); 1466 } 1467 1468 /** 1469 * Unregisters for resend incall mute notifications. 1470 */ unregisterForResendIncallMute(Handler h)1471 public void unregisterForResendIncallMute(Handler h) { 1472 mCi.unregisterForResendIncallMute(h); 1473 } 1474 1475 /** 1476 * Enables or disables echo suppression. 1477 */ setEchoSuppressionEnabled()1478 public void setEchoSuppressionEnabled() { 1479 // no need for regular phone 1480 } 1481 1482 /** 1483 * Subclasses of Phone probably want to replace this with a 1484 * version scoped to their packages 1485 */ notifyServiceStateChangedP(ServiceState ss)1486 protected void notifyServiceStateChangedP(ServiceState ss) { 1487 AsyncResult ar = new AsyncResult(null, ss, null); 1488 mServiceStateRegistrants.notifyRegistrants(ar); 1489 1490 mNotifier.notifyServiceState(this); 1491 } 1492 1493 /** 1494 * If this is a simulated phone interface, returns a SimulatedRadioControl. 1495 * @return SimulatedRadioControl if this is a simulated interface; 1496 * otherwise, null. 1497 */ getSimulatedRadioControl()1498 public SimulatedRadioControl getSimulatedRadioControl() { 1499 return mSimulatedRadioControl; 1500 } 1501 1502 /** 1503 * Verifies the current thread is the same as the thread originally 1504 * used in the initialization of this instance. Throws RuntimeException 1505 * if not. 1506 * 1507 * @exception RuntimeException if the current thread is not 1508 * the thread that originally obtained this Phone instance. 1509 */ checkCorrectThread(Handler h)1510 private void checkCorrectThread(Handler h) { 1511 if (h.getLooper() != mLooper) { 1512 throw new RuntimeException( 1513 "com.android.internal.telephony.Phone must be used from within one thread"); 1514 } 1515 } 1516 1517 /** 1518 * Set the properties by matching the carrier string in 1519 * a string-array resource 1520 */ getLocaleFromCarrierProperties(Context ctx)1521 private static Locale getLocaleFromCarrierProperties(Context ctx) { 1522 String carrier = SystemProperties.get("ro.carrier"); 1523 1524 if (null == carrier || 0 == carrier.length() || "unknown".equals(carrier)) { 1525 return null; 1526 } 1527 1528 CharSequence[] carrierLocales = ctx.getResources().getTextArray(R.array.carrier_properties); 1529 1530 for (int i = 0; i < carrierLocales.length; i+=3) { 1531 String c = carrierLocales[i].toString(); 1532 if (carrier.equals(c)) { 1533 return Locale.forLanguageTag(carrierLocales[i + 1].toString().replace('_', '-')); 1534 } 1535 } 1536 1537 return null; 1538 } 1539 1540 /** 1541 * Get current coarse-grained voice call state. 1542 * Use {@link #registerForPreciseCallStateChanged(Handler, int, Object) 1543 * registerForPreciseCallStateChanged()} for change notification. <p> 1544 * If the phone has an active call and call waiting occurs, 1545 * then the phone state is RINGING not OFFHOOK 1546 * <strong>Note:</strong> 1547 * This registration point provides notification of finer-grained 1548 * changes.<p> 1549 */ getState()1550 public abstract PhoneConstants.State getState(); 1551 1552 /** 1553 * Retrieves the IccFileHandler of the Phone instance 1554 */ getIccFileHandler()1555 public IccFileHandler getIccFileHandler(){ 1556 UiccCardApplication uiccApplication = mUiccApplication.get(); 1557 IccFileHandler fh; 1558 1559 if (uiccApplication == null) { 1560 Rlog.d(LOG_TAG, "getIccFileHandler: uiccApplication == null, return null"); 1561 fh = null; 1562 } else { 1563 fh = uiccApplication.getIccFileHandler(); 1564 } 1565 1566 Rlog.d(LOG_TAG, "getIccFileHandler: fh=" + fh); 1567 return fh; 1568 } 1569 1570 /* 1571 * Retrieves the Handler of the Phone instance 1572 */ getHandler()1573 public Handler getHandler() { 1574 return this; 1575 } 1576 1577 /** 1578 * Update the phone object if the voice radio technology has changed 1579 * 1580 * @param voiceRadioTech The new voice radio technology 1581 */ updatePhoneObject(int voiceRadioTech)1582 public void updatePhoneObject(int voiceRadioTech) { 1583 } 1584 1585 /** 1586 * Retrieves the ServiceStateTracker of the phone instance. 1587 */ getServiceStateTracker()1588 public ServiceStateTracker getServiceStateTracker() { 1589 return null; 1590 } 1591 1592 /** 1593 * Get call tracker 1594 */ getCallTracker()1595 public CallTracker getCallTracker() { 1596 return null; 1597 } 1598 1599 /** 1600 * Update voice activation state 1601 */ setVoiceActivationState(int state)1602 public void setVoiceActivationState(int state) { 1603 mSimActivationTracker.setVoiceActivationState(state); 1604 } 1605 /** 1606 * Update data activation state 1607 */ setDataActivationState(int state)1608 public void setDataActivationState(int state) { 1609 mSimActivationTracker.setDataActivationState(state); 1610 } 1611 1612 /** 1613 * Returns voice activation state 1614 */ getVoiceActivationState()1615 public int getVoiceActivationState() { 1616 return mSimActivationTracker.getVoiceActivationState(); 1617 } 1618 /** 1619 * Returns data activation state 1620 */ getDataActivationState()1621 public int getDataActivationState() { 1622 return mSimActivationTracker.getDataActivationState(); 1623 } 1624 1625 /** 1626 * Update voice mail count related fields and notify listeners 1627 */ updateVoiceMail()1628 public void updateVoiceMail() { 1629 Rlog.e(LOG_TAG, "updateVoiceMail() should be overridden"); 1630 } 1631 getCurrentUiccAppType()1632 public AppType getCurrentUiccAppType() { 1633 UiccCardApplication currentApp = mUiccApplication.get(); 1634 if (currentApp != null) { 1635 return currentApp.getType(); 1636 } 1637 return AppType.APPTYPE_UNKNOWN; 1638 } 1639 1640 /** 1641 * Returns the ICC card interface for this phone, or null 1642 * if not applicable to underlying technology. 1643 */ getIccCard()1644 public IccCard getIccCard() { 1645 return null; 1646 //throw new Exception("getIccCard Shouldn't be called from Phone"); 1647 } 1648 1649 /** 1650 * Retrieves the serial number of the ICC, if applicable. Returns only the decimal digits before 1651 * the first hex digit in the ICC ID. 1652 */ getIccSerialNumber()1653 public String getIccSerialNumber() { 1654 IccRecords r = mIccRecords.get(); 1655 return (r != null) ? r.getIccId() : null; 1656 } 1657 1658 /** 1659 * Retrieves the full serial number of the ICC (including hex digits), if applicable. 1660 */ getFullIccSerialNumber()1661 public String getFullIccSerialNumber() { 1662 IccRecords r = mIccRecords.get(); 1663 return (r != null) ? r.getFullIccId() : null; 1664 } 1665 1666 /** 1667 * Returns SIM record load state. Use 1668 * <code>getSimCard().registerForReady()</code> for change notification. 1669 * 1670 * @return true if records from the SIM have been loaded and are 1671 * available (if applicable). If not applicable to the underlying 1672 * technology, returns true as well. 1673 */ getIccRecordsLoaded()1674 public boolean getIccRecordsLoaded() { 1675 IccRecords r = mIccRecords.get(); 1676 return (r != null) ? r.getRecordsLoaded() : false; 1677 } 1678 1679 /** 1680 * @param workSource calling WorkSource 1681 * @return all available cell information or null if none. 1682 */ getAllCellInfo(WorkSource workSource)1683 public List<CellInfo> getAllCellInfo(WorkSource workSource) { 1684 List<CellInfo> cellInfoList = getServiceStateTracker().getAllCellInfo(workSource); 1685 return privatizeCellInfoList(cellInfoList); 1686 } 1687 getCellLocation()1688 public CellLocation getCellLocation() { 1689 return getCellLocation(null); 1690 } 1691 1692 /** 1693 * Clear CDMA base station lat/long values if location setting is disabled. 1694 * @param cellInfoList the original cell info list from the RIL 1695 * @return the original list with CDMA lat/long cleared if necessary 1696 */ privatizeCellInfoList(List<CellInfo> cellInfoList)1697 private List<CellInfo> privatizeCellInfoList(List<CellInfo> cellInfoList) { 1698 if (cellInfoList == null) return null; 1699 int mode = Settings.Secure.getInt(getContext().getContentResolver(), 1700 Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF); 1701 if (mode == Settings.Secure.LOCATION_MODE_OFF) { 1702 ArrayList<CellInfo> privateCellInfoList = new ArrayList<CellInfo>(cellInfoList.size()); 1703 // clear lat/lon values for location privacy 1704 for (CellInfo c : cellInfoList) { 1705 if (c instanceof CellInfoCdma) { 1706 CellInfoCdma cellInfoCdma = (CellInfoCdma) c; 1707 CellIdentityCdma cellIdentity = cellInfoCdma.getCellIdentity(); 1708 CellIdentityCdma maskedCellIdentity = new CellIdentityCdma( 1709 cellIdentity.getNetworkId(), 1710 cellIdentity.getSystemId(), 1711 cellIdentity.getBasestationId(), 1712 Integer.MAX_VALUE, Integer.MAX_VALUE); 1713 CellInfoCdma privateCellInfoCdma = new CellInfoCdma(cellInfoCdma); 1714 privateCellInfoCdma.setCellIdentity(maskedCellIdentity); 1715 privateCellInfoList.add(privateCellInfoCdma); 1716 } else { 1717 privateCellInfoList.add(c); 1718 } 1719 } 1720 cellInfoList = privateCellInfoList; 1721 } 1722 return cellInfoList; 1723 } 1724 1725 /** 1726 * Sets the minimum time in milli-seconds between {@link PhoneStateListener#onCellInfoChanged 1727 * PhoneStateListener.onCellInfoChanged} will be invoked. 1728 * 1729 * The default, 0, means invoke onCellInfoChanged when any of the reported 1730 * information changes. Setting the value to INT_MAX(0x7fffffff) means never issue 1731 * A onCellInfoChanged. 1732 * 1733 * @param rateInMillis the rate 1734 * @param workSource calling WorkSource 1735 */ setCellInfoListRate(int rateInMillis, WorkSource workSource)1736 public void setCellInfoListRate(int rateInMillis, WorkSource workSource) { 1737 mCi.setCellInfoListRate(rateInMillis, null, workSource); 1738 } 1739 1740 /** 1741 * Get voice message waiting indicator status. No change notification 1742 * available on this interface. Use PhoneStateNotifier or similar instead. 1743 * 1744 * @return true if there is a voice message waiting 1745 */ getMessageWaitingIndicator()1746 public boolean getMessageWaitingIndicator() { 1747 return mVmCount != 0; 1748 } 1749 getCallForwardingIndicatorFromSharedPref()1750 private int getCallForwardingIndicatorFromSharedPref() { 1751 int status = IccRecords.CALL_FORWARDING_STATUS_DISABLED; 1752 int subId = getSubId(); 1753 if (SubscriptionManager.isValidSubscriptionId(subId)) { 1754 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 1755 status = sp.getInt(CF_STATUS + subId, IccRecords.CALL_FORWARDING_STATUS_UNKNOWN); 1756 Rlog.d(LOG_TAG, "getCallForwardingIndicatorFromSharedPref: for subId " + subId + "= " + 1757 status); 1758 // Check for old preference if status is UNKNOWN for current subId. This part of the 1759 // code is needed only when upgrading from M to N. 1760 if (status == IccRecords.CALL_FORWARDING_STATUS_UNKNOWN) { 1761 String subscriberId = sp.getString(CF_ID, null); 1762 if (subscriberId != null) { 1763 String currentSubscriberId = getSubscriberId(); 1764 1765 if (subscriberId.equals(currentSubscriberId)) { 1766 // get call forwarding status from preferences 1767 status = sp.getInt(CF_STATUS, IccRecords.CALL_FORWARDING_STATUS_DISABLED); 1768 setCallForwardingIndicatorInSharedPref( 1769 status == IccRecords.CALL_FORWARDING_STATUS_ENABLED ? true : false); 1770 Rlog.d(LOG_TAG, "getCallForwardingIndicatorFromSharedPref: " + status); 1771 } else { 1772 Rlog.d(LOG_TAG, "getCallForwardingIndicatorFromSharedPref: returning " + 1773 "DISABLED as status for matching subscriberId not found"); 1774 } 1775 1776 // get rid of old preferences. 1777 SharedPreferences.Editor editor = sp.edit(); 1778 editor.remove(CF_ID); 1779 editor.remove(CF_STATUS); 1780 editor.apply(); 1781 } 1782 } 1783 } else { 1784 Rlog.e(LOG_TAG, "getCallForwardingIndicatorFromSharedPref: invalid subId " + subId); 1785 } 1786 return status; 1787 } 1788 setCallForwardingIndicatorInSharedPref(boolean enable)1789 private void setCallForwardingIndicatorInSharedPref(boolean enable) { 1790 int status = enable ? IccRecords.CALL_FORWARDING_STATUS_ENABLED : 1791 IccRecords.CALL_FORWARDING_STATUS_DISABLED; 1792 int subId = getSubId(); 1793 Rlog.i(LOG_TAG, "setCallForwardingIndicatorInSharedPref: Storing status = " + status + 1794 " in pref " + CF_STATUS + subId); 1795 1796 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 1797 SharedPreferences.Editor editor = sp.edit(); 1798 editor.putInt(CF_STATUS + subId, status); 1799 editor.apply(); 1800 } 1801 setVoiceCallForwardingFlag(int line, boolean enable, String number)1802 public void setVoiceCallForwardingFlag(int line, boolean enable, String number) { 1803 setCallForwardingIndicatorInSharedPref(enable); 1804 IccRecords r = mIccRecords.get(); 1805 if (r != null) { 1806 r.setVoiceCallForwardingFlag(line, enable, number); 1807 } 1808 } 1809 setVoiceCallForwardingFlag(IccRecords r, int line, boolean enable, String number)1810 protected void setVoiceCallForwardingFlag(IccRecords r, int line, boolean enable, 1811 String number) { 1812 setCallForwardingIndicatorInSharedPref(enable); 1813 r.setVoiceCallForwardingFlag(line, enable, number); 1814 } 1815 1816 /** 1817 * Get voice call forwarding indicator status. No change notification 1818 * available on this interface. Use PhoneStateNotifier or similar instead. 1819 * 1820 * @return true if there is a voice call forwarding 1821 */ getCallForwardingIndicator()1822 public boolean getCallForwardingIndicator() { 1823 if (getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) { 1824 Rlog.e(LOG_TAG, "getCallForwardingIndicator: not possible in CDMA"); 1825 return false; 1826 } 1827 IccRecords r = mIccRecords.get(); 1828 int callForwardingIndicator = IccRecords.CALL_FORWARDING_STATUS_UNKNOWN; 1829 if (r != null) { 1830 callForwardingIndicator = r.getVoiceCallForwardingFlag(); 1831 } 1832 if (callForwardingIndicator == IccRecords.CALL_FORWARDING_STATUS_UNKNOWN) { 1833 callForwardingIndicator = getCallForwardingIndicatorFromSharedPref(); 1834 } 1835 Rlog.v(LOG_TAG, "getCallForwardingIndicator: iccForwardingFlag=" + (r != null 1836 ? r.getVoiceCallForwardingFlag() : "null") + ", sharedPrefFlag=" 1837 + getCallForwardingIndicatorFromSharedPref()); 1838 return (callForwardingIndicator == IccRecords.CALL_FORWARDING_STATUS_ENABLED); 1839 } 1840 getCarrierSignalAgent()1841 public CarrierSignalAgent getCarrierSignalAgent() { 1842 return mCarrierSignalAgent; 1843 } 1844 getCarrierActionAgent()1845 public CarrierActionAgent getCarrierActionAgent() { 1846 return mCarrierActionAgent; 1847 } 1848 1849 /** 1850 * Query the CDMA roaming preference setting 1851 * 1852 * @param response is callback message to report one of CDMA_RM_* 1853 */ queryCdmaRoamingPreference(Message response)1854 public void queryCdmaRoamingPreference(Message response) { 1855 mCi.queryCdmaRoamingPreference(response); 1856 } 1857 1858 /** 1859 * Get current signal strength. No change notification available on this 1860 * interface. Use <code>PhoneStateNotifier</code> or an equivalent. 1861 * An ASU is 0-31 or -1 if unknown (for GSM, dBm = -113 - 2 * asu). 1862 * The following special values are defined:</p> 1863 * <ul><li>0 means "-113 dBm or less".</li> 1864 * <li>31 means "-51 dBm or greater".</li></ul> 1865 * 1866 * @return Current signal strength as SignalStrength 1867 */ getSignalStrength()1868 public SignalStrength getSignalStrength() { 1869 ServiceStateTracker sst = getServiceStateTracker(); 1870 if (sst == null) { 1871 return new SignalStrength(); 1872 } else { 1873 return sst.getSignalStrength(); 1874 } 1875 } 1876 1877 /** 1878 * @return true, if the device is in a state where both voice and data 1879 * are supported simultaneously. This can change based on location or network condition. 1880 */ isConcurrentVoiceAndDataAllowed()1881 public boolean isConcurrentVoiceAndDataAllowed() { 1882 ServiceStateTracker sst = getServiceStateTracker(); 1883 return sst == null ? false : sst.isConcurrentVoiceAndDataAllowed(); 1884 } 1885 1886 /** 1887 * Requests to set the CDMA roaming preference 1888 * @param cdmaRoamingType one of CDMA_RM_* 1889 * @param response is callback message 1890 */ setCdmaRoamingPreference(int cdmaRoamingType, Message response)1891 public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) { 1892 mCi.setCdmaRoamingPreference(cdmaRoamingType, response); 1893 } 1894 1895 /** 1896 * Requests to set the CDMA subscription mode 1897 * @param cdmaSubscriptionType one of CDMA_SUBSCRIPTION_* 1898 * @param response is callback message 1899 */ setCdmaSubscription(int cdmaSubscriptionType, Message response)1900 public void setCdmaSubscription(int cdmaSubscriptionType, Message response) { 1901 mCi.setCdmaSubscriptionSource(cdmaSubscriptionType, response); 1902 } 1903 1904 /** 1905 * Requests to set the preferred network type for searching and registering 1906 * (CS/PS domain, RAT, and operation mode) 1907 * @param networkType one of NT_*_TYPE 1908 * @param response is callback message 1909 */ setPreferredNetworkType(int networkType, Message response)1910 public void setPreferredNetworkType(int networkType, Message response) { 1911 // Only set preferred network types to that which the modem supports 1912 int modemRaf = getRadioAccessFamily(); 1913 int rafFromType = RadioAccessFamily.getRafFromNetworkType(networkType); 1914 1915 if (modemRaf == RadioAccessFamily.RAF_UNKNOWN 1916 || rafFromType == RadioAccessFamily.RAF_UNKNOWN) { 1917 Rlog.d(LOG_TAG, "setPreferredNetworkType: Abort, unknown RAF: " 1918 + modemRaf + " " + rafFromType); 1919 if (response != null) { 1920 CommandException ex; 1921 1922 ex = new CommandException(CommandException.Error.GENERIC_FAILURE); 1923 AsyncResult.forMessage(response, null, ex); 1924 response.sendToTarget(); 1925 } 1926 return; 1927 } 1928 1929 int filteredRaf = (rafFromType & modemRaf); 1930 int filteredType = RadioAccessFamily.getNetworkTypeFromRaf(filteredRaf); 1931 1932 Rlog.d(LOG_TAG, "setPreferredNetworkType: networkType = " + networkType 1933 + " modemRaf = " + modemRaf 1934 + " rafFromType = " + rafFromType 1935 + " filteredType = " + filteredType); 1936 1937 mCi.setPreferredNetworkType(filteredType, response); 1938 } 1939 1940 /** 1941 * Query the preferred network type setting 1942 * 1943 * @param response is callback message to report one of NT_*_TYPE 1944 */ getPreferredNetworkType(Message response)1945 public void getPreferredNetworkType(Message response) { 1946 mCi.getPreferredNetworkType(response); 1947 } 1948 1949 /** 1950 * Gets the default SMSC address. 1951 * 1952 * @param result Callback message contains the SMSC address. 1953 */ getSmscAddress(Message result)1954 public void getSmscAddress(Message result) { 1955 mCi.getSmscAddress(result); 1956 } 1957 1958 /** 1959 * Sets the default SMSC address. 1960 * 1961 * @param address new SMSC address 1962 * @param result Callback message is empty on completion 1963 */ setSmscAddress(String address, Message result)1964 public void setSmscAddress(String address, Message result) { 1965 mCi.setSmscAddress(address, result); 1966 } 1967 1968 /** 1969 * setTTYMode 1970 * sets a TTY mode option. 1971 * @param ttyMode is a one of the following: 1972 * - {@link com.android.internal.telephony.Phone#TTY_MODE_OFF} 1973 * - {@link com.android.internal.telephony.Phone#TTY_MODE_FULL} 1974 * - {@link com.android.internal.telephony.Phone#TTY_MODE_HCO} 1975 * - {@link com.android.internal.telephony.Phone#TTY_MODE_VCO} 1976 * @param onComplete a callback message when the action is completed 1977 */ setTTYMode(int ttyMode, Message onComplete)1978 public void setTTYMode(int ttyMode, Message onComplete) { 1979 mCi.setTTYMode(ttyMode, onComplete); 1980 } 1981 1982 /** 1983 * setUiTTYMode 1984 * sets a TTY mode option. 1985 * @param ttyMode is a one of the following: 1986 * - {@link com.android.internal.telephony.Phone#TTY_MODE_OFF} 1987 * - {@link com.android.internal.telephony.Phone#TTY_MODE_FULL} 1988 * - {@link com.android.internal.telephony.Phone#TTY_MODE_HCO} 1989 * - {@link com.android.internal.telephony.Phone#TTY_MODE_VCO} 1990 * @param onComplete a callback message when the action is completed 1991 */ setUiTTYMode(int uiTtyMode, Message onComplete)1992 public void setUiTTYMode(int uiTtyMode, Message onComplete) { 1993 Rlog.d(LOG_TAG, "unexpected setUiTTYMode method call"); 1994 } 1995 1996 /** 1997 * queryTTYMode 1998 * query the status of the TTY mode 1999 * 2000 * @param onComplete a callback message when the action is completed. 2001 */ queryTTYMode(Message onComplete)2002 public void queryTTYMode(Message onComplete) { 2003 mCi.queryTTYMode(onComplete); 2004 } 2005 2006 /** 2007 * Enable or disable enhanced Voice Privacy (VP). If enhanced VP is 2008 * disabled, normal VP is enabled. 2009 * 2010 * @param enable whether true or false to enable or disable. 2011 * @param onComplete a callback message when the action is completed. 2012 */ enableEnhancedVoicePrivacy(boolean enable, Message onComplete)2013 public void enableEnhancedVoicePrivacy(boolean enable, Message onComplete) { 2014 } 2015 2016 /** 2017 * Get the currently set Voice Privacy (VP) mode. 2018 * 2019 * @param onComplete a callback message when the action is completed. 2020 */ getEnhancedVoicePrivacy(Message onComplete)2021 public void getEnhancedVoicePrivacy(Message onComplete) { 2022 } 2023 2024 /** 2025 * Assign a specified band for RF configuration. 2026 * 2027 * @param bandMode one of BM_*_BAND 2028 * @param response is callback message 2029 */ setBandMode(int bandMode, Message response)2030 public void setBandMode(int bandMode, Message response) { 2031 mCi.setBandMode(bandMode, response); 2032 } 2033 2034 /** 2035 * Query the list of band mode supported by RF. 2036 * 2037 * @param response is callback message 2038 * ((AsyncResult)response.obj).result is an int[] where int[0] is 2039 * the size of the array and the rest of each element representing 2040 * one available BM_*_BAND 2041 */ queryAvailableBandMode(Message response)2042 public void queryAvailableBandMode(Message response) { 2043 mCi.queryAvailableBandMode(response); 2044 } 2045 2046 /** 2047 * Invokes RIL_REQUEST_OEM_HOOK_RAW on RIL implementation. 2048 * 2049 * @param data The data for the request. 2050 * @param response <strong>On success</strong>, 2051 * (byte[])(((AsyncResult)response.obj).result) 2052 * <strong>On failure</strong>, 2053 * (((AsyncResult)response.obj).result) == null and 2054 * (((AsyncResult)response.obj).exception) being an instance of 2055 * com.android.internal.telephony.gsm.CommandException 2056 * 2057 * @see #invokeOemRilRequestRaw(byte[], android.os.Message) 2058 * @deprecated OEM needs a vendor-extension hal and their apps should use that instead 2059 */ 2060 @Deprecated invokeOemRilRequestRaw(byte[] data, Message response)2061 public void invokeOemRilRequestRaw(byte[] data, Message response) { 2062 mCi.invokeOemRilRequestRaw(data, response); 2063 } 2064 2065 /** 2066 * Invokes RIL_REQUEST_OEM_HOOK_Strings on RIL implementation. 2067 * 2068 * @param strings The strings to make available as the request data. 2069 * @param response <strong>On success</strong>, "response" bytes is 2070 * made available as: 2071 * (String[])(((AsyncResult)response.obj).result). 2072 * <strong>On failure</strong>, 2073 * (((AsyncResult)response.obj).result) == null and 2074 * (((AsyncResult)response.obj).exception) being an instance of 2075 * com.android.internal.telephony.gsm.CommandException 2076 * 2077 * @see #invokeOemRilRequestStrings(java.lang.String[], android.os.Message) 2078 * @deprecated OEM needs a vendor-extension hal and their apps should use that instead 2079 */ 2080 @Deprecated invokeOemRilRequestStrings(String[] strings, Message response)2081 public void invokeOemRilRequestStrings(String[] strings, Message response) { 2082 mCi.invokeOemRilRequestStrings(strings, response); 2083 } 2084 2085 /** 2086 * Read one of the NV items defined in {@link RadioNVItems} / {@code ril_nv_items.h}. 2087 * Used for device configuration by some CDMA operators. 2088 * 2089 * @param itemID the ID of the item to read 2090 * @param response callback message with the String response in the obj field 2091 */ nvReadItem(int itemID, Message response)2092 public void nvReadItem(int itemID, Message response) { 2093 mCi.nvReadItem(itemID, response); 2094 } 2095 2096 /** 2097 * Write one of the NV items defined in {@link RadioNVItems} / {@code ril_nv_items.h}. 2098 * Used for device configuration by some CDMA operators. 2099 * 2100 * @param itemID the ID of the item to read 2101 * @param itemValue the value to write, as a String 2102 * @param response Callback message. 2103 */ nvWriteItem(int itemID, String itemValue, Message response)2104 public void nvWriteItem(int itemID, String itemValue, Message response) { 2105 mCi.nvWriteItem(itemID, itemValue, response); 2106 } 2107 2108 /** 2109 * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage. 2110 * Used for device configuration by some CDMA operators. 2111 * 2112 * @param preferredRoamingList byte array containing the new PRL 2113 * @param response Callback message. 2114 */ nvWriteCdmaPrl(byte[] preferredRoamingList, Message response)2115 public void nvWriteCdmaPrl(byte[] preferredRoamingList, Message response) { 2116 mCi.nvWriteCdmaPrl(preferredRoamingList, response); 2117 } 2118 2119 /** 2120 * Perform the specified type of NV config reset. The radio will be taken offline 2121 * and the device must be rebooted after erasing the NV. Used for device 2122 * configuration by some CDMA operators. 2123 * 2124 * @param resetType reset type: 1: reload NV reset, 2: erase NV reset, 3: factory NV reset 2125 * @param response Callback message. 2126 */ nvResetConfig(int resetType, Message response)2127 public void nvResetConfig(int resetType, Message response) { 2128 mCi.nvResetConfig(resetType, response); 2129 } 2130 notifyDataActivity()2131 public void notifyDataActivity() { 2132 mNotifier.notifyDataActivity(this); 2133 } 2134 notifyMessageWaitingIndicator()2135 private void notifyMessageWaitingIndicator() { 2136 // Do not notify voice mail waiting if device doesn't support voice 2137 if (!mIsVoiceCapable) 2138 return; 2139 2140 // This function is added to send the notification to DefaultPhoneNotifier. 2141 mNotifier.notifyMessageWaitingChanged(this); 2142 } 2143 notifyDataConnection(String reason, String apnType, PhoneConstants.DataState state)2144 public void notifyDataConnection(String reason, String apnType, 2145 PhoneConstants.DataState state) { 2146 mNotifier.notifyDataConnection(this, reason, apnType, state); 2147 } 2148 notifyDataConnection(String reason, String apnType)2149 public void notifyDataConnection(String reason, String apnType) { 2150 mNotifier.notifyDataConnection(this, reason, apnType, getDataConnectionState(apnType)); 2151 } 2152 notifyDataConnection(String reason)2153 public void notifyDataConnection(String reason) { 2154 String types[] = getActiveApnTypes(); 2155 for (String apnType : types) { 2156 mNotifier.notifyDataConnection(this, reason, apnType, getDataConnectionState(apnType)); 2157 } 2158 } 2159 notifyOtaspChanged(int otaspMode)2160 public void notifyOtaspChanged(int otaspMode) { 2161 mNotifier.notifyOtaspChanged(this, otaspMode); 2162 } 2163 notifyVoiceActivationStateChanged(int state)2164 public void notifyVoiceActivationStateChanged(int state) { 2165 mNotifier.notifyVoiceActivationStateChanged(this, state); 2166 } 2167 notifyDataActivationStateChanged(int state)2168 public void notifyDataActivationStateChanged(int state) { 2169 mNotifier.notifyDataActivationStateChanged(this, state); 2170 } 2171 notifySignalStrength()2172 public void notifySignalStrength() { 2173 mNotifier.notifySignalStrength(this); 2174 } 2175 notifyCellInfo(List<CellInfo> cellInfo)2176 public void notifyCellInfo(List<CellInfo> cellInfo) { 2177 mNotifier.notifyCellInfo(this, privatizeCellInfoList(cellInfo)); 2178 } 2179 notifyVoLteServiceStateChanged(VoLteServiceState lteState)2180 public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) { 2181 mNotifier.notifyVoLteServiceStateChanged(this, lteState); 2182 } 2183 2184 /** 2185 * @return true if a mobile originating emergency call is active 2186 */ isInEmergencyCall()2187 public boolean isInEmergencyCall() { 2188 return false; 2189 } 2190 2191 // This property is used to handle phone process crashes, and is the same for CDMA and IMS 2192 // phones getInEcmMode()2193 protected static boolean getInEcmMode() { 2194 return SystemProperties.getBoolean(TelephonyProperties.PROPERTY_INECM_MODE, false); 2195 } 2196 2197 /** 2198 * @return {@code true} if we are in emergency call back mode. This is a period where the phone 2199 * should be using as little power as possible and be ready to receive an incoming call from the 2200 * emergency operator. 2201 */ isInEcm()2202 public boolean isInEcm() { 2203 return mIsPhoneInEcmState; 2204 } 2205 setIsInEcm(boolean isInEcm)2206 public void setIsInEcm(boolean isInEcm) { 2207 setSystemProperty(TelephonyProperties.PROPERTY_INECM_MODE, String.valueOf(isInEcm)); 2208 mIsPhoneInEcmState = isInEcm; 2209 } 2210 getVideoState(Call call)2211 private static int getVideoState(Call call) { 2212 int videoState = VideoProfile.STATE_AUDIO_ONLY; 2213 Connection conn = call.getEarliestConnection(); 2214 if (conn != null) { 2215 videoState = conn.getVideoState(); 2216 } 2217 return videoState; 2218 } 2219 2220 /** 2221 * Determines if the specified call currently is or was at some point a video call, or if it is 2222 * a conference call. 2223 * @param call The call. 2224 * @return {@code true} if the call is or was a video call or is a conference call, 2225 * {@code false} otherwise. 2226 */ isVideoCallOrConference(Call call)2227 private boolean isVideoCallOrConference(Call call) { 2228 if (call.isMultiparty()) { 2229 return true; 2230 } 2231 2232 boolean isDowngradedVideoCall = false; 2233 if (call instanceof ImsPhoneCall) { 2234 ImsPhoneCall imsPhoneCall = (ImsPhoneCall) call; 2235 ImsCall imsCall = imsPhoneCall.getImsCall(); 2236 return imsCall != null && (imsCall.isVideoCall() || 2237 imsCall.wasVideoCall()); 2238 } 2239 return isDowngradedVideoCall; 2240 } 2241 2242 /** 2243 * @return {@code true} if an IMS video call or IMS conference is present, false otherwise. 2244 */ isImsVideoCallOrConferencePresent()2245 public boolean isImsVideoCallOrConferencePresent() { 2246 boolean isPresent = false; 2247 if (mImsPhone != null) { 2248 isPresent = isVideoCallOrConference(mImsPhone.getForegroundCall()) || 2249 isVideoCallOrConference(mImsPhone.getBackgroundCall()) || 2250 isVideoCallOrConference(mImsPhone.getRingingCall()); 2251 } 2252 Rlog.d(LOG_TAG, "isImsVideoCallOrConferencePresent: " + isPresent); 2253 return isPresent; 2254 } 2255 2256 /** 2257 * Return a numerical identifier for the phone radio interface. 2258 * @return PHONE_TYPE_XXX as defined above. 2259 */ getPhoneType()2260 public abstract int getPhoneType(); 2261 2262 /** 2263 * Returns unread voicemail count. This count is shown when the voicemail 2264 * notification is expanded.<p> 2265 */ getVoiceMessageCount()2266 public int getVoiceMessageCount(){ 2267 return mVmCount; 2268 } 2269 2270 /** sets the voice mail count of the phone and notifies listeners. */ setVoiceMessageCount(int countWaiting)2271 public void setVoiceMessageCount(int countWaiting) { 2272 mVmCount = countWaiting; 2273 int subId = getSubId(); 2274 if (SubscriptionManager.isValidSubscriptionId(subId)) { 2275 2276 Rlog.d(LOG_TAG, "setVoiceMessageCount: Storing Voice Mail Count = " + countWaiting + 2277 " for mVmCountKey = " + VM_COUNT + subId + " in preferences."); 2278 2279 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 2280 SharedPreferences.Editor editor = sp.edit(); 2281 editor.putInt(VM_COUNT + subId, countWaiting); 2282 editor.apply(); 2283 } else { 2284 Rlog.e(LOG_TAG, "setVoiceMessageCount in sharedPreference: invalid subId " + subId); 2285 } 2286 // notify listeners of voice mail 2287 notifyMessageWaitingIndicator(); 2288 } 2289 2290 /** gets the voice mail count from preferences */ getStoredVoiceMessageCount()2291 protected int getStoredVoiceMessageCount() { 2292 int countVoiceMessages = 0; 2293 int subId = getSubId(); 2294 if (SubscriptionManager.isValidSubscriptionId(subId)) { 2295 int invalidCount = -2; //-1 is not really invalid. It is used for unknown number of vm 2296 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 2297 int countFromSP = sp.getInt(VM_COUNT + subId, invalidCount); 2298 if (countFromSP != invalidCount) { 2299 countVoiceMessages = countFromSP; 2300 Rlog.d(LOG_TAG, "getStoredVoiceMessageCount: from preference for subId " + subId + 2301 "= " + countVoiceMessages); 2302 } else { 2303 // Check for old preference if count not found for current subId. This part of the 2304 // code is needed only when upgrading from M to N. 2305 String subscriberId = sp.getString(VM_ID, null); 2306 if (subscriberId != null) { 2307 String currentSubscriberId = getSubscriberId(); 2308 2309 if (currentSubscriberId != null && currentSubscriberId.equals(subscriberId)) { 2310 // get voice mail count from preferences 2311 countVoiceMessages = sp.getInt(VM_COUNT, 0); 2312 setVoiceMessageCount(countVoiceMessages); 2313 Rlog.d(LOG_TAG, "getStoredVoiceMessageCount: from preference = " + 2314 countVoiceMessages); 2315 } else { 2316 Rlog.d(LOG_TAG, "getStoredVoiceMessageCount: returning 0 as count for " + 2317 "matching subscriberId not found"); 2318 2319 } 2320 // get rid of old preferences. 2321 SharedPreferences.Editor editor = sp.edit(); 2322 editor.remove(VM_ID); 2323 editor.remove(VM_COUNT); 2324 editor.apply(); 2325 } 2326 } 2327 } else { 2328 Rlog.e(LOG_TAG, "getStoredVoiceMessageCount: invalid subId " + subId); 2329 } 2330 return countVoiceMessages; 2331 } 2332 2333 /** 2334 * send secret dialer codes to launch arbitrary activities. 2335 * an Intent is started with the android_secret_code://<code> URI. 2336 * 2337 * @param code stripped version of secret code without *#*# prefix and #*#* suffix 2338 */ sendDialerSpecialCode(String code)2339 public void sendDialerSpecialCode(String code) { 2340 if (!TextUtils.isEmpty(code)) { 2341 Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION, 2342 Uri.parse("android_secret_code://" + code)); 2343 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); 2344 mContext.sendBroadcast(intent); 2345 } 2346 } 2347 2348 /** 2349 * Returns the CDMA ERI icon index to display 2350 */ getCdmaEriIconIndex()2351 public int getCdmaEriIconIndex() { 2352 return -1; 2353 } 2354 2355 /** 2356 * Returns the CDMA ERI icon mode, 2357 * 0 - ON 2358 * 1 - FLASHING 2359 */ getCdmaEriIconMode()2360 public int getCdmaEriIconMode() { 2361 return -1; 2362 } 2363 2364 /** 2365 * Returns the CDMA ERI text, 2366 */ getCdmaEriText()2367 public String getCdmaEriText() { 2368 return "GSM nw, no ERI"; 2369 } 2370 2371 /** 2372 * Retrieves the MIN for CDMA phones. 2373 */ getCdmaMin()2374 public String getCdmaMin() { 2375 return null; 2376 } 2377 2378 /** 2379 * Check if subscription data has been assigned to mMin 2380 * 2381 * return true if MIN info is ready; false otherwise. 2382 */ isMinInfoReady()2383 public boolean isMinInfoReady() { 2384 return false; 2385 } 2386 2387 /** 2388 * Retrieves PRL Version for CDMA phones 2389 */ getCdmaPrlVersion()2390 public String getCdmaPrlVersion(){ 2391 return null; 2392 } 2393 2394 /** 2395 * send burst DTMF tone, it can send the string as single character or multiple character 2396 * ignore if there is no active call or not valid digits string. 2397 * Valid digit means only includes characters ISO-LATIN characters 0-9, *, # 2398 * The difference between sendDtmf and sendBurstDtmf is sendDtmf only sends one character, 2399 * this api can send single character and multiple character, also, this api has response 2400 * back to caller. 2401 * 2402 * @param dtmfString is string representing the dialing digit(s) in the active call 2403 * @param on the DTMF ON length in milliseconds, or 0 for default 2404 * @param off the DTMF OFF length in milliseconds, or 0 for default 2405 * @param onComplete is the callback message when the action is processed by BP 2406 * 2407 */ sendBurstDtmf(String dtmfString, int on, int off, Message onComplete)2408 public void sendBurstDtmf(String dtmfString, int on, int off, Message onComplete) { 2409 } 2410 2411 /** 2412 * Sets an event to be fired when the telephony system processes 2413 * a post-dial character on an outgoing call.<p> 2414 * 2415 * Messages of type <code>what</code> will be sent to <code>h</code>. 2416 * The <code>obj</code> field of these Message's will be instances of 2417 * <code>AsyncResult</code>. <code>Message.obj.result</code> will be 2418 * a Connection object.<p> 2419 * 2420 * Message.arg1 will be the post dial character being processed, 2421 * or 0 ('\0') if end of string.<p> 2422 * 2423 * If Connection.getPostDialState() == WAIT, 2424 * the application must call 2425 * {@link com.android.internal.telephony.Connection#proceedAfterWaitChar() 2426 * Connection.proceedAfterWaitChar()} or 2427 * {@link com.android.internal.telephony.Connection#cancelPostDial() 2428 * Connection.cancelPostDial()} 2429 * for the telephony system to continue playing the post-dial 2430 * DTMF sequence.<p> 2431 * 2432 * If Connection.getPostDialState() == WILD, 2433 * the application must call 2434 * {@link com.android.internal.telephony.Connection#proceedAfterWildChar 2435 * Connection.proceedAfterWildChar()} 2436 * or 2437 * {@link com.android.internal.telephony.Connection#cancelPostDial() 2438 * Connection.cancelPostDial()} 2439 * for the telephony system to continue playing the 2440 * post-dial DTMF sequence.<p> 2441 * 2442 * Only one post dial character handler may be set. <p> 2443 * Calling this method with "h" equal to null unsets this handler.<p> 2444 */ setOnPostDialCharacter(Handler h, int what, Object obj)2445 public void setOnPostDialCharacter(Handler h, int what, Object obj) { 2446 mPostDialHandler = new Registrant(h, what, obj); 2447 } 2448 getPostDialHandler()2449 public Registrant getPostDialHandler() { 2450 return mPostDialHandler; 2451 } 2452 2453 /** 2454 * request to exit emergency call back mode 2455 * the caller should use setOnECMModeExitResponse 2456 * to receive the emergency callback mode exit response 2457 */ exitEmergencyCallbackMode()2458 public void exitEmergencyCallbackMode() { 2459 } 2460 2461 /** 2462 * Register for notifications when CDMA OTA Provision status change 2463 * 2464 * @param h Handler that receives the notification message. 2465 * @param what User-defined message code. 2466 * @param obj User object. 2467 */ registerForCdmaOtaStatusChange(Handler h, int what, Object obj)2468 public void registerForCdmaOtaStatusChange(Handler h, int what, Object obj) { 2469 } 2470 2471 /** 2472 * Unregister for notifications when CDMA OTA Provision status change 2473 * @param h Handler to be removed from the registrant list. 2474 */ unregisterForCdmaOtaStatusChange(Handler h)2475 public void unregisterForCdmaOtaStatusChange(Handler h) { 2476 } 2477 2478 /** 2479 * Registration point for subscription info ready 2480 * @param h handler to notify 2481 * @param what what code of message when delivered 2482 * @param obj placed in Message.obj 2483 */ registerForSubscriptionInfoReady(Handler h, int what, Object obj)2484 public void registerForSubscriptionInfoReady(Handler h, int what, Object obj) { 2485 } 2486 2487 /** 2488 * Unregister for notifications for subscription info 2489 * @param h Handler to be removed from the registrant list. 2490 */ unregisterForSubscriptionInfoReady(Handler h)2491 public void unregisterForSubscriptionInfoReady(Handler h) { 2492 } 2493 2494 /** 2495 * Returns true if OTA Service Provisioning needs to be performed. 2496 */ needsOtaServiceProvisioning()2497 public boolean needsOtaServiceProvisioning() { 2498 return false; 2499 } 2500 2501 /** 2502 * this decides if the dial number is OTA(Over the air provision) number or not 2503 * @param dialStr is string representing the dialing digit(s) 2504 * @return true means the dialStr is OTA number, and false means the dialStr is not OTA number 2505 */ isOtaSpNumber(String dialStr)2506 public boolean isOtaSpNumber(String dialStr) { 2507 return false; 2508 } 2509 2510 /** 2511 * Register for notifications when CDMA call waiting comes 2512 * 2513 * @param h Handler that receives the notification message. 2514 * @param what User-defined message code. 2515 * @param obj User object. 2516 */ registerForCallWaiting(Handler h, int what, Object obj)2517 public void registerForCallWaiting(Handler h, int what, Object obj){ 2518 } 2519 2520 /** 2521 * Unegister for notifications when CDMA Call waiting comes 2522 * @param h Handler to be removed from the registrant list. 2523 */ unregisterForCallWaiting(Handler h)2524 public void unregisterForCallWaiting(Handler h){ 2525 } 2526 2527 /** 2528 * Registration point for Ecm timer reset 2529 * @param h handler to notify 2530 * @param what user-defined message code 2531 * @param obj placed in Message.obj 2532 */ registerForEcmTimerReset(Handler h, int what, Object obj)2533 public void registerForEcmTimerReset(Handler h, int what, Object obj) { 2534 } 2535 2536 /** 2537 * Unregister for notification for Ecm timer reset 2538 * @param h Handler to be removed from the registrant list. 2539 */ unregisterForEcmTimerReset(Handler h)2540 public void unregisterForEcmTimerReset(Handler h) { 2541 } 2542 2543 /** 2544 * Register for signal information notifications from the network. 2545 * Message.obj will contain an AsyncResult. 2546 * AsyncResult.result will be a SuppServiceNotification instance. 2547 * 2548 * @param h Handler that receives the notification message. 2549 * @param what User-defined message code. 2550 * @param obj User object. 2551 */ registerForSignalInfo(Handler h, int what, Object obj)2552 public void registerForSignalInfo(Handler h, int what, Object obj) { 2553 mCi.registerForSignalInfo(h, what, obj); 2554 } 2555 2556 /** 2557 * Unregisters for signal information notifications. 2558 * Extraneous calls are tolerated silently 2559 * 2560 * @param h Handler to be removed from the registrant list. 2561 */ unregisterForSignalInfo(Handler h)2562 public void unregisterForSignalInfo(Handler h) { 2563 mCi.unregisterForSignalInfo(h); 2564 } 2565 2566 /** 2567 * Register for display information notifications from the network. 2568 * Message.obj will contain an AsyncResult. 2569 * AsyncResult.result will be a SuppServiceNotification instance. 2570 * 2571 * @param h Handler that receives the notification message. 2572 * @param what User-defined message code. 2573 * @param obj User object. 2574 */ registerForDisplayInfo(Handler h, int what, Object obj)2575 public void registerForDisplayInfo(Handler h, int what, Object obj) { 2576 mCi.registerForDisplayInfo(h, what, obj); 2577 } 2578 2579 /** 2580 * Unregisters for display information notifications. 2581 * Extraneous calls are tolerated silently 2582 * 2583 * @param h Handler to be removed from the registrant list. 2584 */ unregisterForDisplayInfo(Handler h)2585 public void unregisterForDisplayInfo(Handler h) { 2586 mCi.unregisterForDisplayInfo(h); 2587 } 2588 2589 /** 2590 * Register for CDMA number information record notification from the network. 2591 * Message.obj will contain an AsyncResult. 2592 * AsyncResult.result will be a CdmaInformationRecords.CdmaNumberInfoRec 2593 * instance. 2594 * 2595 * @param h Handler that receives the notification message. 2596 * @param what User-defined message code. 2597 * @param obj User object. 2598 */ registerForNumberInfo(Handler h, int what, Object obj)2599 public void registerForNumberInfo(Handler h, int what, Object obj) { 2600 mCi.registerForNumberInfo(h, what, obj); 2601 } 2602 2603 /** 2604 * Unregisters for number information record notifications. 2605 * Extraneous calls are tolerated silently 2606 * 2607 * @param h Handler to be removed from the registrant list. 2608 */ unregisterForNumberInfo(Handler h)2609 public void unregisterForNumberInfo(Handler h) { 2610 mCi.unregisterForNumberInfo(h); 2611 } 2612 2613 /** 2614 * Register for CDMA redirected number information record notification 2615 * from the network. 2616 * Message.obj will contain an AsyncResult. 2617 * AsyncResult.result will be a CdmaInformationRecords.CdmaRedirectingNumberInfoRec 2618 * instance. 2619 * 2620 * @param h Handler that receives the notification message. 2621 * @param what User-defined message code. 2622 * @param obj User object. 2623 */ registerForRedirectedNumberInfo(Handler h, int what, Object obj)2624 public void registerForRedirectedNumberInfo(Handler h, int what, Object obj) { 2625 mCi.registerForRedirectedNumberInfo(h, what, obj); 2626 } 2627 2628 /** 2629 * Unregisters for redirected number information record notification. 2630 * Extraneous calls are tolerated silently 2631 * 2632 * @param h Handler to be removed from the registrant list. 2633 */ unregisterForRedirectedNumberInfo(Handler h)2634 public void unregisterForRedirectedNumberInfo(Handler h) { 2635 mCi.unregisterForRedirectedNumberInfo(h); 2636 } 2637 2638 /** 2639 * Register for CDMA line control information record notification 2640 * from the network. 2641 * Message.obj will contain an AsyncResult. 2642 * AsyncResult.result will be a CdmaInformationRecords.CdmaLineControlInfoRec 2643 * instance. 2644 * 2645 * @param h Handler that receives the notification message. 2646 * @param what User-defined message code. 2647 * @param obj User object. 2648 */ registerForLineControlInfo(Handler h, int what, Object obj)2649 public void registerForLineControlInfo(Handler h, int what, Object obj) { 2650 mCi.registerForLineControlInfo(h, what, obj); 2651 } 2652 2653 /** 2654 * Unregisters for line control information notifications. 2655 * Extraneous calls are tolerated silently 2656 * 2657 * @param h Handler to be removed from the registrant list. 2658 */ unregisterForLineControlInfo(Handler h)2659 public void unregisterForLineControlInfo(Handler h) { 2660 mCi.unregisterForLineControlInfo(h); 2661 } 2662 2663 /** 2664 * Register for CDMA T53 CLIR information record notifications 2665 * from the network. 2666 * Message.obj will contain an AsyncResult. 2667 * AsyncResult.result will be a CdmaInformationRecords.CdmaT53ClirInfoRec 2668 * instance. 2669 * 2670 * @param h Handler that receives the notification message. 2671 * @param what User-defined message code. 2672 * @param obj User object. 2673 */ registerFoT53ClirlInfo(Handler h, int what, Object obj)2674 public void registerFoT53ClirlInfo(Handler h, int what, Object obj) { 2675 mCi.registerFoT53ClirlInfo(h, what, obj); 2676 } 2677 2678 /** 2679 * Unregisters for T53 CLIR information record notification 2680 * Extraneous calls are tolerated silently 2681 * 2682 * @param h Handler to be removed from the registrant list. 2683 */ unregisterForT53ClirInfo(Handler h)2684 public void unregisterForT53ClirInfo(Handler h) { 2685 mCi.unregisterForT53ClirInfo(h); 2686 } 2687 2688 /** 2689 * Register for CDMA T53 audio control information record notifications 2690 * from the network. 2691 * Message.obj will contain an AsyncResult. 2692 * AsyncResult.result will be a CdmaInformationRecords.CdmaT53AudioControlInfoRec 2693 * instance. 2694 * 2695 * @param h Handler that receives the notification message. 2696 * @param what User-defined message code. 2697 * @param obj User object. 2698 */ registerForT53AudioControlInfo(Handler h, int what, Object obj)2699 public void registerForT53AudioControlInfo(Handler h, int what, Object obj) { 2700 mCi.registerForT53AudioControlInfo(h, what, obj); 2701 } 2702 2703 /** 2704 * Unregisters for T53 audio control information record notifications. 2705 * Extraneous calls are tolerated silently 2706 * 2707 * @param h Handler to be removed from the registrant list. 2708 */ unregisterForT53AudioControlInfo(Handler h)2709 public void unregisterForT53AudioControlInfo(Handler h) { 2710 mCi.unregisterForT53AudioControlInfo(h); 2711 } 2712 2713 /** 2714 * registers for exit emergency call back mode request response 2715 * 2716 * @param h Handler that receives the notification message. 2717 * @param what User-defined message code. 2718 * @param obj User object. 2719 */ setOnEcbModeExitResponse(Handler h, int what, Object obj)2720 public void setOnEcbModeExitResponse(Handler h, int what, Object obj){ 2721 } 2722 2723 /** 2724 * Unregisters for exit emergency call back mode request response 2725 * 2726 * @param h Handler to be removed from the registrant list. 2727 */ unsetOnEcbModeExitResponse(Handler h)2728 public void unsetOnEcbModeExitResponse(Handler h){ 2729 } 2730 2731 /** 2732 * Register for radio off or not available 2733 * 2734 * @param h Handler that receives the notification message. 2735 * @param what User-defined message code. 2736 * @param obj User object. 2737 */ registerForRadioOffOrNotAvailable(Handler h, int what, Object obj)2738 public void registerForRadioOffOrNotAvailable(Handler h, int what, Object obj) { 2739 mRadioOffOrNotAvailableRegistrants.addUnique(h, what, obj); 2740 } 2741 2742 /** 2743 * Unregisters for radio off or not available 2744 * 2745 * @param h Handler to be removed from the registrant list. 2746 */ unregisterForRadioOffOrNotAvailable(Handler h)2747 public void unregisterForRadioOffOrNotAvailable(Handler h) { 2748 mRadioOffOrNotAvailableRegistrants.remove(h); 2749 } 2750 2751 /** 2752 * Returns an array of string identifiers for the APN types serviced by the 2753 * currently active. 2754 * @return The string array will always return at least one entry, Phone.APN_TYPE_DEFAULT. 2755 * TODO: Revisit if we always should return at least one entry. 2756 */ getActiveApnTypes()2757 public String[] getActiveApnTypes() { 2758 if (mDcTracker == null) { 2759 return null; 2760 } 2761 2762 return mDcTracker.getActiveApnTypes(); 2763 } 2764 2765 /** 2766 * Check if TETHER_DUN_APN setting or config_tether_apndata includes APN that matches 2767 * current operator. 2768 * @return true if there is a matching DUN APN. 2769 */ hasMatchedTetherApnSetting()2770 public boolean hasMatchedTetherApnSetting() { 2771 return mDcTracker.hasMatchedTetherApnSetting(); 2772 } 2773 2774 /** 2775 * Returns string for the active APN host. 2776 * @return type as a string or null if none. 2777 */ getActiveApnHost(String apnType)2778 public String getActiveApnHost(String apnType) { 2779 return mDcTracker.getActiveApnString(apnType); 2780 } 2781 2782 /** 2783 * Return the LinkProperties for the named apn or null if not available 2784 */ getLinkProperties(String apnType)2785 public LinkProperties getLinkProperties(String apnType) { 2786 return mDcTracker.getLinkProperties(apnType); 2787 } 2788 2789 /** 2790 * Return the NetworkCapabilities 2791 */ getNetworkCapabilities(String apnType)2792 public NetworkCapabilities getNetworkCapabilities(String apnType) { 2793 return mDcTracker.getNetworkCapabilities(apnType); 2794 } 2795 2796 /** 2797 * Report on whether data connectivity is allowed. 2798 * 2799 * @return True if data is allowed to be established. 2800 */ isDataAllowed()2801 public boolean isDataAllowed() { 2802 return ((mDcTracker != null) && (mDcTracker.isDataAllowed(null))); 2803 } 2804 2805 /** 2806 * Report on whether data connectivity is allowed. 2807 * 2808 * @param reasons The reasons that data can/can't be established. This is an output param. 2809 * @return True if data is allowed to be established 2810 */ isDataAllowed(DataConnectionReasons reasons)2811 public boolean isDataAllowed(DataConnectionReasons reasons) { 2812 return ((mDcTracker != null) && (mDcTracker.isDataAllowed(reasons))); 2813 } 2814 2815 2816 /** 2817 * Action set from carrier signalling broadcast receivers to enable/disable metered apns. 2818 */ carrierActionSetMeteredApnsEnabled(boolean enabled)2819 public void carrierActionSetMeteredApnsEnabled(boolean enabled) { 2820 mCarrierActionAgent.carrierActionSetMeteredApnsEnabled(enabled); 2821 } 2822 2823 /** 2824 * Action set from carrier signalling broadcast receivers to enable/disable radio 2825 */ carrierActionSetRadioEnabled(boolean enabled)2826 public void carrierActionSetRadioEnabled(boolean enabled) { 2827 mCarrierActionAgent.carrierActionSetRadioEnabled(enabled); 2828 } 2829 2830 /** 2831 * Action set from carrier app to start/stop reporting default network condition. 2832 */ carrierActionReportDefaultNetworkStatus(boolean report)2833 public void carrierActionReportDefaultNetworkStatus(boolean report) { 2834 mCarrierActionAgent.carrierActionReportDefaultNetworkStatus(report); 2835 } 2836 2837 /** 2838 * Notify registrants of a new ringing Connection. 2839 * Subclasses of Phone probably want to replace this with a 2840 * version scoped to their packages 2841 */ notifyNewRingingConnectionP(Connection cn)2842 public void notifyNewRingingConnectionP(Connection cn) { 2843 if (!mIsVoiceCapable) 2844 return; 2845 AsyncResult ar = new AsyncResult(null, cn, null); 2846 mNewRingingConnectionRegistrants.notifyRegistrants(ar); 2847 } 2848 2849 /** 2850 * Notify registrants of a new unknown connection. 2851 */ notifyUnknownConnectionP(Connection cn)2852 public void notifyUnknownConnectionP(Connection cn) { 2853 mUnknownConnectionRegistrants.notifyResult(cn); 2854 } 2855 2856 /** 2857 * Notify registrants if phone is video capable. 2858 */ notifyForVideoCapabilityChanged(boolean isVideoCallCapable)2859 public void notifyForVideoCapabilityChanged(boolean isVideoCallCapable) { 2860 // Cache the current video capability so that we don't lose the information. 2861 mIsVideoCapable = isVideoCallCapable; 2862 2863 AsyncResult ar = new AsyncResult(null, isVideoCallCapable, null); 2864 mVideoCapabilityChangedRegistrants.notifyRegistrants(ar); 2865 } 2866 2867 /** 2868 * Notify registrants of a RING event. 2869 */ notifyIncomingRing()2870 private void notifyIncomingRing() { 2871 if (!mIsVoiceCapable) 2872 return; 2873 AsyncResult ar = new AsyncResult(null, this, null); 2874 mIncomingRingRegistrants.notifyRegistrants(ar); 2875 } 2876 2877 /** 2878 * Send the incoming call Ring notification if conditions are right. 2879 */ sendIncomingCallRingNotification(int token)2880 private void sendIncomingCallRingNotification(int token) { 2881 if (mIsVoiceCapable && !mDoesRilSendMultipleCallRing && 2882 (token == mCallRingContinueToken)) { 2883 Rlog.d(LOG_TAG, "Sending notifyIncomingRing"); 2884 notifyIncomingRing(); 2885 sendMessageDelayed( 2886 obtainMessage(EVENT_CALL_RING_CONTINUE, token, 0), mCallRingDelay); 2887 } else { 2888 Rlog.d(LOG_TAG, "Ignoring ring notification request," 2889 + " mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing 2890 + " token=" + token 2891 + " mCallRingContinueToken=" + mCallRingContinueToken 2892 + " mIsVoiceCapable=" + mIsVoiceCapable); 2893 } 2894 } 2895 2896 /** 2897 * TODO: Adding a function for each property is not good. 2898 * A fucntion of type getPhoneProp(propType) where propType is an 2899 * enum of GSM+CDMA+LTE props would be a better approach. 2900 * 2901 * Get "Restriction of menu options for manual PLMN selection" bit 2902 * status from EF_CSP data, this belongs to "Value Added Services Group". 2903 * @return true if this bit is set or EF_CSP data is unavailable, 2904 * false otherwise 2905 */ isCspPlmnEnabled()2906 public boolean isCspPlmnEnabled() { 2907 return false; 2908 } 2909 2910 /** 2911 * Return an interface to retrieve the ISIM records for IMS, if available. 2912 * @return the interface to retrieve the ISIM records, or null if not supported 2913 */ getIsimRecords()2914 public IsimRecords getIsimRecords() { 2915 Rlog.e(LOG_TAG, "getIsimRecords() is only supported on LTE devices"); 2916 return null; 2917 } 2918 2919 /** 2920 * Retrieves the MSISDN from the UICC. For GSM/UMTS phones, this is equivalent to 2921 * {@link #getLine1Number()}. For CDMA phones, {@link #getLine1Number()} returns 2922 * the MDN, so this method is provided to return the MSISDN on CDMA/LTE phones. 2923 */ getMsisdn()2924 public String getMsisdn() { 2925 return null; 2926 } 2927 2928 /** 2929 * Get the current for the default apn DataState. No change notification 2930 * exists at this interface -- use 2931 * {@link android.telephony.PhoneStateListener} instead. 2932 */ getDataConnectionState()2933 public PhoneConstants.DataState getDataConnectionState() { 2934 return getDataConnectionState(PhoneConstants.APN_TYPE_DEFAULT); 2935 } 2936 notifyCallForwardingIndicator()2937 public void notifyCallForwardingIndicator() { 2938 } 2939 notifyDataConnectionFailed(String reason, String apnType)2940 public void notifyDataConnectionFailed(String reason, String apnType) { 2941 mNotifier.notifyDataConnectionFailed(this, reason, apnType); 2942 } 2943 notifyPreciseDataConnectionFailed(String reason, String apnType, String apn, String failCause)2944 public void notifyPreciseDataConnectionFailed(String reason, String apnType, String apn, 2945 String failCause) { 2946 mNotifier.notifyPreciseDataConnectionFailed(this, reason, apnType, apn, failCause); 2947 } 2948 2949 /** 2950 * Return if the current radio is LTE on CDMA. This 2951 * is a tri-state return value as for a period of time 2952 * the mode may be unknown. 2953 * 2954 * @return {@link PhoneConstants#LTE_ON_CDMA_UNKNOWN}, {@link PhoneConstants#LTE_ON_CDMA_FALSE} 2955 * or {@link PhoneConstants#LTE_ON_CDMA_TRUE} 2956 */ getLteOnCdmaMode()2957 public int getLteOnCdmaMode() { 2958 return mCi.getLteOnCdmaMode(); 2959 } 2960 2961 /** 2962 * Sets the SIM voice message waiting indicator records. 2963 * @param line GSM Subscriber Profile Number, one-based. Only '1' is supported 2964 * @param countWaiting The number of messages waiting, if known. Use 2965 * -1 to indicate that an unknown number of 2966 * messages are waiting 2967 */ setVoiceMessageWaiting(int line, int countWaiting)2968 public void setVoiceMessageWaiting(int line, int countWaiting) { 2969 // This function should be overridden by class GsmCdmaPhone. 2970 Rlog.e(LOG_TAG, "Error! This function should never be executed, inactive Phone."); 2971 } 2972 2973 /** 2974 * Gets the USIM service table from the UICC, if present and available. 2975 * @return an interface to the UsimServiceTable record, or null if not available 2976 */ getUsimServiceTable()2977 public UsimServiceTable getUsimServiceTable() { 2978 IccRecords r = mIccRecords.get(); 2979 return (r != null) ? r.getUsimServiceTable() : null; 2980 } 2981 2982 /** 2983 * Gets the Uicc card corresponding to this phone. 2984 * @return the UiccCard object corresponding to the phone ID. 2985 */ getUiccCard()2986 public UiccCard getUiccCard() { 2987 return mUiccController.getUiccCard(mPhoneId); 2988 } 2989 2990 /** 2991 * Get P-CSCF address from PCO after data connection is established or modified. 2992 * @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN 2993 */ getPcscfAddress(String apnType)2994 public String[] getPcscfAddress(String apnType) { 2995 return mDcTracker.getPcscfAddress(apnType); 2996 } 2997 2998 /** 2999 * Set IMS registration state 3000 */ setImsRegistrationState(boolean registered)3001 public void setImsRegistrationState(boolean registered) { 3002 } 3003 3004 /** 3005 * Return an instance of a IMS phone 3006 */ getImsPhone()3007 public Phone getImsPhone() { 3008 return mImsPhone; 3009 } 3010 3011 /** 3012 * Returns Carrier specific information that will be used to encrypt the IMSI and IMPI. 3013 * @param keyType whether the key is being used for WLAN or ePDG. 3014 * @return ImsiEncryptionInfo which includes the Key Type, the Public Key 3015 * {@link java.security.PublicKey} and the Key Identifier. 3016 * The keyIdentifier This is used by the server to help it locate the private key to 3017 * decrypt the permanent identity. 3018 */ getCarrierInfoForImsiEncryption(int keyType)3019 public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType) { 3020 return null; 3021 } 3022 3023 /** 3024 * Sets the carrier information needed to encrypt the IMSI and IMPI. 3025 * @param imsiEncryptionInfo Carrier specific information that will be used to encrypt the 3026 * IMSI and IMPI. This includes the Key type, the Public key 3027 * {@link java.security.PublicKey} and the Key identifier. 3028 */ setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo)3029 public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo) { 3030 return; 3031 } 3032 3033 /** 3034 * Return if UT capability of ImsPhone is enabled or not 3035 */ isUtEnabled()3036 public boolean isUtEnabled() { 3037 if (mImsPhone != null) { 3038 return mImsPhone.isUtEnabled(); 3039 } 3040 return false; 3041 } 3042 dispose()3043 public void dispose() { 3044 } 3045 updateImsPhone()3046 private void updateImsPhone() { 3047 Rlog.d(LOG_TAG, "updateImsPhone" 3048 + " mImsServiceReady=" + mImsServiceReady); 3049 3050 if (mImsServiceReady && (mImsPhone == null)) { 3051 mImsPhone = PhoneFactory.makeImsPhone(mNotifier, this); 3052 CallManager.getInstance().registerPhone(mImsPhone); 3053 mImsPhone.registerForSilentRedial( 3054 this, EVENT_INITIATE_SILENT_REDIAL, null); 3055 } else if (!mImsServiceReady && (mImsPhone != null)) { 3056 CallManager.getInstance().unregisterPhone(mImsPhone); 3057 mImsPhone.unregisterForSilentRedial(this); 3058 3059 mImsPhone.dispose(); 3060 // Potential GC issue if someone keeps a reference to ImsPhone. 3061 // However: this change will make sure that such a reference does 3062 // not access functions through NULL pointer. 3063 //mImsPhone.removeReferences(); 3064 mImsPhone = null; 3065 } 3066 } 3067 3068 /** 3069 * Dials a number. 3070 * 3071 * @param dialString The number to dial. 3072 * @param uusInfo The UUSInfo. 3073 * @param videoState The video state for the call. 3074 * @param intentExtras Extras from the original CALL intent. 3075 * @return The Connection. 3076 * @throws CallStateException 3077 */ dialInternal( String dialString, UUSInfo uusInfo, int videoState, Bundle intentExtras)3078 protected Connection dialInternal( 3079 String dialString, UUSInfo uusInfo, int videoState, Bundle intentExtras) 3080 throws CallStateException { 3081 // dialInternal shall be overriden by GsmCdmaPhone 3082 return null; 3083 } 3084 3085 /* 3086 * Returns the subscription id. 3087 */ getSubId()3088 public int getSubId() { 3089 return SubscriptionController.getInstance().getSubIdUsingPhoneId(mPhoneId); 3090 } 3091 3092 /** 3093 * Returns the phone id. 3094 */ getPhoneId()3095 public int getPhoneId() { 3096 return mPhoneId; 3097 } 3098 3099 /** 3100 * Return the service state of mImsPhone if it is STATE_IN_SERVICE 3101 * otherwise return the current voice service state 3102 */ getVoicePhoneServiceState()3103 public int getVoicePhoneServiceState() { 3104 Phone imsPhone = mImsPhone; 3105 if (imsPhone != null 3106 && imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE) { 3107 return ServiceState.STATE_IN_SERVICE; 3108 } 3109 return getServiceState().getState(); 3110 } 3111 3112 /** 3113 * Override the service provider name and the operator name for the current ICCID. 3114 */ setOperatorBrandOverride(String brand)3115 public boolean setOperatorBrandOverride(String brand) { 3116 return false; 3117 } 3118 3119 /** 3120 * Override the roaming indicator for the current ICCID. 3121 */ setRoamingOverride(List<String> gsmRoamingList, List<String> gsmNonRoamingList, List<String> cdmaRoamingList, List<String> cdmaNonRoamingList)3122 public boolean setRoamingOverride(List<String> gsmRoamingList, 3123 List<String> gsmNonRoamingList, List<String> cdmaRoamingList, 3124 List<String> cdmaNonRoamingList) { 3125 String iccId = getIccSerialNumber(); 3126 if (TextUtils.isEmpty(iccId)) { 3127 return false; 3128 } 3129 3130 setRoamingOverrideHelper(gsmRoamingList, GSM_ROAMING_LIST_OVERRIDE_PREFIX, iccId); 3131 setRoamingOverrideHelper(gsmNonRoamingList, GSM_NON_ROAMING_LIST_OVERRIDE_PREFIX, iccId); 3132 setRoamingOverrideHelper(cdmaRoamingList, CDMA_ROAMING_LIST_OVERRIDE_PREFIX, iccId); 3133 setRoamingOverrideHelper(cdmaNonRoamingList, CDMA_NON_ROAMING_LIST_OVERRIDE_PREFIX, iccId); 3134 3135 // Refresh. 3136 ServiceStateTracker tracker = getServiceStateTracker(); 3137 if (tracker != null) { 3138 tracker.pollState(); 3139 } 3140 return true; 3141 } 3142 setRoamingOverrideHelper(List<String> list, String prefix, String iccId)3143 private void setRoamingOverrideHelper(List<String> list, String prefix, String iccId) { 3144 SharedPreferences.Editor spEditor = 3145 PreferenceManager.getDefaultSharedPreferences(mContext).edit(); 3146 String key = prefix + iccId; 3147 if (list == null || list.isEmpty()) { 3148 spEditor.remove(key).commit(); 3149 } else { 3150 spEditor.putStringSet(key, new HashSet<String>(list)).commit(); 3151 } 3152 } 3153 isMccMncMarkedAsRoaming(String mccMnc)3154 public boolean isMccMncMarkedAsRoaming(String mccMnc) { 3155 return getRoamingOverrideHelper(GSM_ROAMING_LIST_OVERRIDE_PREFIX, mccMnc); 3156 } 3157 isMccMncMarkedAsNonRoaming(String mccMnc)3158 public boolean isMccMncMarkedAsNonRoaming(String mccMnc) { 3159 return getRoamingOverrideHelper(GSM_NON_ROAMING_LIST_OVERRIDE_PREFIX, mccMnc); 3160 } 3161 isSidMarkedAsRoaming(int SID)3162 public boolean isSidMarkedAsRoaming(int SID) { 3163 return getRoamingOverrideHelper(CDMA_ROAMING_LIST_OVERRIDE_PREFIX, 3164 Integer.toString(SID)); 3165 } 3166 isSidMarkedAsNonRoaming(int SID)3167 public boolean isSidMarkedAsNonRoaming(int SID) { 3168 return getRoamingOverrideHelper(CDMA_NON_ROAMING_LIST_OVERRIDE_PREFIX, 3169 Integer.toString(SID)); 3170 } 3171 3172 /** 3173 * Query the IMS Registration Status. 3174 * 3175 * @return true if IMS is Registered 3176 */ isImsRegistered()3177 public boolean isImsRegistered() { 3178 Phone imsPhone = mImsPhone; 3179 boolean isImsRegistered = false; 3180 if (imsPhone != null) { 3181 isImsRegistered = imsPhone.isImsRegistered(); 3182 } else { 3183 ServiceStateTracker sst = getServiceStateTracker(); 3184 if (sst != null) { 3185 isImsRegistered = sst.isImsRegistered(); 3186 } 3187 } 3188 Rlog.d(LOG_TAG, "isImsRegistered =" + isImsRegistered); 3189 return isImsRegistered; 3190 } 3191 3192 /** 3193 * Get Wifi Calling Feature Availability 3194 */ isWifiCallingEnabled()3195 public boolean isWifiCallingEnabled() { 3196 Phone imsPhone = mImsPhone; 3197 boolean isWifiCallingEnabled = false; 3198 if (imsPhone != null) { 3199 isWifiCallingEnabled = imsPhone.isWifiCallingEnabled(); 3200 } 3201 Rlog.d(LOG_TAG, "isWifiCallingEnabled =" + isWifiCallingEnabled); 3202 return isWifiCallingEnabled; 3203 } 3204 3205 /** 3206 * Get Volte Feature Availability 3207 */ isVolteEnabled()3208 public boolean isVolteEnabled() { 3209 Phone imsPhone = mImsPhone; 3210 boolean isVolteEnabled = false; 3211 if (imsPhone != null) { 3212 isVolteEnabled = imsPhone.isVolteEnabled(); 3213 } 3214 Rlog.d(LOG_TAG, "isImsRegistered =" + isVolteEnabled); 3215 return isVolteEnabled; 3216 } 3217 getRoamingOverrideHelper(String prefix, String key)3218 private boolean getRoamingOverrideHelper(String prefix, String key) { 3219 String iccId = getIccSerialNumber(); 3220 if (TextUtils.isEmpty(iccId) || TextUtils.isEmpty(key)) { 3221 return false; 3222 } 3223 3224 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext); 3225 Set<String> value = sp.getStringSet(prefix + iccId, null); 3226 if (value == null) { 3227 return false; 3228 } 3229 return value.contains(key); 3230 } 3231 3232 /** 3233 * Is Radio Present on the device and is it accessible 3234 */ isRadioAvailable()3235 public boolean isRadioAvailable() { 3236 return mCi.getRadioState().isAvailable(); 3237 } 3238 3239 /** 3240 * Is Radio turned on 3241 */ isRadioOn()3242 public boolean isRadioOn() { 3243 return mCi.getRadioState().isOn(); 3244 } 3245 3246 /** 3247 * shutdown Radio gracefully 3248 */ shutdownRadio()3249 public void shutdownRadio() { 3250 getServiceStateTracker().requestShutdown(); 3251 } 3252 3253 /** 3254 * Return true if the device is shutting down. 3255 */ isShuttingDown()3256 public boolean isShuttingDown() { 3257 return getServiceStateTracker().isDeviceShuttingDown(); 3258 } 3259 3260 /** 3261 * Set phone radio capability 3262 * 3263 * @param rc the phone radio capability defined in 3264 * RadioCapability. It's a input object used to transfer parameter to logic modem 3265 * @param response Callback message. 3266 */ setRadioCapability(RadioCapability rc, Message response)3267 public void setRadioCapability(RadioCapability rc, Message response) { 3268 mCi.setRadioCapability(rc, response); 3269 } 3270 3271 /** 3272 * Get phone radio access family 3273 * 3274 * @return a bit mask to identify the radio access family. 3275 */ getRadioAccessFamily()3276 public int getRadioAccessFamily() { 3277 final RadioCapability rc = getRadioCapability(); 3278 return (rc == null ? RadioAccessFamily.RAF_UNKNOWN : rc.getRadioAccessFamily()); 3279 } 3280 3281 /** 3282 * Get the associated data modems Id. 3283 * 3284 * @return a String containing the id of the data modem 3285 */ getModemUuId()3286 public String getModemUuId() { 3287 final RadioCapability rc = getRadioCapability(); 3288 return (rc == null ? "" : rc.getLogicalModemUuid()); 3289 } 3290 3291 /** 3292 * Get phone radio capability 3293 * 3294 * @return the capability of the radio defined in RadioCapability 3295 */ getRadioCapability()3296 public RadioCapability getRadioCapability() { 3297 return mRadioCapability.get(); 3298 } 3299 3300 /** 3301 * The RadioCapability has changed. This comes up from the RIL and is called when radios first 3302 * become available or after a capability switch. The flow is we use setRadioCapability to 3303 * request a change with the RIL and get an UNSOL response with the new data which gets set 3304 * here. 3305 * 3306 * @param rc the phone radio capability currently in effect for this phone. 3307 */ radioCapabilityUpdated(RadioCapability rc)3308 public void radioCapabilityUpdated(RadioCapability rc) { 3309 // Called when radios first become available or after a capability switch 3310 // Update the cached value 3311 mRadioCapability.set(rc); 3312 3313 if (SubscriptionManager.isValidSubscriptionId(getSubId())) { 3314 sendSubscriptionSettings(true); 3315 } 3316 } 3317 sendSubscriptionSettings(boolean restoreNetworkSelection)3318 public void sendSubscriptionSettings(boolean restoreNetworkSelection) { 3319 // Send settings down 3320 int type = PhoneFactory.calculatePreferredNetworkType(mContext, getSubId()); 3321 setPreferredNetworkType(type, null); 3322 3323 if (restoreNetworkSelection) { 3324 restoreSavedNetworkSelection(null); 3325 } 3326 } 3327 setPreferredNetworkTypeIfSimLoaded()3328 protected void setPreferredNetworkTypeIfSimLoaded() { 3329 int subId = getSubId(); 3330 if (SubscriptionManager.isValidSubscriptionId(subId)) { 3331 int type = PhoneFactory.calculatePreferredNetworkType(mContext, getSubId()); 3332 setPreferredNetworkType(type, null); 3333 } 3334 } 3335 3336 /** 3337 * Registers the handler when phone radio capability is changed. 3338 * 3339 * @param h Handler for notification message. 3340 * @param what User-defined message code. 3341 * @param obj User object. 3342 */ registerForRadioCapabilityChanged(Handler h, int what, Object obj)3343 public void registerForRadioCapabilityChanged(Handler h, int what, Object obj) { 3344 mCi.registerForRadioCapabilityChanged(h, what, obj); 3345 } 3346 3347 /** 3348 * Unregister for notifications when phone radio type and access technology is changed. 3349 * 3350 * @param h Handler to be removed from the registrant list. 3351 */ unregisterForRadioCapabilityChanged(Handler h)3352 public void unregisterForRadioCapabilityChanged(Handler h) { 3353 mCi.unregisterForRadioCapabilityChanged(this); 3354 } 3355 3356 /** 3357 * Determines if IMS is enabled for call. 3358 * 3359 * @return {@code true} if IMS calling is enabled. 3360 */ isImsUseEnabled()3361 public boolean isImsUseEnabled() { 3362 boolean imsUseEnabled = 3363 ((ImsManager.isVolteEnabledByPlatform(mContext) && 3364 ImsManager.isEnhanced4gLteModeSettingEnabledByUser(mContext)) || 3365 (ImsManager.isWfcEnabledByPlatform(mContext) && 3366 ImsManager.isWfcEnabledByUser(mContext)) && 3367 ImsManager.isNonTtyOrTtyOnVolteEnabled(mContext)); 3368 return imsUseEnabled; 3369 } 3370 3371 /** 3372 * Determines if the connection to IMS services are available yet. 3373 * @return {@code true} if the connection to IMS services are available. 3374 */ isImsAvailable()3375 public boolean isImsAvailable() { 3376 if (mImsPhone == null) { 3377 return false; 3378 } 3379 3380 return mImsPhone.isImsAvailable(); 3381 } 3382 3383 /** 3384 * Determines if video calling is enabled for the phone. 3385 * 3386 * @return {@code true} if video calling is enabled, {@code false} otherwise. 3387 */ isVideoEnabled()3388 public boolean isVideoEnabled() { 3389 Phone imsPhone = mImsPhone; 3390 if (imsPhone != null) { 3391 return imsPhone.isVideoEnabled(); 3392 } 3393 return false; 3394 } 3395 3396 /** 3397 * Returns the status of Link Capacity Estimation (LCE) service. 3398 */ getLceStatus()3399 public int getLceStatus() { 3400 return mLceStatus; 3401 } 3402 3403 /** 3404 * Returns the modem activity information 3405 */ getModemActivityInfo(Message response)3406 public void getModemActivityInfo(Message response) { 3407 mCi.getModemActivityInfo(response); 3408 } 3409 3410 /** 3411 * Starts LCE service after radio becomes available. 3412 * LCE service state may get destroyed on the modem when radio becomes unavailable. 3413 */ startLceAfterRadioIsAvailable()3414 public void startLceAfterRadioIsAvailable() { 3415 mCi.startLceService(DEFAULT_REPORT_INTERVAL_MS, LCE_PULL_MODE, 3416 obtainMessage(EVENT_CONFIG_LCE)); 3417 } 3418 3419 /** 3420 * Set allowed carriers 3421 */ setAllowedCarriers(List<CarrierIdentifier> carriers, Message response)3422 public void setAllowedCarriers(List<CarrierIdentifier> carriers, Message response) { 3423 mCi.setAllowedCarriers(carriers, response); 3424 } 3425 3426 /** 3427 * Get allowed carriers 3428 */ getAllowedCarriers(Message response)3429 public void getAllowedCarriers(Message response) { 3430 mCi.getAllowedCarriers(response); 3431 } 3432 3433 /** 3434 * Returns the locale based on the carrier properties (such as {@code ro.carrier}) and 3435 * SIM preferences. 3436 */ getLocaleFromSimAndCarrierPrefs()3437 public Locale getLocaleFromSimAndCarrierPrefs() { 3438 final IccRecords records = mIccRecords.get(); 3439 if (records != null && records.getSimLanguage() != null) { 3440 return new Locale(records.getSimLanguage()); 3441 } 3442 3443 return getLocaleFromCarrierProperties(mContext); 3444 } 3445 updateDataConnectionTracker()3446 public void updateDataConnectionTracker() { 3447 mDcTracker.update(); 3448 } 3449 setInternalDataEnabled(boolean enable, Message onCompleteMsg)3450 public void setInternalDataEnabled(boolean enable, Message onCompleteMsg) { 3451 mDcTracker.setInternalDataEnabled(enable, onCompleteMsg); 3452 } 3453 updateCurrentCarrierInProvider()3454 public boolean updateCurrentCarrierInProvider() { 3455 return false; 3456 } 3457 registerForAllDataDisconnected(Handler h, int what, Object obj)3458 public void registerForAllDataDisconnected(Handler h, int what, Object obj) { 3459 mDcTracker.registerForAllDataDisconnected(h, what, obj); 3460 } 3461 unregisterForAllDataDisconnected(Handler h)3462 public void unregisterForAllDataDisconnected(Handler h) { 3463 mDcTracker.unregisterForAllDataDisconnected(h); 3464 } 3465 registerForDataEnabledChanged(Handler h, int what, Object obj)3466 public void registerForDataEnabledChanged(Handler h, int what, Object obj) { 3467 mDcTracker.registerForDataEnabledChanged(h, what, obj); 3468 } 3469 unregisterForDataEnabledChanged(Handler h)3470 public void unregisterForDataEnabledChanged(Handler h) { 3471 mDcTracker.unregisterForDataEnabledChanged(h); 3472 } 3473 getIccSmsInterfaceManager()3474 public IccSmsInterfaceManager getIccSmsInterfaceManager(){ 3475 return null; 3476 } 3477 isMatchGid(String gid)3478 protected boolean isMatchGid(String gid) { 3479 String gid1 = getGroupIdLevel1(); 3480 int gidLength = gid.length(); 3481 if (!TextUtils.isEmpty(gid1) && (gid1.length() >= gidLength) 3482 && gid1.substring(0, gidLength).equalsIgnoreCase(gid)) { 3483 return true; 3484 } 3485 return false; 3486 } 3487 checkWfcWifiOnlyModeBeforeDial(Phone imsPhone, Context context)3488 public static void checkWfcWifiOnlyModeBeforeDial(Phone imsPhone, Context context) 3489 throws CallStateException { 3490 if (imsPhone == null || !imsPhone.isWifiCallingEnabled()) { 3491 boolean wfcWiFiOnly = (ImsManager.isWfcEnabledByPlatform(context) && 3492 ImsManager.isWfcEnabledByUser(context) && 3493 (ImsManager.getWfcMode(context) == 3494 ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY)); 3495 if (wfcWiFiOnly) { 3496 throw new CallStateException( 3497 CallStateException.ERROR_OUT_OF_SERVICE, 3498 "WFC Wi-Fi Only Mode: IMS not registered"); 3499 } 3500 } 3501 } 3502 startRingbackTone()3503 public void startRingbackTone() { 3504 } 3505 stopRingbackTone()3506 public void stopRingbackTone() { 3507 } 3508 callEndCleanupHandOverCallIfAny()3509 public void callEndCleanupHandOverCallIfAny() { 3510 } 3511 cancelUSSD()3512 public void cancelUSSD() { 3513 } 3514 3515 /** 3516 * Set boolean broadcastEmergencyCallStateChanges 3517 */ setBroadcastEmergencyCallStateChanges(boolean broadcast)3518 public abstract void setBroadcastEmergencyCallStateChanges(boolean broadcast); 3519 sendEmergencyCallStateChange(boolean callActive)3520 public abstract void sendEmergencyCallStateChange(boolean callActive); 3521 3522 /** 3523 * This function returns the parent phone of the current phone. It is applicable 3524 * only for IMS phone (function is overridden by ImsPhone). For others the phone 3525 * object itself is returned. 3526 * @return 3527 */ getDefaultPhone()3528 public Phone getDefaultPhone() { 3529 return this; 3530 } 3531 3532 /** 3533 * Get aggregated video call data usage since boot. 3534 * Permissions android.Manifest.permission.READ_NETWORK_USAGE_HISTORY is required. 3535 * 3536 * @param perUidStats True if requesting data usage per uid, otherwise overall usage. 3537 * @return Snapshot of video call data usage 3538 */ getVtDataUsage(boolean perUidStats)3539 public NetworkStats getVtDataUsage(boolean perUidStats) { 3540 if (mImsPhone == null) return null; 3541 return mImsPhone.getVtDataUsage(perUidStats); 3542 } 3543 3544 /** 3545 * Policy control of data connection. Usually used when we hit data limit. 3546 * @param enabled True if enabling the data, otherwise disabling. 3547 */ setPolicyDataEnabled(boolean enabled)3548 public void setPolicyDataEnabled(boolean enabled) { 3549 mDcTracker.setPolicyDataEnabled(enabled); 3550 } 3551 3552 /** 3553 * SIP URIs aliased to the current subscriber given by the IMS implementation. 3554 * Applicable only on IMS; used in absence of line1number. 3555 * @return array of SIP URIs aliased to the current subscriber 3556 */ getCurrentSubscriberUris()3557 public Uri[] getCurrentSubscriberUris() { 3558 return null; 3559 } 3560 getAppSmsManager()3561 public AppSmsManager getAppSmsManager() { 3562 return mAppSmsManager; 3563 } 3564 3565 /** 3566 * Set SIM card power state. 3567 * @param state State of SIM (power down, power up, pass through) 3568 * - {@link android.telephony.TelephonyManager#CARD_POWER_DOWN} 3569 * - {@link android.telephony.TelephonyManager#CARD_POWER_UP} 3570 * - {@link android.telephony.TelephonyManager#CARD_POWER_UP_PASS_THROUGH} 3571 **/ setSimPowerState(int state)3572 public void setSimPowerState(int state) { 3573 mCi.setSimCardPower(state, null); 3574 } 3575 dump(FileDescriptor fd, PrintWriter pw, String[] args)3576 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { 3577 pw.println("Phone: subId=" + getSubId()); 3578 pw.println(" mPhoneId=" + mPhoneId); 3579 pw.println(" mCi=" + mCi); 3580 pw.println(" mDnsCheckDisabled=" + mDnsCheckDisabled); 3581 pw.println(" mDcTracker=" + mDcTracker); 3582 pw.println(" mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing); 3583 pw.println(" mCallRingContinueToken=" + mCallRingContinueToken); 3584 pw.println(" mCallRingDelay=" + mCallRingDelay); 3585 pw.println(" mIsVoiceCapable=" + mIsVoiceCapable); 3586 pw.println(" mIccRecords=" + mIccRecords.get()); 3587 pw.println(" mUiccApplication=" + mUiccApplication.get()); 3588 pw.println(" mSmsStorageMonitor=" + mSmsStorageMonitor); 3589 pw.println(" mSmsUsageMonitor=" + mSmsUsageMonitor); 3590 pw.flush(); 3591 pw.println(" mLooper=" + mLooper); 3592 pw.println(" mContext=" + mContext); 3593 pw.println(" mNotifier=" + mNotifier); 3594 pw.println(" mSimulatedRadioControl=" + mSimulatedRadioControl); 3595 pw.println(" mUnitTestMode=" + mUnitTestMode); 3596 pw.println(" isDnsCheckDisabled()=" + isDnsCheckDisabled()); 3597 pw.println(" getUnitTestMode()=" + getUnitTestMode()); 3598 pw.println(" getState()=" + getState()); 3599 pw.println(" getIccSerialNumber()=" + getIccSerialNumber()); 3600 pw.println(" getIccRecordsLoaded()=" + getIccRecordsLoaded()); 3601 pw.println(" getMessageWaitingIndicator()=" + getMessageWaitingIndicator()); 3602 pw.println(" getCallForwardingIndicator()=" + getCallForwardingIndicator()); 3603 pw.println(" isInEmergencyCall()=" + isInEmergencyCall()); 3604 pw.flush(); 3605 pw.println(" isInEcm()=" + isInEcm()); 3606 pw.println(" getPhoneName()=" + getPhoneName()); 3607 pw.println(" getPhoneType()=" + getPhoneType()); 3608 pw.println(" getVoiceMessageCount()=" + getVoiceMessageCount()); 3609 pw.println(" getActiveApnTypes()=" + getActiveApnTypes()); 3610 pw.println(" needsOtaServiceProvisioning=" + needsOtaServiceProvisioning()); 3611 pw.flush(); 3612 pw.println("++++++++++++++++++++++++++++++++"); 3613 3614 if (mImsPhone != null) { 3615 try { 3616 mImsPhone.dump(fd, pw, args); 3617 } catch (Exception e) { 3618 e.printStackTrace(); 3619 } 3620 3621 pw.flush(); 3622 pw.println("++++++++++++++++++++++++++++++++"); 3623 } 3624 3625 if (mDcTracker != null) { 3626 try { 3627 mDcTracker.dump(fd, pw, args); 3628 } catch (Exception e) { 3629 e.printStackTrace(); 3630 } 3631 3632 pw.flush(); 3633 pw.println("++++++++++++++++++++++++++++++++"); 3634 } 3635 3636 if (getServiceStateTracker() != null) { 3637 try { 3638 getServiceStateTracker().dump(fd, pw, args); 3639 } catch (Exception e) { 3640 e.printStackTrace(); 3641 } 3642 3643 pw.flush(); 3644 pw.println("++++++++++++++++++++++++++++++++"); 3645 } 3646 3647 if (mCarrierActionAgent != null) { 3648 try { 3649 mCarrierActionAgent.dump(fd, pw, args); 3650 } catch (Exception e) { 3651 e.printStackTrace(); 3652 } 3653 3654 pw.flush(); 3655 pw.println("++++++++++++++++++++++++++++++++"); 3656 } 3657 3658 if (mCarrierSignalAgent != null) { 3659 try { 3660 mCarrierSignalAgent.dump(fd, pw, args); 3661 } catch (Exception e) { 3662 e.printStackTrace(); 3663 } 3664 3665 pw.flush(); 3666 pw.println("++++++++++++++++++++++++++++++++"); 3667 } 3668 3669 if (getCallTracker() != null) { 3670 try { 3671 getCallTracker().dump(fd, pw, args); 3672 } catch (Exception e) { 3673 e.printStackTrace(); 3674 } 3675 3676 pw.flush(); 3677 pw.println("++++++++++++++++++++++++++++++++"); 3678 } 3679 3680 if (mSimActivationTracker != null) { 3681 try { 3682 mSimActivationTracker.dump(fd, pw, args); 3683 } catch (Exception e) { 3684 e.printStackTrace(); 3685 } 3686 3687 pw.flush(); 3688 pw.println("++++++++++++++++++++++++++++++++"); 3689 } 3690 3691 if (mCi != null && mCi instanceof RIL) { 3692 try { 3693 ((RIL)mCi).dump(fd, pw, args); 3694 } catch (Exception e) { 3695 e.printStackTrace(); 3696 } 3697 3698 pw.flush(); 3699 pw.println("++++++++++++++++++++++++++++++++"); 3700 } 3701 } 3702 } 3703