diff options
Diffstat (limited to 'telephony')
22 files changed, 1070 insertions, 301 deletions
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java index b6f6888..299c7c4 100644 --- a/telephony/java/android/telephony/CarrierConfigManager.java +++ b/telephony/java/android/telephony/CarrierConfigManager.java @@ -35,36 +35,160 @@ import android.os.ServiceManager; * @see Context#CARRIER_CONFIG_SERVICE */ public class CarrierConfigManager { + /** + * @hide + */ + public CarrierConfigManager() { + } /** * This intent is broadcast by the system when carrier config changes. */ public static final String - ACTION_CARRIER_CONFIG_CHANGED = "android.intent.action.carrier_config_changed"; + ACTION_CARRIER_CONFIG_CHANGED = "android.telephony.action.CARRIER_CONFIG_CHANGED"; /** - * Flag specifying whether VoLTE should be available for carrier, independent of carrier - * provisioning. If false: hard disabled. If true: then depends on carrier provisioning, - * availability, etc. + * Flag indicating whether the Phone app should ignore EVENT_SIM_NETWORK_LOCKED + * events from the Sim. + * If true, this will prevent the IccNetworkDepersonalizationPanel from being shown, and + * effectively disable the "Sim network lock" feature. */ - public static final String BOOL_CARRIER_VOLTE_AVAILABLE = "bool_carrier_volte_available"; + public static final String + BOOL_IGNORE_SIM_NETWORK_LOCKED_EVENTS = "bool_ignore_sim_network_locked_events"; /** - * Flag specifying whether VoLTE availability is based on provisioning. + * Flag indicating whether the Phone app should provide a "Dismiss" button on the SIM network + * unlock screen. The default value is true. If set to false, there will be *no way* to dismiss + * the SIM network unlock screen if you don't enter the correct unlock code. (One important + * consequence: there will be no way to make an Emergency Call if your SIM is network-locked and + * you don't know the PIN.) */ - public static final String BOOL_CARRIER_VOLTE_PROVISIONED = "bool_carrier_volte_provisioned"; + public static final String + BOOL_SIM_NETWORK_UNLOCK_ALLOW_DISMISS = "bool_sim_network_unlock_allow_dismiss"; + + /** Flag indicating if the phone is a world phone */ + public static final String BOOL_WORLD_PHONE = "bool_world_phone"; /** - * Flag specifying whether VoLTE TTY is supported. + * If true, enable vibration (haptic feedback) for key presses in the EmergencyDialer activity. + * The pattern is set on a per-platform basis using config_virtualKeyVibePattern. To be + * consistent with the regular Dialer, this value should agree with the corresponding values + * from config.xml under apps/Contacts. */ - public static final String BOOL_CARRIER_VOLTE_TTY_SUPPORTED - = "bool_carrier_volte_tty_supported"; + public static final String + BOOL_ENABLE_DIALER_KEY_VIBRATION = "bool_enable_dialer_key_vibration"; + + /** Flag indicating if dtmf tone type is enabled */ + public static final String BOOL_DTMF_TYPE_ENABLED = "bool_dtmf_type_enabled"; + + /** Flag indicating if auto retry is enabled */ + public static final String BOOL_AUTO_RETRY_ENABLED = "bool_auto_retry_enabled"; + + /** + * Determine whether we want to play local DTMF tones in a call, or just let the radio/BP handle + * playing of the tones. + */ + public static final String BOOL_ALLOW_LOCAL_DTMF_TONES = "bool_allow_local_dtmf_tones"; + + /** + * If true, show an onscreen "Dial" button in the dialer. In practice this is used on all + * platforms, even the ones with hard SEND/END keys, but for maximum flexibility it's controlled + * by a flag here (which can be overridden on a per-product basis.) + */ + public static final String BOOL_SHOW_ONSCREEN_DIAL_BUTTON = "bool_show_onscreen_dial_button"; + + /** Determines if device implements a noise suppression device for in call audio. */ + public static final String + BOOL_HAS_IN_CALL_NOISE_SUPPRESSION = "bool_has_in_call_noise_suppression"; /** - * Show APN Settings for some CDMA carriers. + * Determines if the current device should allow emergency numbers to be logged in the Call Log. + * (Some carriers require that emergency calls *not* be logged, presumably to avoid the risk of + * accidental redialing from the call log UI. This is a good idea, so the default here is + * false.) + * <p> + * TODO: on the other hand, it might still be useful to have some record of the emergency calls + * you've made, or to be able to look up the exact date/time of an emergency call. So perhaps we + * <b>should</b> log those calls, but instead fix the call log to disable the "call" button for + * emergency numbers. */ + public static final String + BOOL_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG = "bool_allow_emergency_numbers_in_call_log"; + + /** If true, removes the Voice Privacy option from Call Settings */ + public static final String BOOL_VOICE_PRIVACY_DISABLE = "bool_voice_privacy_disable"; + + /** Control whether users can reach the carrier portions of Cellular Network Settings. */ + public static final String + BOOL_HIDE_CARRIER_NETWORK_SETTINGS = "bool_hide_carrier_network_settings"; + + /** Control whether users can edit APNs in Settings. */ + public static final String BOOL_APN_EXPAND = "bool_apn_expand"; + + /** Control whether users can choose a network operator. */ + public static final String BOOL_OPERATOR_SELECTION_EXPAND = "bool_operator_selection_expand"; + + /** Used in Cellular Network Settings for preferred network type. */ + public static final String BOOL_PREFER_2G = "bool_prefer_2g"; + + /** Show cdma auto network mode in (glabal) roaming */ + public static final String BOOL_SHOW_CDMA = "bool_show_cdma"; + + /** CDMA activation goes through HFA */ + public static final String BOOL_USE_HFA_FOR_PROVISIONING = "bool_use_hfa_for_provisioning"; + + /** + * CDMA activation goes through OTASP. + * <p> + * TODO: This should be combined with config_use_hfa_for_provisioning and implemented as an enum + * (NONE, HFA, OTASP). + */ + public static final String BOOL_USE_OTASP_FOR_PROVISIONING = "bool_use_otasp_for_provisioning"; + + /** Display carrier settings menu if true */ + public static final String BOOL_CARRIER_SETTINGS_ENABLE = "bool_carrier_settings_enable"; + + /** Does not display additional call seting for IMS phone based on GSM Phone */ + public static final String BOOL_ADDITIONAL_CALL_SETTING = "bool_additional_call_setting"; + + /** Show APN Settings for some CDMA carriers */ public static final String BOOL_SHOW_APN_SETTING_CDMA = "bool_show_apn_setting_cdma"; + /** After a CDMA conference call is merged, the swap button should be displayed. */ + public static final String BOOL_SUPPORT_SWAP_AFTER_MERGE = "bool_support_swap_after_merge"; + + /** + * Determine whether the voicemail notification is persistent in the notification bar. If true, + * the voicemail notifications cannot be dismissed from the notification bar. + */ + public static final String + BOOL_VOICEMAIL_NOTIFICATION_PERSISTENT = "bool_voicemail_notification_persistent"; + + /** For IMS video over LTE calls, determines whether video pause signalling is supported. */ + public static final String + BOOL_SUPPORT_PAUSE_IMS_VIDEO_CALLS = "bool_support_pause_ims_video_calls"; + + /** + * Disables dialing "*228" (OTASP provisioning) on CDMA carriers where it is not supported or is + * potentially harmful by locking the SIM to 3G. + */ + public static final String + BOOL_DISABLE_CDMA_ACTIVATION_CODE = "bool_disable_cdma_activation_code"; + + /** + * Flag specifying whether VoLTE should be available for carrier, independent of carrier + * provisioning. If false: hard disabled. If true: then depends on carrier provisioning, + * availability, etc. + */ + public static final String BOOL_CARRIER_VOLTE_AVAILABLE = "bool_carrier_volte_available"; + + /** Flag specifying whether VoLTE availability is based on provisioning. */ + public static final String BOOL_CARRIER_VOLTE_PROVISIONED = "bool_carrier_volte_provisioned"; + + /** Flag specifying whether VoLTE TTY is supported. */ + public static final String BOOL_CARRIER_VOLTE_TTY_SUPPORTED + = "bool_carrier_volte_tty_supported"; + /** * If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 or RIL_RADIO_TECHNOLOGY_UNKNOWN:0 * this is the value that should be used instead. A configuration value of @@ -76,11 +200,10 @@ public class CarrierConfigManager { /* The following 3 fields are related to carrier visual voicemail. */ /** - * The carrier number MO sms messages are sent to. + * The carrier number MO sms messages are sent to. * - * @hide + * @hide */ - @SystemApi public static final String STRING_VVM_DESTINATION_NUMBER = "string_vvm_destination_number"; /** @@ -88,15 +211,13 @@ public class CarrierConfigManager { * * @hide */ - @SystemApi - public static final String SHORT_VVM_PORT_NUMBER = "string_vvm_port_number"; + public static final String INT_VVM_PORT_NUMBER = "int_vvm_port_number"; /** * The type of visual voicemail protocol the carrier adheres to (see below). * * @hide */ - @SystemApi public static final String STRING_VVM_TYPE = "string_vvm_type"; /* Visual voicemail protocols */ @@ -106,7 +227,6 @@ public class CarrierConfigManager { * * @hide */ - @SystemApi public static final String VVM_TYPE_OMTP = "vvm_type_omtp"; private final static String TAG = "CarrierConfigManager"; @@ -116,12 +236,38 @@ public class CarrierConfigManager { static { sDefaults = new Bundle(); + sDefaults.putBoolean(BOOL_ADDITIONAL_CALL_SETTING, true); + sDefaults.putBoolean(BOOL_ALLOW_EMERGENCY_NUMBERS_IN_CALL_LOG, false); + sDefaults.putBoolean(BOOL_ALLOW_LOCAL_DTMF_TONES, true); + sDefaults.putBoolean(BOOL_APN_EXPAND, true); + sDefaults.putBoolean(BOOL_AUTO_RETRY_ENABLED, false); + sDefaults.putBoolean(BOOL_CARRIER_SETTINGS_ENABLE, false); sDefaults.putBoolean(BOOL_CARRIER_VOLTE_AVAILABLE, false); sDefaults.putBoolean(BOOL_CARRIER_VOLTE_PROVISIONED, false); sDefaults.putBoolean(BOOL_CARRIER_VOLTE_TTY_SUPPORTED, true); + sDefaults.putBoolean(BOOL_DISABLE_CDMA_ACTIVATION_CODE, false); + sDefaults.putBoolean(BOOL_DTMF_TYPE_ENABLED, false); + sDefaults.putBoolean(BOOL_ENABLE_DIALER_KEY_VIBRATION, true); + sDefaults.putBoolean(BOOL_HAS_IN_CALL_NOISE_SUPPRESSION, false); + sDefaults.putBoolean(BOOL_HIDE_CARRIER_NETWORK_SETTINGS, false); + sDefaults.putBoolean(BOOL_IGNORE_SIM_NETWORK_LOCKED_EVENTS, false); + sDefaults.putBoolean(BOOL_OPERATOR_SELECTION_EXPAND, true); + sDefaults.putBoolean(BOOL_PREFER_2G, true); sDefaults.putBoolean(BOOL_SHOW_APN_SETTING_CDMA, false); - + sDefaults.putBoolean(BOOL_SHOW_CDMA, false); + sDefaults.putBoolean(BOOL_SHOW_ONSCREEN_DIAL_BUTTON, true); + sDefaults.putBoolean(BOOL_SIM_NETWORK_UNLOCK_ALLOW_DISMISS, true); + sDefaults.putBoolean(BOOL_SUPPORT_PAUSE_IMS_VIDEO_CALLS, true); + sDefaults.putBoolean(BOOL_SUPPORT_SWAP_AFTER_MERGE, true); + sDefaults.putBoolean(BOOL_USE_HFA_FOR_PROVISIONING, false); + sDefaults.putBoolean(BOOL_USE_OTASP_FOR_PROVISIONING, false); + sDefaults.putBoolean(BOOL_VOICEMAIL_NOTIFICATION_PERSISTENT, false); + sDefaults.putBoolean(BOOL_VOICE_PRIVACY_DISABLE, false); + sDefaults.putBoolean(BOOL_WORLD_PHONE, false); sDefaults.putInt(INT_VOLTE_REPLACEMENT_RAT, 0); + sDefaults.putInt(INT_VVM_PORT_NUMBER, 0); + sDefaults.putString(STRING_VVM_DESTINATION_NUMBER, ""); + sDefaults.putString(STRING_VVM_TYPE, ""); } /** @@ -179,10 +325,11 @@ public class CarrierConfigManager { /** * Request the carrier config loader to update the cofig for phoneId. - * - * Depending on simState, the config may be cleared or loaded from config app. - * This is only used by SubscriptionInfoUpdater. - * + * <p> + * Depending on simState, the config may be cleared or loaded from config app. This is only used + * by SubscriptionInfoUpdater. + * </p> + * * @hide */ @SystemApi @@ -197,13 +344,13 @@ public class CarrierConfigManager { } /** - * Returns a bundle with the default value for every supported configuration variable. + * Returns a new bundle with the default value for every supported configuration variable. * * @hide */ @SystemApi public static Bundle getDefaultConfig() { - return sDefaults; + return new Bundle(sDefaults); } /** @hide */ diff --git a/telephony/java/android/telephony/CellIdentityCdma.java b/telephony/java/android/telephony/CellIdentityCdma.java index dbd48d9..b39b4c7 100644 --- a/telephony/java/android/telephony/CellIdentityCdma.java +++ b/telephony/java/android/telephony/CellIdentityCdma.java @@ -20,6 +20,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import java.util.Objects; + /** * CellIdentity is to represent a unique CDMA cell */ @@ -137,27 +139,25 @@ public final class CellIdentityCdma implements Parcelable { @Override public int hashCode() { - int primeNum = 31; - return (mNetworkId * primeNum) + (mSystemId * primeNum) + (mBasestationId * primeNum) + - (mLatitude * primeNum) + (mLongitude * primeNum); + return Objects.hash(mNetworkId, mSystemId, mBasestationId, mLatitude, mLongitude); } @Override public boolean equals(Object other) { - if (super.equals(other)) { - try { - CellIdentityCdma o = (CellIdentityCdma)other; - return mNetworkId == o.mNetworkId && - mSystemId == o.mSystemId && - mBasestationId == o.mBasestationId && - mLatitude == o.mLatitude && - mLongitude == o.mLongitude; - } catch (ClassCastException e) { - return false; - } - } else { + if (this == other) { + return true; + } + + if (!(other instanceof CellIdentityCdma)) { return false; } + + CellIdentityCdma o = (CellIdentityCdma) other; + return mNetworkId == o.mNetworkId && + mSystemId == o.mSystemId && + mBasestationId == o.mBasestationId && + mLatitude == o.mLatitude && + mLongitude == o.mLongitude; } @Override diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java index 6f8cc91..90d2aa0 100644 --- a/telephony/java/android/telephony/CellIdentityGsm.java +++ b/telephony/java/android/telephony/CellIdentityGsm.java @@ -20,6 +20,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import java.util.Objects; + /** * CellIdentity to represent a unique GSM cell */ @@ -113,25 +115,24 @@ public final class CellIdentityGsm implements Parcelable { @Override public int hashCode() { - int primeNum = 31; - return (mMcc * primeNum) + (mMnc * primeNum) + (mLac * primeNum) + (mCid * primeNum); + return Objects.hash(mMcc, mMnc, mLac, mCid); } @Override public boolean equals(Object other) { - if (super.equals(other)) { - try { - CellIdentityGsm o = (CellIdentityGsm)other; - return mMcc == o.mMcc && - mMnc == o.mMnc && - mLac == o.mLac && - mCid == o.mCid; - } catch (ClassCastException e) { - return false; - } - } else { + if (this == other) { + return true; + } + + if (!(other instanceof CellIdentityGsm)) { return false; } + + CellIdentityGsm o = (CellIdentityGsm) other; + return mMcc == o.mMcc && + mMnc == o.mMnc && + mLac == o.mLac && + mCid == o.mCid; } @Override diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java index 72578a4..1e7ac08 100644 --- a/telephony/java/android/telephony/CellIdentityLte.java +++ b/telephony/java/android/telephony/CellIdentityLte.java @@ -20,6 +20,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import java.util.Objects; + /** * CellIdentity is to represent a unique LTE cell */ @@ -117,27 +119,25 @@ public final class CellIdentityLte implements Parcelable { @Override public int hashCode() { - int primeNum = 31; - return (mMcc * primeNum) + (mMnc * primeNum) + (mCi * primeNum) + (mPci * primeNum) + - (mTac * primeNum); + return Objects.hash(mMcc, mMnc, mCi, mPci, mTac); } @Override public boolean equals(Object other) { - if (super.equals(other)) { - try { - CellIdentityLte o = (CellIdentityLte)other; - return mMcc == o.mMcc && - mMnc == o.mMnc && - mCi == o.mCi && - mPci == o.mPci && - mTac == o.mTac; - } catch (ClassCastException e) { - return false; - } - } else { + if (this == other) { + return true; + } + + if (!(other instanceof CellIdentityLte)) { return false; } + + CellIdentityLte o = (CellIdentityLte) other; + return mMcc == o.mMcc && + mMnc == o.mMnc && + mCi == o.mCi && + mPci == o.mPci && + mTac == o.mTac; } @Override diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java index 2f8fa42..56ee8c9 100644 --- a/telephony/java/android/telephony/CellIdentityWcdma.java +++ b/telephony/java/android/telephony/CellIdentityWcdma.java @@ -20,6 +20,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.telephony.Rlog; +import java.util.Objects; + /** * CellIdentity to represent a unique UMTS cell */ @@ -118,27 +120,25 @@ public final class CellIdentityWcdma implements Parcelable { @Override public int hashCode() { - int primeNum = 31; - return (mMcc * primeNum) + (mMnc * primeNum) + (mLac * primeNum) + (mCid * primeNum) + - (mPsc * primeNum); + return Objects.hash(mMcc, mMnc, mLac, mCid, mPsc); } @Override public boolean equals(Object other) { - if (super.equals(other)) { - try { - CellIdentityWcdma o = (CellIdentityWcdma)other; - return mMcc == o.mMcc && - mMnc == o.mMnc && - mLac == o.mLac && - mCid == o.mCid && - mPsc == o.mPsc; - } catch (ClassCastException e) { - return false; - } - } else { + if (this == other) { + return true; + } + + if (!(other instanceof CellIdentityWcdma)) { return false; } + + CellIdentityWcdma o = (CellIdentityWcdma) other; + return mMcc == o.mMcc && + mMnc == o.mMnc && + mLac == o.mLac && + mCid == o.mCid && + mPsc == o.mPsc; } @Override diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 3572846..aae3ff6 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -37,8 +37,6 @@ import android.text.TextUtils; import android.text.style.TtsSpan; import android.util.SparseIntArray; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY; -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY; import static com.android.internal.telephony.TelephonyProperties.PROPERTY_OPERATOR_IDP_STRING; import java.util.Locale; @@ -1143,6 +1141,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static String formatNumber(String source) { SpannableStringBuilder text = new SpannableStringBuilder(source); formatNumber(text, getFormatTypeForLocale(Locale.getDefault())); @@ -1161,6 +1160,7 @@ public class PhoneNumberUtils * @hide * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static String formatNumber(String source, int defaultFormattingType) { SpannableStringBuilder text = new SpannableStringBuilder(source); formatNumber(text, defaultFormattingType); @@ -1176,6 +1176,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static int getFormatTypeForLocale(Locale locale) { String country = locale.getCountry(); @@ -1192,6 +1193,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static void formatNumber(Editable text, int defaultFormattingType) { int formatType = defaultFormattingType; @@ -1240,6 +1242,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static void formatNanpNumber(Editable text) { int length = text.length(); if (length > "+1-nnn-nnn-nnnn".length()) { @@ -1355,6 +1358,7 @@ public class PhoneNumberUtils * * @deprecated Use link #formatNumber(String phoneNumber, String defaultCountryIso) instead */ + @Deprecated public static void formatJapaneseNumber(Editable text) { JapanesePhoneNumberFormatter.format(text); } @@ -1376,32 +1380,52 @@ public class PhoneNumberUtils } /** - * Format the given phoneNumber to the E.164 representation. + * Formats the specified {@code phoneNumber} to the E.164 representation. + * + * @param phoneNumber the phone number to format. + * @param defaultCountryIso the ISO 3166-1 two letters country code. + * @return the E.164 representation, or null if the given phone number is not valid. + */ + public static String formatNumberToE164(String phoneNumber, String defaultCountryIso) { + return formatNumberInternal(phoneNumber, defaultCountryIso, PhoneNumberFormat.E164); + } + + /** + * Formats the specified {@code phoneNumber} to the RFC3966 representation. + * + * @param phoneNumber the phone number to format. + * @param defaultCountryIso the ISO 3166-1 two letters country code. + * @return the RFC3966 representation, or null if the given phone number is not valid. + */ + public static String formatNumberToRFC3966(String phoneNumber, String defaultCountryIso) { + return formatNumberInternal(phoneNumber, defaultCountryIso, PhoneNumberFormat.RFC3966); + } + + /** + * Formats the raw phone number (string) using the specified {@code formatIdentifier}. * <p> - * The given phone number must have an area code and could have a country - * code. + * The given phone number must have an area code and could have a country code. * <p> - * The defaultCountryIso is used to validate the given number and generate - * the E.164 phone number if the given number doesn't have a country code. + * The defaultCountryIso is used to validate the given number and generate the formatted number + * if the specified number doesn't have a country code. * - * @param phoneNumber - * the phone number to format - * @param defaultCountryIso - * the ISO 3166-1 two letters country code - * @return the E.164 representation, or null if the given phone number is - * not valid. + * @param rawPhoneNumber The phone number to format. + * @param defaultCountryIso The ISO 3166-1 two letters country code. + * @param formatIdentifier The (enum) identifier of the desired format. + * @return the formatted representation, or null if the specified number is not valid. */ - public static String formatNumberToE164(String phoneNumber, String defaultCountryIso) { + private static String formatNumberInternal( + String rawPhoneNumber, String defaultCountryIso, PhoneNumberFormat formatIdentifier) { + PhoneNumberUtil util = PhoneNumberUtil.getInstance(); - String result = null; try { - PhoneNumber pn = util.parse(phoneNumber, defaultCountryIso); - if (util.isValidNumber(pn)) { - result = util.format(pn, PhoneNumberFormat.E164); + PhoneNumber phoneNumber = util.parse(rawPhoneNumber, defaultCountryIso); + if (util.isValidNumber(phoneNumber)) { + return util.format(phoneNumber, formatIdentifier); } - } catch (NumberParseException e) { - } - return result; + } catch (NumberParseException ignored) { } + + return null; } /** @@ -2421,9 +2445,13 @@ public class PhoneNumberUtils } private static String getCurrentIdp(boolean useNanp) { - // in case, there is no IDD is found, we shouldn't convert it. - String ps = SystemProperties.get( - PROPERTY_OPERATOR_IDP_STRING, useNanp ? NANP_IDP_STRING : PLUS_SIGN_STRING); + String ps = null; + if (useNanp) { + ps = NANP_IDP_STRING; + } else { + // in case, there is no IDD is found, we shouldn't convert it. + ps = SystemProperties.get(PROPERTY_OPERATOR_IDP_STRING, PLUS_SIGN_STRING); + } return ps; } @@ -2514,7 +2542,7 @@ public class PhoneNumberUtils * * @param number SIP address of the form "username@domainname" * (or the URI-escaped equivalent "username%40domainname") - * @see isUriNumber + * @see #isUriNumber * * @hide */ diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java index 8f4a92b..d192288 100644 --- a/telephony/java/android/telephony/PhoneStateListener.java +++ b/telephony/java/android/telephony/PhoneStateListener.java @@ -27,13 +27,10 @@ import android.telephony.VoLteServiceState; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.SignalStrength; -import android.telephony.SubscriptionManager; import android.telephony.PreciseCallState; import android.telephony.PreciseDataConnectionState; import com.android.internal.telephony.IPhoneStateListener; -import com.android.internal.telephony.PhoneConstants; - import java.util.List; /** @@ -222,6 +219,15 @@ public class PhoneStateListener { */ public static final int LISTEN_OEM_HOOK_RAW_EVENT = 0x00008000; + /** + * Listen for carrier network changes indicated by a carrier app. + * + * @see #onCarrierNetworkRequest + * @see TelephonyManager#notifyCarrierNetworkChange(boolean) + * @hide + */ + public static final int LISTEN_CARRIER_NETWORK_CHANGE = 0x00010000; + /* * Subscription used to listen to the phone state changes * @hide @@ -233,8 +239,7 @@ public class PhoneStateListener { /** * Create a PhoneStateListener for the Phone with the default subscription. - * This class requires Looper.myLooper() not return null. To supply your - * own non-null looper use PhoneStateListener(Looper looper) below. + * This class requires Looper.myLooper() not return null. */ public PhoneStateListener() { this(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, Looper.myLooper()); @@ -325,6 +330,9 @@ public class PhoneStateListener { case LISTEN_OEM_HOOK_RAW_EVENT: PhoneStateListener.this.onOemHookRawEvent((byte[])msg.obj); break; + case LISTEN_CARRIER_NETWORK_CHANGE: + PhoneStateListener.this.onCarrierNetworkChange((boolean)msg.obj); + break; } } @@ -504,6 +512,22 @@ public class PhoneStateListener { } /** + * Callback invoked when telephony has received notice from a carrier + * app that a network action that could result in connectivity loss + * has been requested by an app using + * {@link android.telephony.TelephonyManager#notifyCarrierNetworkChange(boolean)} + * + * @param active Whether the carrier network change is or shortly + * will be active. This value is true to indicate + * showing alternative UI and false to stop. + * + * @hide + */ + public void onCarrierNetworkChange(boolean active) { + // default implementation empty + } + + /** * The callback methods need to be called on the handler thread where * this object was created. If the binder did that for us it'd be nice. */ @@ -579,6 +603,10 @@ public class PhoneStateListener { public void onOemHookRawEvent(byte[] rawData) { Message.obtain(mHandler, LISTEN_OEM_HOOK_RAW_EVENT, 0, 0, rawData).sendToTarget(); } + + public void onCarrierNetworkChange(boolean active) { + Message.obtain(mHandler, LISTEN_CARRIER_NETWORK_CHANGE, 0, 0, active).sendToTarget(); + } }; private void log(String s) { diff --git a/telephony/java/android/telephony/PreciseCallState.java b/telephony/java/android/telephony/PreciseCallState.java index a85df15..f246416 100644 --- a/telephony/java/android/telephony/PreciseCallState.java +++ b/telephony/java/android/telephony/PreciseCallState.java @@ -16,10 +16,8 @@ package android.telephony; -import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; -import android.telephony.Rlog; import android.telephony.DisconnectCause; import android.telephony.PreciseDisconnectCause; diff --git a/telephony/java/android/telephony/PreciseDataConnectionState.java b/telephony/java/android/telephony/PreciseDataConnectionState.java index 87529fe..31c9a9e 100644 --- a/telephony/java/android/telephony/PreciseDataConnectionState.java +++ b/telephony/java/android/telephony/PreciseDataConnectionState.java @@ -16,10 +16,8 @@ package android.telephony; -import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; -import android.telephony.Rlog; import android.telephony.TelephonyManager; import android.net.LinkProperties; diff --git a/telephony/java/android/telephony/RadioAccessFamily.java b/telephony/java/android/telephony/RadioAccessFamily.java index d10a7ea..9fea418 100644 --- a/telephony/java/android/telephony/RadioAccessFamily.java +++ b/telephony/java/android/telephony/RadioAccessFamily.java @@ -48,6 +48,13 @@ public class RadioAccessFamily implements Parcelable { public static final int RAF_GSM = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_GSM); public static final int RAF_TD_SCDMA = (1 << ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA); + // Grouping of RAFs + private static final int GSM = RAF_GSM | RAF_GPRS | RAF_EDGE; + private static final int HS = RAF_HSUPA | RAF_HSDPA | RAF_HSPA | RAF_HSPAP; + private static final int CDMA = RAF_IS95A | RAF_IS95B | RAF_1xRTT; + private static final int EVDO = RAF_EVDO_0 | RAF_EVDO_A | RAF_EVDO_B | RAF_EHRPD; + private static final int WCDMA = HS | RAF_UMTS; + /* Phone ID of phone */ private int mPhoneId; @@ -136,12 +143,6 @@ public class RadioAccessFamily implements Parcelable { }; public static int getRafFromNetworkType(int type) { - final int GSM = RAF_GSM | RAF_GPRS | RAF_EDGE; - final int HS = RAF_HSUPA | RAF_HSDPA | RAF_HSPA | RAF_HSPAP; - final int CDMA = RAF_IS95A | RAF_IS95B | RAF_1xRTT; - final int EVDO = RAF_EVDO_0 | RAF_EVDO_A | RAF_EVDO_B; - final int WCDMA = HS | RAF_UMTS; - int raf; switch (type) { @@ -158,7 +159,7 @@ public class RadioAccessFamily implements Parcelable { raf = GSM | WCDMA; break; case RILConstants.NETWORK_MODE_CDMA: - raf = CDMA; + raf = CDMA | EVDO; break; case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO: raf = RAF_LTE | CDMA | EVDO; @@ -188,7 +189,71 @@ public class RadioAccessFamily implements Parcelable { raf = RAF_UNKNOWN; break; } + return raf; } + + /** + * if the raf includes ANY bit set for a group + * adjust it to contain ALL the bits for that group + */ + private static int getAdjustedRaf(int raf) { + raf = ((GSM & raf) > 0) ? (GSM | raf) : raf; + raf = ((WCDMA & raf) > 0) ? (WCDMA | raf) : raf; + raf = ((CDMA & raf) > 0) ? (CDMA | raf) : raf; + raf = ((EVDO & raf) > 0) ? (EVDO | raf) : raf; + + return raf; + } + + public static int getNetworkTypeFromRaf(int raf) { + int type; + + raf = getAdjustedRaf(raf); + + switch (raf) { + case (GSM | WCDMA): + type = RILConstants.NETWORK_MODE_WCDMA_PREF; + break; + case GSM: + type = RILConstants.NETWORK_MODE_GSM_ONLY; + break; + case WCDMA: + type = RILConstants.NETWORK_MODE_WCDMA_ONLY; + break; + case (CDMA | EVDO): + type = RILConstants.NETWORK_MODE_CDMA; + break; + case (RAF_LTE | CDMA | EVDO): + type = RILConstants.NETWORK_MODE_LTE_CDMA_EVDO; + break; + case (RAF_LTE | GSM | WCDMA): + type = RILConstants.NETWORK_MODE_LTE_GSM_WCDMA; + break; + case (RAF_LTE | CDMA | EVDO | GSM | WCDMA): + type = RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA; + break; + case RAF_LTE: + type = RILConstants.NETWORK_MODE_LTE_ONLY; + break; + case (RAF_LTE | WCDMA): + type = RILConstants.NETWORK_MODE_LTE_WCDMA; + break; + case CDMA: + type = RILConstants.NETWORK_MODE_CDMA_NO_EVDO; + break; + case EVDO: + type = RILConstants.NETWORK_MODE_EVDO_NO_CDMA; + break; + case (GSM | WCDMA | CDMA | EVDO): + type = RILConstants.NETWORK_MODE_GLOBAL; + break; + default: + type = RILConstants.PREFERRED_NETWORK_MODE ; + break; + } + + return type; + } } diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java index 17db3fb..7b58755 100644 --- a/telephony/java/android/telephony/SignalStrength.java +++ b/telephony/java/android/telephony/SignalStrength.java @@ -470,8 +470,6 @@ public class SignalStrength implements Parcelable { /** * Get signal level as an int from 0..4 - * - * @hide */ public int getLevel() { int level; diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 88ca8a4..33e52bf 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -32,8 +32,6 @@ import com.android.internal.telephony.ISub; import com.android.internal.telephony.IOnSubscriptionsChangedListener; import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.PhoneConstants; -import com.android.internal.telephony.TelephonyProperties; - import java.util.ArrayList; import java.util.List; @@ -274,10 +272,6 @@ public class SubscriptionManager { * for #onSubscriptionsChanged to be invoked. */ public static class OnSubscriptionsChangedListener { - /** @hide */ - public static final String PERMISSION_ON_SUBSCRIPTIONS_CHANGED = - android.Manifest.permission.READ_PHONE_STATE; - private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { @@ -402,7 +396,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - subInfo = iSub.getActiveSubscriptionInfo(subId); + subInfo = iSub.getActiveSubscriptionInfo(subId, mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -430,7 +424,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.getActiveSubscriptionInfoForIccId(iccId); + result = iSub.getActiveSubscriptionInfoForIccId(iccId, mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -456,7 +450,8 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.getActiveSubscriptionInfoForSimSlotIndex(slotIdx); + result = iSub.getActiveSubscriptionInfoForSimSlotIndex(slotIdx, + mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -478,7 +473,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.getAllSubInfoList(); + result = iSub.getAllSubInfoList(mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -516,7 +511,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.getActiveSubscriptionInfoList(); + result = iSub.getActiveSubscriptionInfoList(mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -537,7 +532,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.getAllSubInfoCount(); + result = iSub.getAllSubInfoCount(mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -557,7 +552,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.getActiveSubInfoCount(); + result = iSub.getActiveSubInfoCount(mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -606,7 +601,7 @@ public class SubscriptionManager { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { // FIXME: This returns 1 on success, 0 on error should should we return it? - iSub.addSubInfoRecord(iccId, slotId); + iSub.addSubInfoRecord(iccId, slotId, mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -636,7 +631,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.setIconTint(tint, subId); + result = iSub.setIconTint(tint, subId, mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -681,7 +676,8 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.setDisplayNameUsingSrc(displayName, subId, nameSource); + result = iSub.setDisplayNameUsingSrc(displayName, subId, nameSource, + mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -709,7 +705,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.setDisplayNumber(number, subId); + result = iSub.setDisplayNumber(number, subId, mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -738,7 +734,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - result = iSub.setDataRoaming(roaming, subId); + result = iSub.setDataRoaming(roaming, subId, mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -973,7 +969,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - iSub.clearSubInfo(); + iSub.clearSubInfo(mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it @@ -1007,7 +1003,7 @@ public class SubscriptionManager { try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); if (iSub != null) { - iSub.clearDefaultsForInactiveSubIds(); + iSub.clearDefaultsForInactiveSubIds(mContext.getOpPackageName()); } } catch (RemoteException ex) { // ignore it diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index d0a1dc2..d674b31 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -42,9 +42,7 @@ import com.android.internal.telephony.TelephonyProperties; import java.io.FileInputStream; import java.io.IOException; -import java.util.Arrays; import java.util.List; -import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -259,11 +257,19 @@ public class TelephonyManager { * <p> * Output: nothing. */ - @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + @SdkConstant(SdkConstantType.SERVICE_ACTION) public static final String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; /** + * The emergency dialer may choose to present activities with intent filters for this + * action as emergency assistance buttons that launch the activity when clicked. + */ + @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) + public static final String ACTION_EMERGENCY_ASSISTANCE = + "android.telephony.action.EMERGENCY_ASSISTANCE"; + + /** * The lookup key used with the {@link #ACTION_PHONE_STATE_CHANGED} broadcast * for a String containing the new call state. * @@ -568,6 +574,37 @@ public class TelephonyManager { */ public static final String EXTRA_DATA_FAILURE_CAUSE = PhoneConstants.DATA_FAILURE_CAUSE_KEY; + /** + * Response codes for sim activation. Activation completed successfully. + * @hide + */ + @SystemApi + public static final int SIM_ACTIVATION_RESULT_COMPLETE = 0; + /** + * Response codes for sim activation. Activation not supported (device has no SIM). + * @hide + */ + @SystemApi + public static final int SIM_ACTIVATION_RESULT_NOT_SUPPORTED = 1; + /** + * Response codes for sim activation. Activation is in progress. + * @hide + */ + @SystemApi + public static final int SIM_ACTIVATION_RESULT_IN_PROGRESS = 2; + /** + * Response codes for sim activation. Activation failed to complete. + * @hide + */ + @SystemApi + public static final int SIM_ACTIVATION_RESULT_FAILED = 3; + /** + * Response codes for sim activation. Activation canceled by user. + * @hide + */ + @SystemApi + public static final int SIM_ACTIVATION_RESULT_CANCELED = 4; + // // // Device Info @@ -604,7 +641,10 @@ public class TelephonyManager { return null; } try { - return getSubscriberInfo().getDeviceSvnUsingSubId(subId[0]); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getDeviceSvnUsingSubId(subId[0]); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -621,7 +661,10 @@ public class TelephonyManager { */ public String getDeviceId() { try { - return getITelephony().getDeviceId(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getDeviceId(mContext.getOpPackageName()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -641,7 +684,10 @@ public class TelephonyManager { public String getDeviceId(int slotId) { // FIXME this assumes phoneId == slotId try { - return getSubscriberInfo().getDeviceIdForPhone(slotId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getDeviceIdForPhone(slotId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -672,7 +718,10 @@ public class TelephonyManager { public String getImei(int slotId) { int[] subId = SubscriptionManager.getSubId(slotId); try { - return getSubscriberInfo().getImeiForSubscriber(subId[0]); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getImeiForSubscriber(subId[0]); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -698,7 +747,10 @@ public class TelephonyManager { public String getNai(int slotId) { int[] subId = SubscriptionManager.getSubId(slotId); try { - String nai = getSubscriberInfo().getNaiForSubscriber(subId[0]); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + String nai = info.getNaiForSubscriber(subId[0]); if (Log.isLoggable(TAG, Log.VERBOSE)) { Rlog.v(TAG, "Nai = " + nai); } @@ -727,7 +779,10 @@ public class TelephonyManager { */ public CellLocation getCellLocation() { try { - Bundle bundle = getITelephony().getCellLocation(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + Bundle bundle = telephony.getCellLocation(mContext.getOpPackageName()); if (bundle.isEmpty()) return null; CellLocation cl = CellLocation.newFromBundle(bundle); if (cl.isEmpty()) @@ -766,7 +821,9 @@ public class TelephonyManager { /** @hide */ public void enableLocationUpdates(int subId) { try { - getITelephony().enableLocationUpdatesForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.enableLocationUpdatesForSubscriber(subId); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -788,7 +845,9 @@ public class TelephonyManager { /** @hide */ public void disableLocationUpdates(int subId) { try { - getITelephony().disableLocationUpdatesForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.disableLocationUpdatesForSubscriber(subId); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -807,7 +866,10 @@ public class TelephonyManager { */ public List<NeighboringCellInfo> getNeighboringCellInfo() { try { - return getITelephony().getNeighboringCellInfo(mContext.getOpPackageName()); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getNeighboringCellInfo(mContext.getOpPackageName()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1513,7 +1575,10 @@ public class TelephonyManager { public boolean hasIccCard(int slotId) { try { - return getITelephony().hasIccCardUsingSlotId(slotId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return false; + return telephony.hasIccCardUsingSlotId(slotId); } catch (RemoteException ex) { // Assume no ICC card if remote exception which shouldn't happen return false; @@ -1745,7 +1810,10 @@ public class TelephonyManager { /** {@hide} */ public String getSimSerialNumber(int subId) { try { - return getSubscriberInfo().getIccSerialNumberForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIccSerialNumberForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1781,7 +1849,10 @@ public class TelephonyManager { /** {@hide} */ public int getLteOnCdmaMode(int subId) { try { - return getITelephony().getLteOnCdmaModeForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return PhoneConstants.LTE_ON_CDMA_UNKNOWN; + return telephony.getLteOnCdmaModeForSubscriber(subId); } catch (RemoteException ex) { // Assume no ICC card if remote exception which shouldn't happen return PhoneConstants.LTE_ON_CDMA_UNKNOWN; @@ -1821,7 +1892,10 @@ public class TelephonyManager { /** {@hide} */ public String getSubscriberId(int subId) { try { - return getSubscriberInfo().getSubscriberIdForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getSubscriberIdForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1839,7 +1913,10 @@ public class TelephonyManager { */ public String getGroupIdLevel1() { try { - return getSubscriberInfo().getGroupIdLevel1(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getGroupIdLevel1(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1860,7 +1937,10 @@ public class TelephonyManager { /** {@hide} */ public String getGroupIdLevel1(int subId) { try { - return getSubscriberInfo().getGroupIdLevel1ForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getGroupIdLevel1ForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1893,7 +1973,9 @@ public class TelephonyManager { public String getLine1NumberForSubscriber(int subId) { String number = null; try { - number = getITelephony().getLine1NumberForDisplay(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + number = telephony.getLine1NumberForDisplay(subId, mContext.getOpPackageName()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -1901,7 +1983,10 @@ public class TelephonyManager { return number; } try { - return getSubscriberInfo().getLine1NumberForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getLine1NumberForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1944,7 +2029,9 @@ public class TelephonyManager { */ public boolean setLine1NumberForDisplayForSubscriber(int subId, String alphaTag, String number) { try { - return getITelephony().setLine1NumberForDisplayForSubscriber(subId, alphaTag, number); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setLine1NumberForDisplayForSubscriber(subId, alphaTag, number); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -1952,6 +2039,35 @@ public class TelephonyManager { } /** + * Informs the system of an intentional upcoming carrier network change by + * a carrier app. This call is optional and is only used to allow the + * system to provide alternative UI while telephony is performing an action + * that may result in intentional, temporary network lack of connectivity. + * <p> + * Based on the active parameter passed in, this method will either show or + * hide the alternative UI. There is no timeout associated with showing + * this UX, so a carrier app must be sure to call with active set to false + * sometime after calling with it set to true. + * <p> + * Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * Or the calling app has carrier privileges. + * @see #hasCarrierPrivileges + * + * @param active Whether the carrier network change is or shortly will be + * active. Set this value to true to begin showing + * alternative UI and false to stop. + */ + public void notifyCarrierNetworkChange(boolean active) { + try { + if (sRegistry != null) + sRegistry.notifyCarrierNetworkChange(active); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + } + + /** * Returns the alphabetic identifier associated with the line 1 number. * Return null if it is unavailable. * <p> @@ -1978,7 +2094,10 @@ public class TelephonyManager { public String getLine1AlphaTagForSubscriber(int subId) { String alphaTag = null; try { - alphaTag = getITelephony().getLine1AlphaTagForDisplay(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + alphaTag = telephony.getLine1AlphaTagForDisplay(subId, + mContext.getOpPackageName()); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -1986,7 +2105,10 @@ public class TelephonyManager { return alphaTag; } try { - return getSubscriberInfo().getLine1AlphaTagForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getLine1AlphaTagForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2005,7 +2127,9 @@ public class TelephonyManager { */ public @Nullable String[] getMergedSubscriberIds() { try { - return getITelephony().getMergedSubscriberIds(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getMergedSubscriberIds(); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2037,7 +2161,10 @@ public class TelephonyManager { /** {@hide} */ public String getMsisdn(int subId) { try { - return getSubscriberInfo().getMsisdnForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getMsisdnForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2067,7 +2194,10 @@ public class TelephonyManager { /** {@hide} */ public String getVoiceMailNumber(int subId) { try { - return getSubscriberInfo().getVoiceMailNumberForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getVoiceMailNumberForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2099,7 +2229,10 @@ public class TelephonyManager { /** {@hide} */ public String getCompleteVoiceMailNumber(int subId) { try { - return getSubscriberInfo().getCompleteVoiceMailNumberForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getCompleteVoiceMailNumberForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2134,7 +2267,9 @@ public class TelephonyManager { /** {@hide} */ public boolean setVoiceMailNumber(int subId, String alphaTag, String number) { try { - return getITelephony().setVoiceMailNumber(subId, alphaTag, number); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setVoiceMailNumber(subId, alphaTag, number); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2162,7 +2297,10 @@ public class TelephonyManager { /** {@hide} */ public int getVoiceMessageCount(int subId) { try { - return getITelephony().getVoiceMessageCountForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return 0; + return telephony.getVoiceMessageCountForSubscriber(subId); } catch (RemoteException ex) { return 0; } catch (NullPointerException ex) { @@ -2194,7 +2332,10 @@ public class TelephonyManager { /** {@hide} */ public String getVoiceMailAlphaTag(int subId) { try { - return getSubscriberInfo().getVoiceMailAlphaTagForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getVoiceMailAlphaTagForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2210,7 +2351,10 @@ public class TelephonyManager { */ public String getIsimImpi() { try { - return getSubscriberInfo().getIsimImpi(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimImpi(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2226,7 +2370,10 @@ public class TelephonyManager { */ public String getIsimDomain() { try { - return getSubscriberInfo().getIsimDomain(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimDomain(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2243,7 +2390,10 @@ public class TelephonyManager { */ public String[] getIsimImpu() { try { - return getSubscriberInfo().getIsimImpu(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimImpu(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2275,11 +2425,7 @@ public class TelephonyManager { * Returns a constant indicating the call state (cellular) on the device. */ public int getCallState() { - try { - return getTelecomService().getCallState(); - } catch (RemoteException | NullPointerException e) { - return CALL_STATE_IDLE; - } + return getCallState(getDefaultSubscription()); } /** @@ -2291,7 +2437,10 @@ public class TelephonyManager { /** {@hide} */ public int getCallState(int subId) { try { - return getITelephony().getCallStateForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return CALL_STATE_IDLE; + return telephony.getCallStateForSubscriber(subId); } catch (RemoteException ex) { // the phone process is restarting. return CALL_STATE_IDLE; @@ -2327,7 +2476,10 @@ public class TelephonyManager { */ public int getDataActivity() { try { - return getITelephony().getDataActivity(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return DATA_ACTIVITY_NONE; + return telephony.getDataActivity(); } catch (RemoteException ex) { // the phone process is restarting. return DATA_ACTIVITY_NONE; @@ -2363,7 +2515,10 @@ public class TelephonyManager { */ public int getDataState() { try { - return getITelephony().getDataState(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return DATA_DISCONNECTED; + return telephony.getDataState(); } catch (RemoteException ex) { // the phone process is restarting. return DATA_DISCONNECTED; @@ -2416,10 +2571,11 @@ public class TelephonyManager { * LISTEN_ flags. */ public void listen(PhoneStateListener listener, int events) { - String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>"; + if (mContext == null) return; try { Boolean notifyNow = (getITelephony() != null); - sRegistry.listenForSubscriber(listener.mSubId, pkgForDebug, listener.callback, events, notifyNow); + sRegistry.listenForSubscriber(listener.mSubId, mContext.getOpPackageName(), + listener.callback, events, notifyNow); } catch (RemoteException ex) { // system process dead } catch (NullPointerException ex) { @@ -2442,7 +2598,10 @@ public class TelephonyManager { /** {@hide} */ public int getCdmaEriIconIndex(int subId) { try { - return getITelephony().getCdmaEriIconIndexForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return -1; + return telephony.getCdmaEriIconIndexForSubscriber(subId); } catch (RemoteException ex) { // the phone process is restarting. return -1; @@ -2470,7 +2629,10 @@ public class TelephonyManager { /** {@hide} */ public int getCdmaEriIconMode(int subId) { try { - return getITelephony().getCdmaEriIconModeForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return -1; + return telephony.getCdmaEriIconModeForSubscriber(subId); } catch (RemoteException ex) { // the phone process is restarting. return -1; @@ -2495,7 +2657,10 @@ public class TelephonyManager { /** {@hide} */ public String getCdmaEriText(int subId) { try { - return getITelephony().getCdmaEriTextForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getCdmaEriTextForSubscriber(subId); } catch (RemoteException ex) { // the phone process is restarting. return null; @@ -2562,7 +2727,10 @@ public class TelephonyManager { */ public List<CellInfo> getAllCellInfo() { try { - return getITelephony().getAllCellInfo(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getAllCellInfo(mContext.getOpPackageName()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2584,7 +2752,9 @@ public class TelephonyManager { */ public void setCellInfoListRate(int rateInMillis) { try { - getITelephony().setCellInfoListRate(rateInMillis); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.setCellInfoListRate(rateInMillis); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2622,7 +2792,9 @@ public class TelephonyManager { */ public IccOpenLogicalChannelResponse iccOpenLogicalChannel(String AID) { try { - return getITelephony().iccOpenLogicalChannel(AID); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccOpenLogicalChannel(AID); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2644,7 +2816,9 @@ public class TelephonyManager { */ public boolean iccCloseLogicalChannel(int channel) { try { - return getITelephony().iccCloseLogicalChannel(channel); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccCloseLogicalChannel(channel); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2675,7 +2849,9 @@ public class TelephonyManager { public String iccTransmitApduLogicalChannel(int channel, int cla, int instruction, int p1, int p2, int p3, String data) { try { - return getITelephony().iccTransmitApduLogicalChannel(channel, cla, + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccTransmitApduLogicalChannel(channel, cla, instruction, p1, p2, p3, data); } catch (RemoteException ex) { } catch (NullPointerException ex) { @@ -2705,7 +2881,9 @@ public class TelephonyManager { public String iccTransmitApduBasicChannel(int cla, int instruction, int p1, int p2, int p3, String data) { try { - return getITelephony().iccTransmitApduBasicChannel(cla, + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccTransmitApduBasicChannel(cla, instruction, p1, p2, p3, data); } catch (RemoteException ex) { } catch (NullPointerException ex) { @@ -2731,8 +2909,9 @@ public class TelephonyManager { public byte[] iccExchangeSimIO(int fileID, int command, int p1, int p2, int p3, String filePath) { try { - return getITelephony().iccExchangeSimIO(fileID, command, p1, p2, - p3, filePath); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccExchangeSimIO(fileID, command, p1, p2, p3, filePath); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2755,7 +2934,9 @@ public class TelephonyManager { */ public String sendEnvelopeWithStatus(String content) { try { - return getITelephony().sendEnvelopeWithStatus(content); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.sendEnvelopeWithStatus(content); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2777,7 +2958,9 @@ public class TelephonyManager { */ public String nvReadItem(int itemID) { try { - return getITelephony().nvReadItem(itemID); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.nvReadItem(itemID); } catch (RemoteException ex) { Rlog.e(TAG, "nvReadItem RemoteException", ex); } catch (NullPointerException ex) { @@ -2802,7 +2985,9 @@ public class TelephonyManager { */ public boolean nvWriteItem(int itemID, String itemValue) { try { - return getITelephony().nvWriteItem(itemID, itemValue); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.nvWriteItem(itemID, itemValue); } catch (RemoteException ex) { Rlog.e(TAG, "nvWriteItem RemoteException", ex); } catch (NullPointerException ex) { @@ -2826,7 +3011,9 @@ public class TelephonyManager { */ public boolean nvWriteCdmaPrl(byte[] preferredRoamingList) { try { - return getITelephony().nvWriteCdmaPrl(preferredRoamingList); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.nvWriteCdmaPrl(preferredRoamingList); } catch (RemoteException ex) { Rlog.e(TAG, "nvWriteCdmaPrl RemoteException", ex); } catch (NullPointerException ex) { @@ -2851,7 +3038,9 @@ public class TelephonyManager { */ public boolean nvResetConfig(int resetType) { try { - return getITelephony().nvResetConfig(resetType); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.nvResetConfig(resetType); } catch (RemoteException ex) { Rlog.e(TAG, "nvResetConfig RemoteException", ex); } catch (NullPointerException ex) { @@ -3055,7 +3244,10 @@ public class TelephonyManager { */ public String getIsimIst() { try { - return getSubscriberInfo().getIsimIst(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimIst(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3072,7 +3264,10 @@ public class TelephonyManager { */ public String[] getIsimPcscf() { try { - return getSubscriberInfo().getIsimPcscf(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimPcscf(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3091,7 +3286,10 @@ public class TelephonyManager { */ public String getIsimChallengeResponse(String nonce){ try { - return getSubscriberInfo().getIsimChallengeResponse(nonce); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimChallengeResponse(nonce); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3111,7 +3309,10 @@ public class TelephonyManager { */ public String getIccSimChallengeResponse(int subId, int appType, String data) { try { - return getSubscriberInfo().getIccSimChallengeResponse(subId, appType, data); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIccSimChallengeResponse(subId, appType, data); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3140,7 +3341,10 @@ public class TelephonyManager { */ public String[] getPcscfAddress(String apnType) { try { - return getITelephony().getPcscfAddress(apnType); + ITelephony telephony = getITelephony(); + if (telephony == null) + return new String[0]; + return telephony.getPcscfAddress(apnType, mContext.getOpPackageName()); } catch (RemoteException e) { return new String[0]; } @@ -3154,7 +3358,9 @@ public class TelephonyManager { */ public void setImsRegistrationState(boolean registered) { try { - getITelephony().setImsRegistrationState(registered); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.setImsRegistrationState(registered); } catch (RemoteException e) { } } @@ -3170,9 +3376,11 @@ public class TelephonyManager { * @return the preferred network type, defined in RILConstants.java. * @hide */ - public int getPreferredNetworkType() { + public int getPreferredNetworkType(int subId) { try { - return getITelephony().getPreferredNetworkType(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getPreferredNetworkType(subId); } catch (RemoteException ex) { Rlog.e(TAG, "getPreferredNetworkType RemoteException", ex); } catch (NullPointerException ex) { @@ -3182,6 +3390,27 @@ public class TelephonyManager { } /** + * Sets the network selection mode to automatic. + * <p> + * Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + * @hide + */ + public void setNetworkSelectionModeAutomatic(int subId) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.setNetworkSelectionModeAutomatic(subId); + } catch (RemoteException ex) { + Rlog.e(TAG, "setNetworkSelectionModeAutomatic RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "setNetworkSelectionModeAutomatic NPE", ex); + } + } + + /** * Set the preferred network type. * Used for device configuration by some CDMA operators. * <p> @@ -3189,13 +3418,16 @@ public class TelephonyManager { * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} * Or the calling app has carrier privileges. @see #hasCarrierPrivileges * + * @param subId the id of the subscription to set the preferred network type for. * @param networkType the preferred network type, defined in RILConstants.java. * @return true on success; false on any failure. * @hide */ - public boolean setPreferredNetworkType(int networkType) { + public boolean setPreferredNetworkType(int subId, int networkType) { try { - return getITelephony().setPreferredNetworkType(networkType); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setPreferredNetworkType(subId, networkType); } catch (RemoteException ex) { Rlog.e(TAG, "setPreferredNetworkType RemoteException", ex); } catch (NullPointerException ex) { @@ -3214,7 +3446,8 @@ public class TelephonyManager { * @return true on success; false on any failure. */ public boolean setPreferredNetworkTypeToGlobal() { - return setPreferredNetworkType(RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA); + return setPreferredNetworkType(getDefaultSubscription(), + RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA); } /** @@ -3227,7 +3460,9 @@ public class TelephonyManager { */ public int getTetherApnRequired() { try { - return getITelephony().getTetherApnRequired(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getTetherApnRequired(); } catch (RemoteException ex) { Rlog.e(TAG, "hasMatchedTetherApnSetting RemoteException", ex); } catch (NullPointerException ex) { @@ -3260,8 +3495,9 @@ public class TelephonyManager { */ public boolean hasCarrierPrivileges() { try { - return getITelephony().getCarrierPrivilegeStatus() == - CARRIER_PRIVILEGE_STATUS_HAS_ACCESS; + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getCarrierPrivilegeStatus() == CARRIER_PRIVILEGE_STATUS_HAS_ACCESS; } catch (RemoteException ex) { Rlog.e(TAG, "hasCarrierPrivileges RemoteException", ex); } catch (NullPointerException ex) { @@ -3286,7 +3522,9 @@ public class TelephonyManager { */ public boolean setOperatorBrandOverride(String brand) { try { - return getITelephony().setOperatorBrandOverride(brand); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setOperatorBrandOverride(brand); } catch (RemoteException ex) { Rlog.e(TAG, "setOperatorBrandOverride RemoteException", ex); } catch (NullPointerException ex) { @@ -3318,8 +3556,10 @@ public class TelephonyManager { List<String> gsmNonRoamingList, List<String> cdmaRoamingList, List<String> cdmaNonRoamingList) { try { - return getITelephony().setRoamingOverride(gsmRoamingList, gsmNonRoamingList, - cdmaRoamingList, cdmaNonRoamingList); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setRoamingOverride(gsmRoamingList, gsmNonRoamingList, + cdmaRoamingList, cdmaNonRoamingList); } catch (RemoteException ex) { Rlog.e(TAG, "setRoamingOverride RemoteException", ex); } catch (NullPointerException ex) { @@ -3342,7 +3582,10 @@ public class TelephonyManager { @SystemApi public String getCdmaMdn(int subId) { try { - return getITelephony().getCdmaMdn(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getCdmaMdn(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3360,7 +3603,10 @@ public class TelephonyManager { @SystemApi public String getCdmaMin(int subId) { try { - return getITelephony().getCdmaMin(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getCdmaMin(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3372,7 +3618,9 @@ public class TelephonyManager { @SystemApi public int checkCarrierPrivilegesForPackage(String pkgname) { try { - return getITelephony().checkCarrierPrivilegesForPackage(pkgname); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.checkCarrierPrivilegesForPackage(pkgname); } catch (RemoteException ex) { Rlog.e(TAG, "checkCarrierPrivilegesForPackage RemoteException", ex); } catch (NullPointerException ex) { @@ -3384,12 +3632,20 @@ public class TelephonyManager { /** @hide */ @SystemApi public List<String> getCarrierPackageNamesForIntent(Intent intent) { + return getCarrierPackageNamesForIntentAndPhone(intent, getDefaultPhone()); + } + + /** @hide */ + @SystemApi + public List<String> getCarrierPackageNamesForIntentAndPhone(Intent intent, int phoneId) { try { - return getITelephony().getCarrierPackageNamesForIntent(intent); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getCarrierPackageNamesForIntentAndPhone(intent, phoneId); } catch (RemoteException ex) { - Rlog.e(TAG, "getCarrierPackageNamesForIntent RemoteException", ex); + Rlog.e(TAG, "getCarrierPackageNamesForIntentAndPhone RemoteException", ex); } catch (NullPointerException ex) { - Rlog.e(TAG, "getCarrierPackageNamesForIntent NPE", ex); + Rlog.e(TAG, "getCarrierPackageNamesForIntentAndPhone NPE", ex); } return null; } @@ -3398,7 +3654,9 @@ public class TelephonyManager { @SystemApi public void dial(String number) { try { - getITelephony().dial(number); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.dial(number); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#dial", e); } @@ -3408,7 +3666,9 @@ public class TelephonyManager { @SystemApi public void call(String callingPackage, String number) { try { - getITelephony().call(callingPackage, number); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.call(callingPackage, number); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#call", e); } @@ -3418,7 +3678,9 @@ public class TelephonyManager { @SystemApi public boolean endCall() { try { - return getITelephony().endCall(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.endCall(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#endCall", e); } @@ -3429,7 +3691,9 @@ public class TelephonyManager { @SystemApi public void answerRingingCall() { try { - getITelephony().answerRingingCall(); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.answerRingingCall(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#answerRingingCall", e); } @@ -3439,7 +3703,7 @@ public class TelephonyManager { @SystemApi public void silenceRinger() { try { - getTelecomService().silenceRinger(); + getTelecomService().silenceRinger(mContext.getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelecomService#silenceRinger", e); } @@ -3449,7 +3713,9 @@ public class TelephonyManager { @SystemApi public boolean isOffhook() { try { - return getITelephony().isOffhook(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isOffhook(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isOffhook", e); } @@ -3460,7 +3726,9 @@ public class TelephonyManager { @SystemApi public boolean isRinging() { try { - return getITelephony().isRinging(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isRinging(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isRinging", e); } @@ -3471,7 +3739,9 @@ public class TelephonyManager { @SystemApi public boolean isIdle() { try { - return getITelephony().isIdle(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isIdle(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isIdle", e); } @@ -3482,7 +3752,9 @@ public class TelephonyManager { @SystemApi public boolean isRadioOn() { try { - return getITelephony().isRadioOn(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isRadioOn(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isRadioOn", e); } @@ -3493,7 +3765,9 @@ public class TelephonyManager { @SystemApi public boolean isSimPinEnabled() { try { - return getITelephony().isSimPinEnabled(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isSimPinEnabled(mContext.getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isSimPinEnabled", e); } @@ -3504,7 +3778,9 @@ public class TelephonyManager { @SystemApi public boolean supplyPin(String pin) { try { - return getITelephony().supplyPin(pin); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.supplyPin(pin); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#supplyPin", e); } @@ -3515,7 +3791,9 @@ public class TelephonyManager { @SystemApi public boolean supplyPuk(String puk, String pin) { try { - return getITelephony().supplyPuk(puk, pin); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.supplyPuk(puk, pin); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#supplyPuk", e); } @@ -3526,7 +3804,9 @@ public class TelephonyManager { @SystemApi public int[] supplyPinReportResult(String pin) { try { - return getITelephony().supplyPinReportResult(pin); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.supplyPinReportResult(pin); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#supplyPinReportResult", e); } @@ -3537,7 +3817,9 @@ public class TelephonyManager { @SystemApi public int[] supplyPukReportResult(String puk, String pin) { try { - return getITelephony().supplyPukReportResult(puk, pin); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.supplyPukReportResult(puk, pin); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#]", e); } @@ -3548,7 +3830,9 @@ public class TelephonyManager { @SystemApi public boolean handlePinMmi(String dialString) { try { - return getITelephony().handlePinMmi(dialString); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.handlePinMmi(dialString); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#handlePinMmi", e); } @@ -3559,7 +3843,9 @@ public class TelephonyManager { @SystemApi public boolean handlePinMmiForSubscriber(int subId, String dialString) { try { - return getITelephony().handlePinMmiForSubscriber(subId, dialString); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.handlePinMmiForSubscriber(subId, dialString); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#handlePinMmi", e); } @@ -3570,7 +3856,9 @@ public class TelephonyManager { @SystemApi public void toggleRadioOnOff() { try { - getITelephony().toggleRadioOnOff(); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.toggleRadioOnOff(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#toggleRadioOnOff", e); } @@ -3580,7 +3868,9 @@ public class TelephonyManager { @SystemApi public boolean setRadio(boolean turnOn) { try { - return getITelephony().setRadio(turnOn); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setRadio(turnOn); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setRadio", e); } @@ -3591,7 +3881,9 @@ public class TelephonyManager { @SystemApi public boolean setRadioPower(boolean turnOn) { try { - return getITelephony().setRadioPower(turnOn); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setRadioPower(turnOn); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setRadioPower", e); } @@ -3602,7 +3894,9 @@ public class TelephonyManager { @SystemApi public void updateServiceLocation() { try { - getITelephony().updateServiceLocation(); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.updateServiceLocation(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#updateServiceLocation", e); } @@ -3612,7 +3906,9 @@ public class TelephonyManager { @SystemApi public boolean enableDataConnectivity() { try { - return getITelephony().enableDataConnectivity(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.enableDataConnectivity(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#enableDataConnectivity", e); } @@ -3623,7 +3919,9 @@ public class TelephonyManager { @SystemApi public boolean disableDataConnectivity() { try { - return getITelephony().disableDataConnectivity(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.disableDataConnectivity(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#disableDataConnectivity", e); } @@ -3634,7 +3932,9 @@ public class TelephonyManager { @SystemApi public boolean isDataConnectivityPossible() { try { - return getITelephony().isDataConnectivityPossible(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isDataConnectivityPossible(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isDataConnectivityPossible", e); } @@ -3645,7 +3945,9 @@ public class TelephonyManager { @SystemApi public boolean needsOtaServiceProvisioning() { try { - return getITelephony().needsOtaServiceProvisioning(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.needsOtaServiceProvisioning(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#needsOtaServiceProvisioning", e); } @@ -3663,7 +3965,9 @@ public class TelephonyManager { public void setDataEnabled(int subId, boolean enable) { try { Log.d(TAG, "setDataEnabled: enabled=" + enable); - getITelephony().setDataEnabled(subId, enable); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.setDataEnabled(subId, enable); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setDataEnabled", e); } @@ -3680,7 +3984,9 @@ public class TelephonyManager { public boolean getDataEnabled(int subId) { boolean retVal = false; try { - retVal = getITelephony().getDataEnabled(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + retVal = telephony.getDataEnabled(subId); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#getDataEnabled", e); } catch (NullPointerException e) { @@ -3701,7 +4007,9 @@ public class TelephonyManager { */ public int invokeOemRilRequestRaw(byte[] oemReq, byte[] oemResp) { try { - return getITelephony().invokeOemRilRequestRaw(oemReq, oemResp); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.invokeOemRilRequestRaw(oemReq, oemResp); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -3712,7 +4020,9 @@ public class TelephonyManager { @SystemApi public void enableVideoCalling(boolean enable) { try { - getITelephony().enableVideoCalling(enable); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.enableVideoCalling(enable); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#enableVideoCalling", e); } @@ -3722,7 +4032,9 @@ public class TelephonyManager { @SystemApi public boolean isVideoCallingEnabled() { try { - return getITelephony().isVideoCallingEnabled(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isVideoCallingEnabled(mContext.getOpPackageName()); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isVideoCallingEnabled", e); } @@ -3730,12 +4042,72 @@ public class TelephonyManager { } /** - * This function retrieves value for setting "name+subId", and if that is not found - * retrieves value for setting "name", and if that is not found uses def as default + * Whether the device supports configuring the DTMF tone length. * - * @hide */ - public static int getIntWithSubId(ContentResolver cr, String name, int subId, int def) { - return Settings.Global.getInt(cr, name + subId, Settings.Global.getInt(cr, name, def)); + * @return {@code true} if the DTMF tone length can be changed, and {@code false} otherwise. + */ + public boolean canChangeDtmfToneLength() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.canChangeDtmfToneLength(); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#canChangeDtmfToneLength", e); + } + return false; + } + + /** + * Whether the device is a world phone. + * + * @return {@code true} if the device is a world phone, and {@code false} otherwise. + */ + public boolean isWorldPhone() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isWorldPhone(); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#isWorldPhone", e); + } + return false; + } + + /** + * Whether the phone supports TTY mode. + * + * @return {@code true} if the device supports TTY mode, and {@code false} otherwise. + */ + public boolean isTtyModeSupported() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isTtyModeSupported(); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#isTtyModeSupported", e); + } + return false; + } + + /** + * Whether the phone supports hearing aid compatibility. + * + * @return {@code true} if the device supports hearing aid compatibility, and {@code false} + * otherwise. + */ + public boolean isHearingAidCompatibilitySupported() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.isHearingAidCompatibilitySupported(); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#isHearingAidCompatibilitySupported", e); + } + return false; } /** @@ -3782,7 +4154,10 @@ public class TelephonyManager { */ public boolean isImsRegistered() { try { - return getITelephony().isImsRegistered(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return false; + return telephony.isImsRegistered(); } catch (RemoteException ex) { return false; } catch (NullPointerException ex) { @@ -4174,4 +4549,19 @@ public class TelephonyManager { return retval; } + + /** + * Resets telephony manager settings back to factory defaults. + * + * @hide + */ + public void factoryReset(int subId) { + try { + Log.d(TAG, "factoryReset: subId=" + subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.factoryReset(subId); + } catch (RemoteException e) { + } + } } diff --git a/telephony/java/android/telephony/gsm/GsmCellLocation.java b/telephony/java/android/telephony/gsm/GsmCellLocation.java index 313bc82..a3889b2 100644 --- a/telephony/java/android/telephony/gsm/GsmCellLocation.java +++ b/telephony/java/android/telephony/gsm/GsmCellLocation.java @@ -40,9 +40,9 @@ public class GsmCellLocation extends CellLocation { * Initialize the object from a bundle. */ public GsmCellLocation(Bundle bundle) { - mLac = bundle.getInt("lac", mLac); - mCid = bundle.getInt("cid", mCid); - mPsc = bundle.getInt("psc", mPsc); + mLac = bundle.getInt("lac", -1); + mCid = bundle.getInt("cid", -1); + mPsc = bundle.getInt("psc", -1); } /** diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java index aae7617..c754068 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java +++ b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java @@ -34,7 +34,6 @@ import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.telephony.Rlog; import android.telephony.SubscriptionManager; -import android.util.Log; /** * Helper class to make it easier to run asynchronous caller-id lookup queries. diff --git a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl index cea62ba..cbedb95 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -44,5 +44,6 @@ oneway interface IPhoneStateListener { void onDataConnectionRealTimeInfoChanged(in DataConnectionRealTimeInfo dcRtInfo); void onVoLteServiceStateChanged(in VoLteServiceState lteState); void onOemHookRawEvent(in byte[] rawData); + void onCarrierNetworkChange(in boolean active); } diff --git a/telephony/java/com/android/internal/telephony/ISms.aidl b/telephony/java/com/android/internal/telephony/ISms.aidl index f37ae5a..21c94c2 100644 --- a/telephony/java/com/android/internal/telephony/ISms.aidl +++ b/telephony/java/com/android/internal/telephony/ISms.aidl @@ -99,6 +99,34 @@ interface ISms { in PendingIntent deliveryIntent); /** + * Send a data SMS. Only for use internally. + * + * @param smsc the SMSC to send the message through, or NULL for the + * default SMSC + * @param data the body of the message to send + * @param sentIntent if not NULL this <code>PendingIntent</code> is + * broadcast when the message is sucessfully sent, or failed. + * The result code will be <code>Activity.RESULT_OK<code> for success, + * or one of these errors:<br> + * <code>RESULT_ERROR_GENERIC_FAILURE</code><br> + * <code>RESULT_ERROR_RADIO_OFF</code><br> + * <code>RESULT_ERROR_NULL_PDU</code><br> + * For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include + * the extra "errorCode" containing a radio technology specific value, + * generally only useful for troubleshooting.<br> + * The per-application based SMS control checks sentIntent. If sentIntent + * is NULL the caller will be checked against all unknown applicaitons, + * which cause smaller number of SMS to be sent in checking period. + * @param deliveryIntent if not NULL this <code>PendingIntent</code> is + * broadcast when the message is delivered to the recipient. The + * raw pdu of the status report is in the extended data ("pdu"). + * @param subId the subId id. + */ + void sendDataForSubscriberWithSelfPermissions(int subId, String callingPkg, in String destAddr, + in String scAddr, in int destPort, in byte[] data, in PendingIntent sentIntent, + in PendingIntent deliveryIntent); + + /** * Send an SMS. * * @param smsc the SMSC to send the message through, or NULL for the @@ -127,6 +155,34 @@ interface ISms { in PendingIntent deliveryIntent); /** + * Send an SMS. Internal use only. + * + * @param smsc the SMSC to send the message through, or NULL for the + * default SMSC + * @param text the body of the message to send + * @param sentIntent if not NULL this <code>PendingIntent</code> is + * broadcast when the message is sucessfully sent, or failed. + * The result code will be <code>Activity.RESULT_OK<code> for success, + * or one of these errors:<br> + * <code>RESULT_ERROR_GENERIC_FAILURE</code><br> + * <code>RESULT_ERROR_RADIO_OFF</code><br> + * <code>RESULT_ERROR_NULL_PDU</code><br> + * For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include + * the extra "errorCode" containing a radio technology specific value, + * generally only useful for troubleshooting.<br> + * The per-application based SMS control checks sentIntent. If sentIntent + * is NULL the caller will be checked against all unknown applications, + * which cause smaller number of SMS to be sent in checking period. + * @param deliveryIntent if not NULL this <code>PendingIntent</code> is + * broadcast when the message is delivered to the recipient. The + * raw pdu of the status report is in the extended data ("pdu"). + * @param subId the subId on which the SMS has to be sent. + */ + void sendTextForSubscriberWithSelfPermissions(in int subId, String callingPkg, + in String destAddr, in String scAddr, in String text, in PendingIntent sentIntent, + in PendingIntent deliveryIntent); + + /** * Inject an SMS PDU into the android platform. * * @param subId the subId on which the SMS has to be injected. diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl index c12137d..1037f2d 100755 --- a/telephony/java/com/android/internal/telephony/ISub.aidl +++ b/telephony/java/com/android/internal/telephony/ISub.aidl @@ -22,42 +22,48 @@ import com.android.internal.telephony.ISubscriptionListener; interface ISub { /** + * @param callingPackage The package maing the call. * @return a list of all subscriptions in the database, this includes * all subscriptions that have been seen. */ - List<SubscriptionInfo> getAllSubInfoList(); + List<SubscriptionInfo> getAllSubInfoList(String callingPackage); /** + * @param callingPackage The package maing the call. * @return the count of all subscriptions in the database, this includes * all subscriptions that have been seen. */ - int getAllSubInfoCount(); + int getAllSubInfoCount(String callingPackage); /** * Get the active SubscriptionInfo with the subId key * @param subId The unique SubscriptionInfo key in database + * @param callingPackage The package maing the call. * @return SubscriptionInfo, maybe null if its not active */ - SubscriptionInfo getActiveSubscriptionInfo(int subId); + SubscriptionInfo getActiveSubscriptionInfo(int subId, String callingPackage); /** * Get the active SubscriptionInfo associated with the iccId * @param iccId the IccId of SIM card + * @param callingPackage The package maing the call. * @return SubscriptionInfo, maybe null if its not active */ - SubscriptionInfo getActiveSubscriptionInfoForIccId(String iccId); + SubscriptionInfo getActiveSubscriptionInfoForIccId(String iccId, String callingPackage); /** * Get the active SubscriptionInfo associated with the slotIdx * @param slotIdx the slot which the subscription is inserted + * @param callingPackage The package maing the call. * @return SubscriptionInfo, maybe null if its not active */ - SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIdx); + SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIdx, String callingPackage); /** * Get the SubscriptionInfo(s) of the active subscriptions. The records will be sorted * by {@link SubscriptionInfo#getSimSlotIndex} then by {@link SubscriptionInfo#getSubscriptionId}. * + * @param callingPackage The package maing the call. * @return Sorted list of the currently {@link SubscriptionInfo} records available on the device. * <ul> * <li> @@ -74,12 +80,13 @@ interface ISub { * </li> * </ul> */ - List<SubscriptionInfo> getActiveSubscriptionInfoList(); + List<SubscriptionInfo> getActiveSubscriptionInfoList(String callingPackage); /** + * @param callingPackage The package maing the call. * @return the number of active subscriptions */ - int getActiveSubInfoCount(); + int getActiveSubInfoCount(String callingPackage); /** * @return the maximum number of subscriptions this device will support at any one time. @@ -90,50 +97,57 @@ interface ISub { * Add a new SubscriptionInfo to subinfo database if needed * @param iccId the IccId of the SIM card * @param slotId the slot which the SIM is inserted + * @param callingPackage The package maing the call. * @return the URL of the newly created row or the updated row */ - int addSubInfoRecord(String iccId, int slotId); + int addSubInfoRecord(String iccId, int slotId, String callingPackage); /** * Set SIM icon tint color by simInfo index * @param tint the icon tint color of the SIM * @param subId the unique SubscriptionInfo index in database + * @param callingPackage The package maing the call. * @return the number of records updated */ - int setIconTint(int tint, int subId); + int setIconTint(int tint, int subId, String callingPackage); /** * Set display name by simInfo index * @param displayName the display name of SIM card * @param subId the unique SubscriptionInfo index in database + * @param callingPackage The package maing the call. * @return the number of records updated */ - int setDisplayName(String displayName, int subId); + int setDisplayName(String displayName, int subId, String callingPackage); /** * Set display name by simInfo index with name source * @param displayName the display name of SIM card * @param subId the unique SubscriptionInfo index in database * @param nameSource, 0: DEFAULT_SOURCE, 1: SIM_SOURCE, 2: USER_INPUT + * @param callingPackage The package maing the call. * @return the number of records updated */ - int setDisplayNameUsingSrc(String displayName, int subId, long nameSource); + int setDisplayNameUsingSrc(String displayName, int subId, long nameSource, + String callingPackage); /** * Set phone number by subId * @param number the phone number of the SIM * @param subId the unique SubscriptionInfo index in database + * @param callingPackage The package maing the call. * @return the number of records updated */ - int setDisplayNumber(String number, int subId); + int setDisplayNumber(String number, int subId, String callingPackage); /** * Set data roaming by simInfo index * @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming + * @param callingPackage The package maing the call. * @param subId the unique SubscriptionInfo index in database * @return the number of records updated */ - int setDataRoaming(int roaming, int subId); + int setDataRoaming(int roaming, int subId, String callingPackage); int getSlotId(int subId); @@ -141,7 +155,7 @@ interface ISub { int getDefaultSubId(); - int clearSubInfo(); + int clearSubInfo(String callingPackage); int getPhoneId(int subId); @@ -161,7 +175,7 @@ interface ISub { void setDefaultSmsSubId(int subId); - void clearDefaultsForInactiveSubIds(); + void clearDefaultsForInactiveSubIds(String callingPackage); int[] getActiveSubIdList(); diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index d03fa3a..25fe97c 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -45,6 +45,7 @@ interface ITelephony { /** * Place a call to the specified number. + * @param callingPackage The package making the call. * @param number the number to be called. */ void call(String callingPackage, String number); @@ -169,8 +170,9 @@ interface ITelephony { /** * Check if the SIM pin lock is enabled. * @return true if the SIM pin lock is enabled. + * @param callingPackage The package making the call. */ - boolean isSimPinEnabled(); + boolean isSimPinEnabled(String callingPackage); /** * Supply a pin to unlock the SIM. Blocks until a result is determined. @@ -341,7 +343,7 @@ interface ITelephony { */ boolean isDataConnectivityPossible(); - Bundle getCellLocation(); + Bundle getCellLocation(String callingPkg); /** * Returns the neighboring cell information of the device. @@ -505,7 +507,7 @@ interface ITelephony { /** * Returns the all observed cell information of the device. */ - List<CellInfo> getAllCellInfo(); + List<CellInfo> getAllCellInfo(String callingPkg); /** * Sets minimum time in milli-seconds between onCellInfoChanged @@ -644,18 +646,20 @@ interface ITelephony { /* * Get the calculated preferred network type. * Used for device configuration by some CDMA operators. + * @param callingPackage The package making the call. * * @return the calculated preferred network type, defined in RILConstants.java. */ - int getCalculatedPreferredNetworkType(); + int getCalculatedPreferredNetworkType(String callingPackage); /* * Get the preferred network type. * Used for device configuration by some CDMA operators. * + * @param subId the id of the subscription to query. * @return the preferred network type, defined in RILConstants.java. */ - int getPreferredNetworkType(); + int getPreferredNetworkType(int subId); /** * Check TETHER_DUN_REQUIRED and TETHER_DUN_APN settings, net.tethering.noprovisioning @@ -667,13 +671,21 @@ interface ITelephony { int getTetherApnRequired(); /** + * Set the network selection mode to automatic. + * + * @param subId the id of the subscription to update. + */ + void setNetworkSelectionModeAutomatic(int subId); + + /** * Set the preferred network type. * Used for device configuration by some CDMA operators. * + * @param subId the id of the subscription to update. * @param networkType the preferred network type, defined in RILConstants.java. * @return true on success; false on any failure. */ - boolean setPreferredNetworkType(int networkType); + boolean setPreferredNetworkType(int subId, int networkType); /** * User enable/disable Mobile Data. @@ -692,8 +704,9 @@ interface ITelephony { /** * Get P-CSCF address from PCO after data connection is established or modified. * @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN + * @param callingPackage The package making the call. */ - String[] getPcscfAddress(String apnType); + String[] getPcscfAddress(String apnType, String callingPackage); /** * Set IMS registration state @@ -731,15 +744,16 @@ interface ITelephony { int checkCarrierPrivilegesForPackage(String pkgname); /** - * Returns the package name of the carrier apps that should handle the input intent. + * Returns list of the package names of the carrier apps that should handle the input intent + * and have carrier privileges for the given phoneId. * - * @param packageManager PackageManager for getting receivers. * @param intent Intent that will be sent. - * @return list of carrier app package names that can handle the intent. + * @param phoneId The phoneId on which the carrier app has carrier privileges. + * @return list of carrier app package names that can handle the intent on phoneId. * Returns null if there is an error and an empty list if there * are no matching packages. */ - List<String> getCarrierPackageNamesForIntent(in Intent intent); + List<String> getCarrierPackageNamesForIntentAndPhone(in Intent intent, int phoneId); /** * Set the line 1 phone number string and its alphatag for the current ICCID @@ -759,19 +773,21 @@ interface ITelephony { * {@link #setLine1NumberForDisplay}. Otherwise returns null. * * @param subId whose dialing number for line 1 is returned. + * @param callingPackage The package making the call. * @return the displayed dialing number if set, or null if not set. */ - String getLine1NumberForDisplay(int subId); + String getLine1NumberForDisplay(int subId, String callingPackage); /** * Returns the displayed alphatag of the dialing number if it was set * previously via {@link #setLine1NumberForDisplay}. Otherwise returns null. * * @param subId whose alphatag associated with line 1 is returned. + * @param callingPackage The package making the call. * @return the displayed alphatag of the dialing number if set, or null if * not set. */ - String getLine1AlphaTagForDisplay(int subId); + String getLine1AlphaTagForDisplay(int subId, String callingPackage); String[] getMergedSubscriberIds(); @@ -863,9 +879,38 @@ interface ITelephony { /** * Whether video calling has been enabled by the user. * - * @return {@code True} if the user has enabled video calling, {@code false} otherwise. + * @param callingPackage The package making the call. + * @return {@code true} if the user has enabled video calling, {@code false} otherwise. */ - boolean isVideoCallingEnabled(); + boolean isVideoCallingEnabled(String callingPackage); + + /** + * Whether the DTMF tone length can be changed. + * + * @return {@code true} if the DTMF tone length can be changed. + */ + boolean canChangeDtmfToneLength(); + + /** + * Whether the device is a world phone. + * + * @return {@code true} if the devices is a world phone. + */ + boolean isWorldPhone(); + + /** + * Whether the phone supports TTY mode. + * + * @return {@code true} if the device supports TTY mode. + */ + boolean isTtyModeSupported(); + + /** + * Whether the phone supports hearing aid compatibility. + * + * @return {@code true} if the device supports hearing aid compatibility. + */ + boolean isHearingAidCompatibilitySupported(); /** * Get IMS Registration Status @@ -888,13 +933,16 @@ interface ITelephony { * Returns the unique device ID of phone, for example, the IMEI for * GSM and the MEID for CDMA phones. Return null if device ID is not available. * + * @param callingPackage The package making the call. * <p>Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ - String getDeviceId(); + String getDeviceId(String callingPackage); /** * Returns the subscription ID associated with the specified PhoneAccount. */ int getSubIdForPhoneAccount(in PhoneAccount phoneAccount); + + void factoryReset(int subId); } diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 7d8a8d6..76b69ce 100644 --- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -69,4 +69,5 @@ interface ITelephonyRegistry { void notifyVoLteServiceStateChanged(in VoLteServiceState lteState); void notifyOemHookRawEventForSubscriber(in int subId, in byte[] rawData); void notifySubscriptionInfoChanged(); + void notifyCarrierNetworkChange(in boolean active); } diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java index 0ebd719..2a4032c 100644 --- a/telephony/java/com/android/internal/telephony/PhoneConstants.java +++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java @@ -150,6 +150,10 @@ public class PhoneConstants { public static final String SLOT_KEY = "slot"; + /** Fired when a subscriptions phone state changes. */ + public static final String ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED = + "android.intent.action.SUBSCRIPTION_PHONE_STATE"; + // FIXME: This is used to pass a subId via intents, we need to look at its usage, which is // FIXME: extensive, and see if this should be an array of all active subId's or ...? public static final String SUBSCRIPTION_KEY = "subscription"; diff --git a/telephony/java/com/android/internal/telephony/TelephonyIntents.java b/telephony/java/com/android/internal/telephony/TelephonyIntents.java index 26faaba..85a489b 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyIntents.java +++ b/telephony/java/com/android/internal/telephony/TelephonyIntents.java @@ -16,8 +16,6 @@ package com.android.internal.telephony; -import android.content.Intent; - /** * The intents that the telephony services broadcast. * @@ -319,7 +317,6 @@ public class TelephonyIntents { public static final String EXTRA_PLMN = "plmn"; public static final String EXTRA_SHOW_SPN = "showSpn"; public static final String EXTRA_SPN = "spn"; - public static final String EXTRA_DATA_SPN = "spnData"; /** * <p>Broadcast Action: It indicates one column of a subinfo record has been changed |