diff options
Diffstat (limited to 'telephony')
12 files changed, 676 insertions, 146 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index ba07a95..3572846 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -34,11 +34,9 @@ import android.text.Editable; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.TextUtils; -import android.telephony.Rlog; import android.text.style.TtsSpan; import android.util.SparseIntArray; -import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY; 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; @@ -1817,7 +1815,7 @@ public class PhoneNumberUtils // to the list. number = extractNetworkPortionAlt(number); - Rlog.d(LOG_TAG, "subId:" + subId + ", number: " + number + ", defaultCountryIso:" + + Rlog.d(LOG_TAG, "subId:" + subId + ", defaultCountryIso:" + ((defaultCountryIso == null) ? "NULL" : defaultCountryIso)); String emergencyNumbers = ""; @@ -2174,8 +2172,8 @@ public class PhoneNumberUtils if (!TextUtils.isEmpty(dialStr)) { if (isReallyDialable(dialStr.charAt(0)) && isNonSeparator(dialStr)) { - String currIso = SystemProperties.get(PROPERTY_OPERATOR_ISO_COUNTRY, ""); - String defaultIso = SystemProperties.get(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, ""); + String currIso = TelephonyManager.getDefault().getNetworkCountryIso(); + String defaultIso = TelephonyManager.getDefault().getSimCountryIso(); if (!TextUtils.isEmpty(currIso) && !TextUtils.isEmpty(defaultIso)) { return cdmaCheckAndProcessPlusCodeByNumberFormat(dialStr, getFormatTypeFromCountryCode(currIso), @@ -2197,7 +2195,7 @@ public class PhoneNumberUtils public static String cdmaCheckAndProcessPlusCodeForSms(String dialStr) { if (!TextUtils.isEmpty(dialStr)) { if (isReallyDialable(dialStr.charAt(0)) && isNonSeparator(dialStr)) { - String defaultIso = SystemProperties.get(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, ""); + String defaultIso = TelephonyManager.getDefault().getSimCountryIso(); if (!TextUtils.isEmpty(defaultIso)) { int format = getFormatTypeFromCountryCode(defaultIso); return cdmaCheckAndProcessPlusCodeByNumberFormat(dialStr, format, format); @@ -2313,15 +2311,13 @@ public class PhoneNumberUtils * * @param phoneNumber A {@code CharSequence} the entirety of which represents a phone number. * @return A {@code CharSequence} with appropriate annotations. - * - * @hide */ - public static CharSequence ttsSpanAsPhoneNumber(CharSequence phoneNumber) { + public static CharSequence getPhoneTtsSpannable(CharSequence phoneNumber) { if (phoneNumber == null) { return null; } Spannable spannable = Spannable.Factory.getInstance().newSpannable(phoneNumber); - PhoneNumberUtils.ttsSpanAsPhoneNumber(spannable, 0, spannable.length()); + PhoneNumberUtils.addPhoneTtsSpan(spannable, 0, spannable.length()); return spannable; } @@ -2332,19 +2328,83 @@ public class PhoneNumberUtils * @param s A {@code Spannable} to annotate. * @param start The starting character position of the phone number in {@code s}. * @param end The ending character position of the phone number in {@code s}. - * - * @hide */ - public static void ttsSpanAsPhoneNumber(Spannable s, int start, int end) { - s.setSpan( - new TtsSpan.TelephoneBuilder() - .setNumberParts(splitAtNonNumerics(s.subSequence(start, end))) - .build(), + public static void addPhoneTtsSpan(Spannable s, int start, int end) { + s.setSpan(getPhoneTtsSpan(s.subSequence(start, end).toString()), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } + /** + * Wrap the supplied {@code CharSequence} with a {@code TtsSpan}, annotating it as + * containing a phone number in its entirety. + * + * @param phoneNumber A {@code CharSequence} the entirety of which represents a phone number. + * @return A {@code CharSequence} with appropriate annotations. + * @deprecated Renamed {@link #getPhoneTtsSpannable}. + * + * @hide + */ + @Deprecated + public static CharSequence ttsSpanAsPhoneNumber(CharSequence phoneNumber) { + return getPhoneTtsSpannable(phoneNumber); + } + + /** + * Attach a {@link TtsSpan} to the supplied {@code Spannable} at the indicated location, + * annotating that location as containing a phone number. + * + * @param s A {@code Spannable} to annotate. + * @param start The starting character position of the phone number in {@code s}. + * @param end The ending character position of the phone number in {@code s}. + * + * @deprecated Renamed {@link #addPhoneTtsSpan}. + * + * @hide + */ + @Deprecated + public static void ttsSpanAsPhoneNumber(Spannable s, int start, int end) { + addPhoneTtsSpan(s, start, end); + } + + /** + * Create a {@code TtsSpan} for the supplied {@code String}. + * + * @param phoneNumberString A {@code String} the entirety of which represents a phone number. + * @return A {@code TtsSpan} for {@param phoneNumberString}. + */ + public static TtsSpan getPhoneTtsSpan(String phoneNumberString) { + if (phoneNumberString == null) { + return null; + } + + // Parse the phone number + final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); + PhoneNumber phoneNumber = null; + try { + // Don't supply a defaultRegion so this fails for non-international numbers because + // we don't want to TalkBalk to read a country code (e.g. +1) if it is not already + // present + phoneNumber = phoneNumberUtil.parse(phoneNumberString, /* defaultRegion */ null); + } catch (NumberParseException ignored) { + } + + // Build a telephone tts span + final TtsSpan.TelephoneBuilder builder = new TtsSpan.TelephoneBuilder(); + if (phoneNumber == null) { + // Strip separators otherwise TalkBack will be silent + // (this behavior was observed with TalkBalk 4.0.2 from their alpha channel) + builder.setNumberParts(splitAtNonNumerics(phoneNumberString)); + } else { + if (phoneNumber.hasCountryCode()) { + builder.setCountryCode(Integer.toString(phoneNumber.getCountryCode())); + } + builder.setNumberParts(Long.toString(phoneNumber.getNationalNumber())); + } + return builder.build(); + } + // Split a phone number like "+20(123)-456#" using spaces, ignoring anything that is not // a digit, to produce a result like "20 123 456". private static String splitAtNonNumerics(CharSequence number) { diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 559a58c..cdecb33 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -148,7 +148,11 @@ public class ServiceState implements Parcelable { public static final int RIL_RADIO_TECHNOLOGY_GSM = 16; /** @hide */ public static final int RIL_RADIO_TECHNOLOGY_TD_SCDMA = 17; - + /** + * IWLAN + * @hide + */ + public static final int RIL_RADIO_TECHNOLOGY_IWLAN = 18; /** * Available registration states for GSM, UMTS and CDMA. */ @@ -697,6 +701,9 @@ public class ServiceState implements Parcelable { case RIL_RADIO_TECHNOLOGY_GSM: rtString = "GSM"; break; + case RIL_RADIO_TECHNOLOGY_IWLAN: + rtString = "IWLAN"; + break; default: rtString = "Unexpected"; Rlog.w(LOG_TAG, "Unexpected radioTechnology=" + rt); @@ -1030,6 +1037,8 @@ public class ServiceState implements Parcelable { return TelephonyManager.NETWORK_TYPE_HSPAP; case ServiceState.RIL_RADIO_TECHNOLOGY_GSM: return TelephonyManager.NETWORK_TYPE_GSM; + case ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN: + return TelephonyManager.NETWORK_TYPE_IWLAN; default: return TelephonyManager.NETWORK_TYPE_UNKNOWN; } @@ -1080,7 +1089,8 @@ public class ServiceState implements Parcelable { || radioTechnology == RIL_RADIO_TECHNOLOGY_LTE || radioTechnology == RIL_RADIO_TECHNOLOGY_HSPAP || radioTechnology == RIL_RADIO_TECHNOLOGY_GSM - || radioTechnology == RIL_RADIO_TECHNOLOGY_TD_SCDMA; + || radioTechnology == RIL_RADIO_TECHNOLOGY_TD_SCDMA + || radioTechnology == RIL_RADIO_TECHNOLOGY_IWLAN; } /** @hide */ diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java index e57f9e3..37ffa06 100644 --- a/telephony/java/android/telephony/SubscriptionInfo.java +++ b/telephony/java/android/telephony/SubscriptionInfo.java @@ -62,7 +62,8 @@ public class SubscriptionInfo implements Parcelable { private CharSequence mDisplayName; /** - * The string displayed to the user that identifies Subscription Provider Name + * String that identifies SPN/PLMN + * TODO : Add a new field that identifies only SPN for a sim */ private CharSequence mCarrierName; @@ -129,28 +130,28 @@ public class SubscriptionInfo implements Parcelable { } /** - * Returns the subscription ID. + * @return the subscription ID. */ public int getSubscriptionId() { return this.mId; } /** - * Returns the ICC ID. + * @return the ICC ID. */ public String getIccId() { return this.mIccId; } /** - * Returns the slot index of this Subscription's SIM card. + * @return the slot index of this Subscription's SIM card. */ public int getSimSlotIndex() { return this.mSimSlotIndex; } /** - * Returns the name displayed to the user that identifies this subscription + * @return the name displayed to the user that identifies this subscription */ public CharSequence getDisplayName() { return this.mDisplayName; @@ -165,7 +166,7 @@ public class SubscriptionInfo implements Parcelable { } /** - * Returns the name displayed to the user that identifies Subscription provider name + * @return the name displayed to the user that identifies Subscription provider name */ public CharSequence getCarrierName() { return this.mCarrierName; @@ -180,8 +181,9 @@ public class SubscriptionInfo implements Parcelable { } /** - * Return the source of the name, eg NAME_SOURCE_UNDEFINED, NAME_SOURCE_DEFAULT_SOURCE, + * @return the source of the name, eg NAME_SOURCE_UNDEFINED, NAME_SOURCE_DEFAULT_SOURCE, * NAME_SOURCE_SIM_SOURCE or NAME_SOURCE_USER_INPUT. + * @hide */ public int getNameSource() { return this.mNameSource; @@ -246,35 +248,36 @@ public class SubscriptionInfo implements Parcelable { } /** - * Returns the number of this subscription. + * @return the number of this subscription. */ public String getNumber() { return mNumber; } /** - * Return the data roaming value. + * @return the data roaming state for this subscription, either + * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or {@link SubscriptionManager#DATA_ROAMING_DISABLE}. */ public int getDataRoaming() { return this.mDataRoaming; } /** - * Returns the MCC. + * @return the MCC. */ public int getMcc() { return this.mMcc; } /** - * Returns the MNC. + * @return the MNC. */ public int getMnc() { return this.mMnc; } /** - * Returns the ISO country code + * @return the ISO country code */ public String getCountryIso() { return this.mCountryIso; @@ -333,7 +336,7 @@ public class SubscriptionInfo implements Parcelable { public String toString() { return "{id=" + mId + ", iccId=" + mIccId + " simSlotIndex=" + mSimSlotIndex + " displayName=" + mDisplayName + " carrierName=" + mCarrierName - + " nameSource=" + mNameSource + " iconTint=" + mIconTint + " number=" + mNumber + + " nameSource=" + mNameSource + " iconTint=" + mIconTint + " dataRoaming=" + mDataRoaming + " iconBitmap=" + mIconBitmap + " mcc " + mMcc + " mnc " + mMnc + "}"; } diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index d174f47..aca94e9 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -226,10 +226,10 @@ public class SubscriptionManager { /** @hide */ public static final String DATA_ROAMING = "data_roaming"; - /** @hide */ + /** Indicates that data roaming is enabled for a subscription */ public static final int DATA_ROAMING_ENABLE = 1; - /** @hide */ + /** Indicates that data roaming is disabled for a subscription */ public static final int DATA_ROAMING_DISABLE = 0; /** @hide */ @@ -266,9 +266,9 @@ public class SubscriptionManager { * A listener class for monitoring changes to {@link SubscriptionInfo} records. * <p> * Override the onSubscriptionsChanged method in the object that extends this - * class and pass it to {@link #registerOnSubscriptionsChangedListener(OnSubscriptionsChangedListener)} + * class and pass it to {@link #addOnSubscriptionsChangedListener(OnSubscriptionsChangedListener)} * to register your listener and to unregister invoke - * {@link #unregisterOnSubscriptionsChangedListener(OnSubscriptionsChangedListener)} + * {@link #removeOnSubscriptionsChangedListener(OnSubscriptionsChangedListener)} * <p> * Permissions android.Manifest.permission.READ_PHONE_STATE is required * for #onSubscriptionsChanged to be invoked. @@ -340,7 +340,7 @@ public class SubscriptionManager { * @param listener an instance of {@link OnSubscriptionsChangedListener} with * onSubscriptionsChanged overridden. */ - public void registerOnSubscriptionsChangedListener(OnSubscriptionsChangedListener listener) { + public void addOnSubscriptionsChangedListener(OnSubscriptionsChangedListener listener) { String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>"; if (DBG) { logd("register OnSubscriptionsChangedListener pkgForDebug=" + pkgForDebug @@ -352,7 +352,7 @@ public class SubscriptionManager { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); if (tr != null) { - tr.registerOnSubscriptionsChangedListener(pkgForDebug, listener.callback); + tr.addOnSubscriptionsChangedListener(pkgForDebug, listener.callback); } } catch (RemoteException ex) { // Should not happen @@ -366,7 +366,7 @@ public class SubscriptionManager { * * @param listener that is to be unregistered. */ - public void unregisterOnSubscriptionsChangedListener(OnSubscriptionsChangedListener listener) { + public void removeOnSubscriptionsChangedListener(OnSubscriptionsChangedListener listener) { String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>"; if (DBG) { logd("unregister OnSubscriptionsChangedListener pkgForDebug=" + pkgForDebug @@ -378,7 +378,7 @@ public class SubscriptionManager { ITelephonyRegistry tr = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( "telephony.registry")); if (tr != null) { - tr.unregisterOnSubscriptionsChangedListener(pkgForDebug, listener.callback); + tr.removeOnSubscriptionsChangedListener(pkgForDebug, listener.callback); } } catch (RemoteException ex) { // Should not happen @@ -1101,9 +1101,7 @@ public class SubscriptionManager { // What else can we do? return false; } - // FIXME: use better way to get roaming status instead of reading from system property - return Boolean.parseBoolean(TelephonyManager.getTelephonyProperty(phoneId, - TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, null)); + return TelephonyManager.getDefault().isNetworkRoaming(subId); } /** diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 99d0af1..b96f528 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -29,6 +29,7 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; +import android.telecom.PhoneAccount; import android.util.Log; import com.android.internal.telecom.ITelecomService; @@ -620,7 +621,13 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getDeviceId() { - return getDeviceId(getDefaultSim()); + try { + return getITelephony().getDeviceId(); + } catch (RemoteException ex) { + return null; + } catch (NullPointerException ex) { + return null; + } } /** @@ -634,13 +641,9 @@ public class TelephonyManager { */ /** {@hide} */ public String getDeviceId(int slotId) { - // FIXME methods taking slot id should not use subscription, instead us Uicc directly - int[] subId = SubscriptionManager.getSubId(slotId); - if (subId == null || subId.length == 0) { - return null; - } + // FIXME this assumes phoneId == slotId try { - return getSubscriberInfo().getDeviceIdForSubscriber(subId[0]); + return getSubscriberInfo().getDeviceIdForPhone(slotId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -697,7 +700,11 @@ public class TelephonyManager { public String getNai(int slotId) { int[] subId = SubscriptionManager.getSubId(slotId); try { - return getSubscriberInfo().getNaiForSubscriber(subId[0]); + String nai = getSubscriberInfo().getNaiForSubscriber(subId[0]); + if (Log.isLoggable(TAG, Log.VERBOSE)) { + Rlog.v(TAG, "Nai = " + nai); + } + return nai; } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1071,7 +1078,7 @@ public class TelephonyManager { * on a CDMA network). */ public String getNetworkOperator() { - return getNetworkOperator(getDefaultSubscription()); + return getNetworkOperatorForPhone(getDefaultPhone()); } /** @@ -1085,8 +1092,23 @@ public class TelephonyManager { * @param subId */ /** {@hide} */ - public String getNetworkOperator(int subId) { + public String getNetworkOperatorForSubscription(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); + return getNetworkOperatorForPhone(phoneId); + } + + /** + * Returns the numeric name (MCC+MNC) of current registered operator + * for a particular subscription. + * <p> + * Availability: Only when user is registered to a network. Result may be + * unreliable on CDMA networks (use {@link #getPhoneType()} to determine if + * on a CDMA network). + * + * @param phoneId + * @hide + **/ + public String getNetworkOperatorForPhone(int phoneId) { return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, ""); } @@ -1124,7 +1146,7 @@ public class TelephonyManager { * on a CDMA network). */ public String getNetworkCountryIso() { - return getNetworkCountryIso(getDefaultSubscription()); + return getNetworkCountryIsoForPhone(getDefaultPhone()); } /** @@ -1138,8 +1160,23 @@ public class TelephonyManager { * @param subId for which Network CountryIso is returned */ /** {@hide} */ - public String getNetworkCountryIso(int subId) { + public String getNetworkCountryIsoForSubscription(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); + return getNetworkCountryIsoForPhone(phoneId); + } + + /** + * Returns the ISO country code equivalent of the current registered + * operator's MCC (Mobile Country Code) of a subscription. + * <p> + * Availability: Only when user is registered to a network. Result may be + * unreliable on CDMA networks (use {@link #getPhoneType()} to determine if + * on a CDMA network). + * + * @param phoneId for which Network CountryIso is returned + */ + /** {@hide} */ + public String getNetworkCountryIsoForPhone(int phoneId) { return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, ""); } @@ -1177,6 +1214,10 @@ public class TelephonyManager { public static final int NETWORK_TYPE_HSPAP = 15; /** Current network is GSM {@hide} */ public static final int NETWORK_TYPE_GSM = 16; + /** Current network is TD_SCDMA {@hide} */ + public static final int NETWORK_TYPE_TD_SCDMA = 17; + /** Current network is IWLAN {@hide} */ + public static final int NETWORK_TYPE_IWLAN = 18; /** * @return the NETWORK_TYPE_xxxx for current data connection. @@ -1347,8 +1388,10 @@ public class TelephonyManager { case NETWORK_TYPE_EVDO_B: case NETWORK_TYPE_EHRPD: case NETWORK_TYPE_HSPAP: + case NETWORK_TYPE_TD_SCDMA: return NETWORK_CLASS_3_G; case NETWORK_TYPE_LTE: + case NETWORK_TYPE_IWLAN: return NETWORK_CLASS_4_G; default: return NETWORK_CLASS_UNKNOWN; @@ -1408,6 +1451,10 @@ public class TelephonyManager { return "HSPA+"; case NETWORK_TYPE_GSM: return "GSM"; + case NETWORK_TYPE_TD_SCDMA: + return "TD_SCDMA"; + case NETWORK_TYPE_IWLAN: + return "IWLAN"; default: return "UNKNOWN"; } @@ -1531,6 +1578,34 @@ public class TelephonyManager { * @see #getSimState */ public String getSimOperator() { + return getSimOperatorNumeric(); + } + + /** + * Returns the MCC+MNC (mobile country code + mobile network code) of the + * provider of the SIM. 5 or 6 decimal digits. + * <p> + * Availability: SIM state must be {@link #SIM_STATE_READY} + * + * @see #getSimState + * + * @param subId for which SimOperator is returned + * @hide + */ + public String getSimOperator(int subId) { + return getSimOperatorNumericForSubscription(subId); + } + + /** + * Returns the MCC+MNC (mobile country code + mobile network code) of the + * provider of the SIM. 5 or 6 decimal digits. + * <p> + * Availability: SIM state must be {@link #SIM_STATE_READY} + * + * @see #getSimState + * @hide + */ + public String getSimOperatorNumeric() { int subId = SubscriptionManager.getDefaultDataSubId(); if (!SubscriptionManager.isUsableSubIdValue(subId)) { subId = SubscriptionManager.getDefaultSmsSubId(); @@ -1541,8 +1616,8 @@ public class TelephonyManager { } } } - Rlog.d(TAG, "getSimOperator(): default subId=" + subId); - return getSimOperator(subId); + Rlog.d(TAG, "getSimOperatorNumeric(): default subId=" + subId); + return getSimOperatorNumericForSubscription(subId); } /** @@ -1554,14 +1629,24 @@ public class TelephonyManager { * @see #getSimState * * @param subId for which SimOperator is returned + * @hide */ - /** {@hide} */ - public String getSimOperator(int subId) { + public String getSimOperatorNumericForSubscription(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); - String operator = getTelephonyProperty(phoneId, + return getSimOperatorNumericForPhone(phoneId); + } + + /** + * Returns the MCC+MNC (mobile country code + mobile network code) of the + * provider of the SIM for a particular subscription. 5 or 6 decimal digits. + * <p> + * + * @param phoneId for which SimOperator is returned + * @hide + */ + public String getSimOperatorNumericForPhone(int phoneId) { + return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, ""); - Rlog.d(TAG, "getSimOperator: subId=" + subId + " operator=" + operator); - return operator; } /** @@ -1572,7 +1657,7 @@ public class TelephonyManager { * @see #getSimState */ public String getSimOperatorName() { - return getSimOperatorName(getDefaultSubscription()); + return getSimOperatorNameForPhone(getDefaultPhone()); } /** @@ -1583,30 +1668,61 @@ public class TelephonyManager { * @see #getSimState * * @param subId for which SimOperatorName is returned + * @hide */ - /** {@hide} */ - public String getSimOperatorName(int subId) { + public String getSimOperatorNameForSubscription(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); - return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, ""); + return getSimOperatorNameForPhone(phoneId); + } + + /** + * Returns the Service Provider Name (SPN). + * + * @hide + */ + public String getSimOperatorNameForPhone(int phoneId) { + return getTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, ""); } /** * Returns the ISO country code equivalent for the SIM provider's country code. */ public String getSimCountryIso() { - return getSimCountryIso(getDefaultSubscription()); + return getSimCountryIsoForPhone(getDefaultPhone()); } /** * Returns the ISO country code equivalent for the SIM provider's country code. * * @param subId for which SimCountryIso is returned + * + * @hide */ - /** {@hide} */ public String getSimCountryIso(int subId) { + return getSimCountryIsoForSubscription(subId); + } + + /** + * Returns the ISO country code equivalent for the SIM provider's country code. + * + * @param subId for which SimCountryIso is returned + * + * @hide + */ + public String getSimCountryIsoForSubscription(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); - return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY, - ""); + return getSimCountryIsoForPhone(phoneId); + } + + /** + * Returns the ISO country code equivalent for the SIM provider's country code. + * + * @hide + */ + public String getSimCountryIsoForPhone(int phoneId) { + return getTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY, ""); } /** @@ -3099,7 +3215,7 @@ public class TelephonyManager { * * @return true on success; false on any failure. */ - public boolean setGlobalPreferredNetworkType() { + public boolean setPreferredNetworkTypeToGlobal() { return setPreferredNetworkType(RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA); } @@ -3142,8 +3258,6 @@ public class TelephonyManager { * call will return true. This access is granted by the owner of the UICC * card and does not depend on the registered carrier. * - * TODO: Add a link to documentation. - * * @return true if the app has carrier privileges. */ public boolean hasCarrierPrivileges() { @@ -3566,12 +3680,12 @@ public class TelephonyManager { /** @hide */ @SystemApi public boolean getDataEnabled(int subId) { - boolean retVal; + boolean retVal = false; try { retVal = getITelephony().getDataEnabled(subId); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#getDataEnabled", e); - retVal = false; + } catch (NullPointerException e) { } Log.d(TAG, "getDataEnabled: retVal=" + retVal); return retVal; @@ -3666,7 +3780,7 @@ public class TelephonyManager { /** * Returns the IMS Registration Status - *@hide + * @hide */ public boolean isImsRegistered() { try { @@ -3677,4 +3791,361 @@ public class TelephonyManager { return false; } } + + /** + * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC for the default phone. + * + * @hide + */ + public void setSimOperatorNumeric(String numeric) { + int phoneId = getDefaultPhone(); + setSimOperatorNumericForPhone(phoneId, numeric); + } + + /** + * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC for the given phone. + * + * @hide + */ + public void setSimOperatorNumericForPhone(int phoneId, String numeric) { + setTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, numeric); + } + + /** + * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC for the default phone. + * + * @hide + */ + public void setSimOperatorName(String name) { + int phoneId = getDefaultPhone(); + setSimOperatorNameForPhone(phoneId, name); + } + + /** + * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC for the given phone. + * + * @hide + */ + public void setSimOperatorNameForPhone(int phoneId, String name) { + setTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA, name); + } + + /** + * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY for the default phone. + * + * @hide + */ + public void setSimCountryIso(String iso) { + int phoneId = getDefaultPhone(); + setSimCountryIsoForPhone(phoneId, iso); + } + + /** + * Set TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY for the given phone. + * + * @hide + */ + public void setSimCountryIsoForPhone(int phoneId, String iso) { + setTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY, iso); + } + + /** + * Set TelephonyProperties.PROPERTY_SIM_STATE for the default phone. + * + * @hide + */ + public void setSimState(String state) { + int phoneId = getDefaultPhone(); + setSimStateForPhone(phoneId, state); + } + + /** + * Set TelephonyProperties.PROPERTY_SIM_STATE for the given phone. + * + * @hide + */ + public void setSimStateForPhone(int phoneId, String state) { + setTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_SIM_STATE, state); + } + + /** + * Set baseband version for the default phone. + * + * @param version baseband version + * @hide + */ + public void setBasebandVersion(String version) { + int phoneId = getDefaultPhone(); + setBasebandVersionForPhone(phoneId, version); + } + + /** + * Set baseband version by phone id. + * + * @param phoneId for which baseband version is set + * @param version baseband version + * @hide + */ + public void setBasebandVersionForPhone(int phoneId, String version) { + if (SubscriptionManager.isValidPhoneId(phoneId)) { + String prop = TelephonyProperties.PROPERTY_BASEBAND_VERSION + + ((phoneId == 0) ? "" : Integer.toString(phoneId)); + SystemProperties.set(prop, version); + } + } + + /** + * Set phone type for the default phone. + * + * @param type phone type + * + * @hide + */ + public void setPhoneType(int type) { + int phoneId = getDefaultPhone(); + setPhoneType(phoneId, type); + } + + /** + * Set phone type by phone id. + * + * @param phoneId for which phone type is set + * @param type phone type + * + * @hide + */ + public void setPhoneType(int phoneId, int type) { + if (SubscriptionManager.isValidPhoneId(phoneId)) { + TelephonyManager.setTelephonyProperty(phoneId, + TelephonyProperties.CURRENT_ACTIVE_PHONE, String.valueOf(type)); + } + } + + /** + * Get OTASP number schema for the default phone. + * + * @param defaultValue default value + * @return OTA SP number schema + * + * @hide + */ + public String getOtaSpNumberSchema(String defaultValue) { + int phoneId = getDefaultPhone(); + return getOtaSpNumberSchemaForPhone(phoneId, defaultValue); + } + + /** + * Get OTASP number schema by phone id. + * + * @param phoneId for which OTA SP number schema is get + * @param defaultValue default value + * @return OTA SP number schema + * + * @hide + */ + public String getOtaSpNumberSchemaForPhone(int phoneId, String defaultValue) { + if (SubscriptionManager.isValidPhoneId(phoneId)) { + return TelephonyManager.getTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_OTASP_NUM_SCHEMA, defaultValue); + } + + return defaultValue; + } + + /** + * Get SMS receive capable from system property for the default phone. + * + * @param defaultValue default value + * @return SMS receive capable + * + * @hide + */ + public boolean getSmsReceiveCapable(boolean defaultValue) { + int phoneId = getDefaultPhone(); + return getSmsReceiveCapableForPhone(phoneId, defaultValue); + } + + /** + * Get SMS receive capable from system property by phone id. + * + * @param phoneId for which SMS receive capable is get + * @param defaultValue default value + * @return SMS receive capable + * + * @hide + */ + public boolean getSmsReceiveCapableForPhone(int phoneId, boolean defaultValue) { + if (SubscriptionManager.isValidPhoneId(phoneId)) { + return Boolean.valueOf(TelephonyManager.getTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_SMS_RECEIVE, String.valueOf(defaultValue))); + } + + return defaultValue; + } + + /** + * Get SMS send capable from system property for the default phone. + * + * @param defaultValue default value + * @return SMS send capable + * + * @hide + */ + public boolean getSmsSendCapable(boolean defaultValue) { + int phoneId = getDefaultPhone(); + return getSmsSendCapableForPhone(phoneId, defaultValue); + } + + /** + * Get SMS send capable from system property by phone id. + * + * @param phoneId for which SMS send capable is get + * @param defaultValue default value + * @return SMS send capable + * + * @hide + */ + public boolean getSmsSendCapableForPhone(int phoneId, boolean defaultValue) { + if (SubscriptionManager.isValidPhoneId(phoneId)) { + return Boolean.valueOf(TelephonyManager.getTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_SMS_SEND, String.valueOf(defaultValue))); + } + + return defaultValue; + } + + /** + * Set the alphabetic name of current registered operator. + * @param name the alphabetic name of current registered operator. + * @hide + */ + public void setNetworkOperatorName(String name) { + int phoneId = getDefaultPhone(); + setNetworkOperatorNameForPhone(phoneId, name); + } + + /** + * Set the alphabetic name of current registered operator. + * @param phoneId which phone you want to set + * @param name the alphabetic name of current registered operator. + * @hide + */ + public void setNetworkOperatorNameForPhone(int phoneId, String name) { + if (SubscriptionManager.isValidPhoneId(phoneId)) { + setTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ALPHA, name); + } + } + + /** + * Set the numeric name (MCC+MNC) of current registered operator. + * @param operator the numeric name (MCC+MNC) of current registered operator + * @hide + */ + public void setNetworkOperatorNumeric(String numeric) { + int phoneId = getDefaultPhone(); + setNetworkOperatorNumericForPhone(phoneId, numeric); + } + + /** + * Set the numeric name (MCC+MNC) of current registered operator. + * @param phoneId for which phone type is set + * @param operator the numeric name (MCC+MNC) of current registered operator + * @hide + */ + public void setNetworkOperatorNumericForPhone(int phoneId, String numeric) { + setTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, numeric); + } + + /** + * Set roaming state of the current network, for GSM purposes. + * @param isRoaming is network in romaing state or not + * @hide + */ + public void setNetworkRoaming(boolean isRoaming) { + int phoneId = getDefaultPhone(); + setNetworkRoamingForPhone(phoneId, isRoaming); + } + + /** + * Set roaming state of the current network, for GSM purposes. + * @param phoneId which phone you want to set + * @param isRoaming is network in romaing state or not + * @hide + */ + public void setNetworkRoamingForPhone(int phoneId, boolean isRoaming) { + if (SubscriptionManager.isValidPhoneId(phoneId)) { + setTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, + isRoaming ? "true" : "false"); + } + } + + /** + * Set the ISO country code equivalent of the current registered + * operator's MCC (Mobile Country Code). + * @param iso the ISO country code equivalent of the current registered + * @hide + */ + public void setNetworkCountryIso(String iso) { + int phoneId = getDefaultPhone(); + setNetworkCountryIsoForPhone(phoneId, iso); + } + + /** + * Set the ISO country code equivalent of the current registered + * operator's MCC (Mobile Country Code). + * @param phoneId which phone you want to set + * @param iso the ISO country code equivalent of the current registered + * @hide + */ + public void setNetworkCountryIsoForPhone(int phoneId, String iso) { + if (SubscriptionManager.isValidPhoneId(phoneId)) { + setTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, iso); + } + } + + /** + * Set the network type currently in use on the device for data transmission. + * @param type the network type currently in use on the device for data transmission + * @hide + */ + public void setDataNetworkType(int type) { + int phoneId = getDefaultPhone(); + setDataNetworkTypeForPhone(phoneId, type); + } + + /** + * Set the network type currently in use on the device for data transmission. + * @param phoneId which phone you want to set + * @param type the network type currently in use on the device for data transmission + * @hide + */ + public void setDataNetworkTypeForPhone(int phoneId, int type) { + if (SubscriptionManager.isValidPhoneId(phoneId)) { + setTelephonyProperty(phoneId, + TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, + ServiceState.rilRadioTechnologyToString(type)); + } + } + + /** + * Returns the subscription ID for the given phone account. + * @hide + */ + public int getSubIdForPhoneAccount(PhoneAccount phoneAccount) { + int retval = SubscriptionManager.INVALID_SUBSCRIPTION_ID; + try { + ITelephony service = getITelephony(); + if (service != null) { + retval = service.getSubIdForPhoneAccount(phoneAccount); + } + } catch (RemoteException e) { + } + + return retval; + } } diff --git a/telephony/java/com/android/ims/ImsReasonInfo.java b/telephony/java/com/android/ims/ImsReasonInfo.java index 0b1246b..9628915 100644 --- a/telephony/java/com/android/ims/ImsReasonInfo.java +++ b/telephony/java/com/android/ims/ImsReasonInfo.java @@ -25,26 +25,6 @@ import android.os.Parcelable; * @hide */ public class ImsReasonInfo implements Parcelable { - - /** - * Reason types, defines the error category. - * UNSPECIFIED - unknown error reason - * LOCAL - indicates the local/device error reason - * LOCAL_TIMEOUT - indicates the local error reason when a specific timer is expired - * STATUSCODE - indicates the interworking error reason by SIP status code received - * from the network - * MEDIA - indicates the media error reason (local resource, SDP parameter, etc.) - * USER - indicates the error reason by the local or remote user - * UT - indicates the error reason for the supplementary service configuration - */ - public static final int TYPE_UNSPECIFIED = 0; - public static final int TYPE_LOCAL = 1; - public static final int TYPE_TIMEOUT = 2; - public static final int TYPE_STATUSCODE = 3; - public static final int TYPE_MEDIA = 4; - public static final int TYPE_USER = 5; - public static final int TYPE_UT = 8; - /** * Specific code of each types */ @@ -229,23 +209,37 @@ public class ImsReasonInfo implements Parcelable { public static final int CODE_ECBM_NOT_SUPPORTED = 901; /** + * Ims Registration error code + */ + public static final int CODE_REGISTRATION_ERROR = 1000; + + /** + * CALL DROP error codes (Call could drop because of many reasons like Network not available, + * handover, failed, etc) + */ + + /** + * CALL DROP error code for the case when a device is ePDG capable and when the user is on an + * active wifi call and at the edge of coverage and there is no qualified LTE network available + * to handover the call to. We get a handover NOT_TRIGERRED message from the modem. This error + * code is received as part of the handover message. + */ + public static final int CODE_CALL_DROP_IWLAN_TO_LTE_UNAVAILABLE = 1100; + + /** * Network string error messages. * mExtraMessage may have these values. */ public static final String EXTRA_MSG_SERVICE_NOT_AUTHORIZED = "Forbidden. Not Authorized for Service"; - // For reason type - public int mReasonType; // For main reason code public int mCode; // For the extra code value; it depends on the code value. public int mExtraCode; // For the additional message of the reason info. public String mExtraMessage; - public ImsReasonInfo() { - mReasonType = TYPE_UNSPECIFIED; mCode = CODE_UNSPECIFIED; mExtraCode = CODE_UNSPECIFIED; mExtraMessage = null; @@ -256,14 +250,12 @@ public class ImsReasonInfo implements Parcelable { } public ImsReasonInfo(int code, int extraCode) { - mReasonType = (int) (code / 100); mCode = code; mExtraCode = extraCode; mExtraMessage = null; } public ImsReasonInfo(int code, int extraCode, String extraMessage) { - mReasonType = (int) (code / 100); mCode = code; mExtraCode = extraCode; mExtraMessage = extraMessage; @@ -291,20 +283,12 @@ public class ImsReasonInfo implements Parcelable { } /** - * - */ - public int getReasonType() { - return mReasonType; - } - - /** * Returns the string format of {@link ImsReasonInfo} * * @return the string format of {@link ImsReasonInfo} */ public String toString() { - return "ImsReasonInfo :: {" + mReasonType + ", " - + mCode + ", " + mExtraCode + ", " + mExtraMessage + "}"; + return "ImsReasonInfo :: {" + mCode + ", " + mExtraCode + ", " + mExtraMessage + "}"; } @Override @@ -314,14 +298,12 @@ public class ImsReasonInfo implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { - out.writeInt(mReasonType); out.writeInt(mCode); out.writeInt(mExtraCode); out.writeString(mExtraMessage); } private void readFromParcel(Parcel in) { - mReasonType = in.readInt(); mCode = in.readInt(); mExtraCode = in.readInt(); mExtraMessage = in.readString(); diff --git a/telephony/java/com/android/ims/internal/IImsConfig.aidl b/telephony/java/com/android/ims/internal/IImsConfig.aidl index c17637c..441e03e 100644 --- a/telephony/java/com/android/ims/internal/IImsConfig.aidl +++ b/telephony/java/com/android/ims/internal/IImsConfig.aidl @@ -20,31 +20,11 @@ package com.android.ims.internal; import com.android.ims.ImsConfigListener; /** - * Provides APIs to get/set the IMS service capability/parameters. - * The parameters can be configured by operator and/or user. - * We define 4 storage locations for the IMS config items: - * 1) Default config:For factory out device or device after factory data reset, - * the default config is used to build the initial state of the master config value. - * 2) Provisioned value: as the parameters provisioned by operator need to be preserved - * across FDR(factory data reset)/BOTA(over the air software upgrade), the operator - * provisioned items should be stored in memory location preserved across FDR/BOTA. - * 3) Master value: as the provisioned value can override the user setting, - * and the master config are used by IMS stack. They should be stored in the - * storage based on IMS vendor implementations. - * 4) User setting: For items can be changed by both user/operator, the user - * setting should take effect in some cases. So the user setting should be stored in - * database like setting.db. + * Provides APIs to get/set the IMS service feature/capability/parameters. + * The config items include: + * 1) Items provisioned by the operator. + * 2) Items configured by user. Mainly service feature class. * - * Priority consideration if both operator/user can config the same item: - * 1) For feature config items, the master value is obtained from the provisioned value - * masks with the user setting. Specifically the provisioned values overrides - * the user setting if feature is provisioned off. Otherwise, user setting takes - * effect. - * 2) For non-feature config item: to be implemented based on cases. - * Special cases considered as below: - * 1) Factory out device, the master configuration is built from default config. - * 2) For Factory data reset/SW upgrade device, the master config is built by - * taking provisioned value overriding default config. * {@hide} */ interface IImsConfig { diff --git a/telephony/java/com/android/ims/internal/IImsRegistrationListener.aidl b/telephony/java/com/android/ims/internal/IImsRegistrationListener.aidl index 1413e58..c910600 100644 --- a/telephony/java/com/android/ims/internal/IImsRegistrationListener.aidl +++ b/telephony/java/com/android/ims/internal/IImsRegistrationListener.aidl @@ -16,6 +16,7 @@ package com.android.ims.internal; +import com.android.ims.ImsReasonInfo; /** * A listener type for receiving notifications about the changes to * the IMS connection(registration). @@ -29,9 +30,14 @@ interface IImsRegistrationListener { void registrationConnected(); /** + * Notifies the application when the device is trying to connect the IMS network. + */ + void registrationProgressing(); + + /** * Notifies the application when the device is disconnected from the IMS network. */ - void registrationDisconnected(); + void registrationDisconnected(in ImsReasonInfo imsReasonInfo); /** * Notifies the application when its suspended IMS connection is resumed, diff --git a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl index eec5333..c91a59c 100644 --- a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl +++ b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl @@ -33,10 +33,10 @@ interface IPhoneSubInfo { String getNaiForSubscriber(int subId); /** - * Retrieves the unique device ID of a subId for the device, e.g., IMEI + * Retrieves the unique device ID of a phone for the device, e.g., IMEI * for GSM phones. */ - String getDeviceIdForSubscriber(int subId); + String getDeviceIdForPhone(int phoneId); /** * Retrieves the IMEI. diff --git a/telephony/java/com/android/internal/telephony/ISms.aidl b/telephony/java/com/android/internal/telephony/ISms.aidl index 6fdf121..70ac268 100644 --- a/telephony/java/com/android/internal/telephony/ISms.aidl +++ b/telephony/java/com/android/internal/telephony/ISms.aidl @@ -453,10 +453,6 @@ interface ISms { */ void setPremiumSmsPermission(String packageName, int permission); - /** - * Set the SMS send permission for the specified package. - * Requires system permission. - */ /** * Set the SMS send permission for the specified package. * Requires system permission. @@ -483,6 +479,14 @@ interface ISms { */ boolean isImsSmsSupportedForSubscriber(int subId); + /** + * User needs to pick SIM for SMS if multiple SIMs present and if current subId passed in is not + * active/valid. + * @param subId current subId for sending SMS + * @return true if SIM for SMS sending needs to be chosen + */ + boolean isSmsSimPickActivityNeeded(int subId); + /* * get user prefered SMS subId * @return subId id diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index d6e40ae9..62c8746 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.content.Intent; import android.os.Bundle; +import android.telecom.PhoneAccount; import android.telephony.CellInfo; import android.telephony.IccOpenLogicalChannelResponse; import android.telephony.NeighboringCellInfo; @@ -865,8 +866,23 @@ interface ITelephony { * @return {@code True} if the user has enabled video calling, {@code false} otherwise. */ boolean isVideoCallingEnabled(); + /** * Get IMS Registration Status */ boolean isImsRegistered(); + + /** + * 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. + * + * <p>Requires Permission: + * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + */ + String getDeviceId(); + + /** + * Returns the subscription ID associated with the specified PhoneAccount. + */ + int getSubIdForPhoneAccount(in PhoneAccount phoneAccount); } diff --git a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl index ba62f5f..7d8a8d6 100644 --- a/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -30,9 +30,9 @@ import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.IOnSubscriptionsChangedListener; interface ITelephonyRegistry { - void registerOnSubscriptionsChangedListener(String pkg, + void addOnSubscriptionsChangedListener(String pkg, IOnSubscriptionsChangedListener callback); - void unregisterOnSubscriptionsChangedListener(String pkg, + void removeOnSubscriptionsChangedListener(String pkg, IOnSubscriptionsChangedListener callback); void listen(String pkg, IPhoneStateListener callback, int events, boolean notifyNow); void listenForSubscriber(in int subId, String pkg, IPhoneStateListener callback, int events, |