diff options
| -rw-r--r-- | api/current.txt | 33 | ||||
| -rw-r--r-- | api/system-current.txt | 33 | ||||
| -rw-r--r-- | api/test-current.txt | 33 | ||||
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 166 |
4 files changed, 126 insertions, 139 deletions
diff --git a/api/current.txt b/api/current.txt index 1c1826479089..ebda35c7a87c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -37203,69 +37203,47 @@ package android.telephony { public class TelephonyManager { method public boolean canChangeDtmfToneLength(); + method public android.telephony.TelephonyManager createForSubscriptionId(int); method public java.util.List<android.telephony.CellInfo> getAllCellInfo(); method public int getCallState(); - method public int getCallState(int); method public android.telephony.CellLocation getCellLocation(); method public int getDataActivity(); - method public int getDataNetworkType(int); + method public int getDataNetworkType(); method public int getDataState(); method public java.lang.String getDeviceId(); method public java.lang.String getDeviceId(int); method public java.lang.String getDeviceSoftwareVersion(); method public java.lang.String getGroupIdLevel1(); - method public java.lang.String getGroupIdLevel1(int); method public java.lang.String getIccAuthentication(int, int, java.lang.String); - method public java.lang.String getIccAuthentication(int, int, int, java.lang.String); - method public java.lang.String getLine1AlphaTag(int); method public java.lang.String getLine1Number(); - method public java.lang.String getLine1Number(int); method public java.lang.String getMmsUAProfUrl(); method public java.lang.String getMmsUserAgent(); method public deprecated java.util.List<android.telephony.NeighboringCellInfo> getNeighboringCellInfo(); method public java.lang.String getNetworkCountryIso(); - method public java.lang.String getNetworkCountryIso(int); method public java.lang.String getNetworkOperator(); - method public java.lang.String getNetworkOperator(int); method public java.lang.String getNetworkOperatorName(); - method public java.lang.String getNetworkOperatorName(int); method public int getNetworkType(); - method public int getNetworkType(int); method public int getPhoneCount(); method public int getPhoneType(); method public java.lang.String getSimCountryIso(); - method public java.lang.String getSimCountryIso(int); method public java.lang.String getSimOperator(); - method public java.lang.String getSimOperator(int); method public java.lang.String getSimOperatorName(); - method public java.lang.String getSimOperatorName(int); method public java.lang.String getSimSerialNumber(); - method public java.lang.String getSimSerialNumber(int); method public int getSimState(); method public java.lang.String getSubscriberId(); - method public java.lang.String getSubscriberId(int); method public java.lang.String getVoiceMailAlphaTag(); - method public java.lang.String getVoiceMailAlphaTag(int); method public java.lang.String getVoiceMailNumber(); - method public java.lang.String getVoiceMailNumber(int); - method public int getVoiceNetworkType(int); + method public int getVoiceNetworkType(); method public android.net.Uri getVoicemailRingtoneUri(android.telecom.PhoneAccountHandle); method public boolean hasCarrierPrivileges(); - method public boolean hasCarrierPrivileges(int); method public boolean hasIccCard(); method public boolean iccCloseLogicalChannel(int); - method public boolean iccCloseLogicalChannel(int, int); method public byte[] iccExchangeSimIO(int, int, int, int, int, java.lang.String); - method public byte[] iccExchangeSimIO(int, int, int, int, int, int, java.lang.String); method public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannel(java.lang.String); - method public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannel(int, java.lang.String); method public java.lang.String iccTransmitApduBasicChannel(int, int, int, int, int, java.lang.String); - method public java.lang.String iccTransmitApduBasicChannel(int, int, int, int, int, int, java.lang.String); method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String); - method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, int, java.lang.String); method public boolean isHearingAidCompatibilitySupported(); method public boolean isNetworkRoaming(); - method public boolean isNetworkRoaming(int); method public boolean isSmsCapable(); method public boolean isTtyModeSupported(); method public boolean isVoiceCapable(); @@ -37273,15 +37251,10 @@ package android.telephony { method public boolean isWorldPhone(); method public void listen(android.telephony.PhoneStateListener, int); method public java.lang.String sendEnvelopeWithStatus(java.lang.String); - method public java.lang.String sendEnvelopeWithStatus(int, java.lang.String); method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String); - method public boolean setLine1NumberForDisplay(int, java.lang.String, java.lang.String); method public boolean setOperatorBrandOverride(java.lang.String); - method public boolean setOperatorBrandOverride(int, java.lang.String); method public boolean setPreferredNetworkTypeToGlobal(); - method public boolean setPreferredNetworkTypeToGlobal(int); method public boolean setVoiceMailNumber(java.lang.String, java.lang.String); - method public boolean setVoiceMailNumber(int, java.lang.String, java.lang.String); field public static final java.lang.String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL"; field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; diff --git a/api/system-current.txt b/api/system-current.txt index 87bc33e28bbf..0b6ac73f755d 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -40140,6 +40140,7 @@ package android.telephony { method public boolean canChangeDtmfToneLength(); method public int checkCarrierPrivilegesForPackage(java.lang.String); method public int checkCarrierPrivilegesForPackageAnyPhone(java.lang.String); + method public android.telephony.TelephonyManager createForSubscriptionId(int); method public void dial(java.lang.String); method public boolean disableDataConnectivity(); method public boolean enableDataConnectivity(); @@ -40147,7 +40148,6 @@ package android.telephony { method public boolean endCall(); method public java.util.List<android.telephony.CellInfo> getAllCellInfo(); method public int getCallState(); - method public int getCallState(int); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); method public java.lang.String getCdmaMdn(); @@ -40160,68 +40160,46 @@ package android.telephony { method public int getDataActivity(); method public boolean getDataEnabled(); method public boolean getDataEnabled(int); - method public int getDataNetworkType(int); + method public int getDataNetworkType(); method public int getDataState(); method public java.lang.String getDeviceId(); method public java.lang.String getDeviceId(int); method public java.lang.String getDeviceSoftwareVersion(); method public java.lang.String getGroupIdLevel1(); - method public java.lang.String getGroupIdLevel1(int); method public java.lang.String getIccAuthentication(int, int, java.lang.String); - method public java.lang.String getIccAuthentication(int, int, int, java.lang.String); - method public java.lang.String getLine1AlphaTag(int); method public java.lang.String getLine1Number(); - method public java.lang.String getLine1Number(int); method public java.lang.String getMmsUAProfUrl(); method public java.lang.String getMmsUserAgent(); method public deprecated java.util.List<android.telephony.NeighboringCellInfo> getNeighboringCellInfo(); method public java.lang.String getNetworkCountryIso(); - method public java.lang.String getNetworkCountryIso(int); method public java.lang.String getNetworkOperator(); - method public java.lang.String getNetworkOperator(int); method public java.lang.String getNetworkOperatorName(); - method public java.lang.String getNetworkOperatorName(int); method public int getNetworkType(); - method public int getNetworkType(int); method public int getPhoneCount(); method public int getPhoneType(); method public java.lang.String getSimCountryIso(); - method public java.lang.String getSimCountryIso(int); method public java.lang.String getSimOperator(); - method public java.lang.String getSimOperator(int); method public java.lang.String getSimOperatorName(); - method public java.lang.String getSimOperatorName(int); method public java.lang.String getSimSerialNumber(); - method public java.lang.String getSimSerialNumber(int); method public int getSimState(); method public java.lang.String getSubscriberId(); - method public java.lang.String getSubscriberId(int); method public java.lang.String getVoiceMailAlphaTag(); - method public java.lang.String getVoiceMailAlphaTag(int); method public java.lang.String getVoiceMailNumber(); - method public java.lang.String getVoiceMailNumber(int); - method public int getVoiceNetworkType(int); + method public int getVoiceNetworkType(); method public android.net.Uri getVoicemailRingtoneUri(android.telecom.PhoneAccountHandle); method public boolean handlePinMmi(java.lang.String); method public boolean handlePinMmiForSubscriber(int, java.lang.String); method public boolean hasCarrierPrivileges(); - method public boolean hasCarrierPrivileges(int); method public boolean hasIccCard(); method public boolean iccCloseLogicalChannel(int); - method public boolean iccCloseLogicalChannel(int, int); method public byte[] iccExchangeSimIO(int, int, int, int, int, java.lang.String); - method public byte[] iccExchangeSimIO(int, int, int, int, int, int, java.lang.String); method public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannel(java.lang.String); - method public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannel(int, java.lang.String); method public java.lang.String iccTransmitApduBasicChannel(int, int, int, int, int, java.lang.String); - method public java.lang.String iccTransmitApduBasicChannel(int, int, int, int, int, int, java.lang.String); method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String); - method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, int, java.lang.String); method public boolean isDataConnectivityPossible(); method public boolean isHearingAidCompatibilitySupported(); method public boolean isIdle(); method public boolean isNetworkRoaming(); - method public boolean isNetworkRoaming(int); method public boolean isOffhook(); method public boolean isRadioOn(); method public boolean isRinging(); @@ -40234,19 +40212,14 @@ package android.telephony { method public void listen(android.telephony.PhoneStateListener, int); method public boolean needsOtaServiceProvisioning(); method public java.lang.String sendEnvelopeWithStatus(java.lang.String); - method public java.lang.String sendEnvelopeWithStatus(int, java.lang.String); method public void setDataEnabled(boolean); method public void setDataEnabled(int, boolean); method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String); - method public boolean setLine1NumberForDisplay(int, java.lang.String, java.lang.String); method public boolean setOperatorBrandOverride(java.lang.String); - method public boolean setOperatorBrandOverride(int, java.lang.String); method public boolean setPreferredNetworkTypeToGlobal(); - method public boolean setPreferredNetworkTypeToGlobal(int); method public boolean setRadio(boolean); method public boolean setRadioPower(boolean); method public boolean setVoiceMailNumber(java.lang.String, java.lang.String); - method public boolean setVoiceMailNumber(int, java.lang.String, java.lang.String); method public void silenceRinger(); method public boolean supplyPin(java.lang.String); method public int[] supplyPinReportResult(java.lang.String); diff --git a/api/test-current.txt b/api/test-current.txt index f9e2a0a30eb4..d277fd7ae733 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -37280,69 +37280,47 @@ package android.telephony { public class TelephonyManager { method public boolean canChangeDtmfToneLength(); + method public android.telephony.TelephonyManager createForSubscriptionId(int); method public java.util.List<android.telephony.CellInfo> getAllCellInfo(); method public int getCallState(); - method public int getCallState(int); method public android.telephony.CellLocation getCellLocation(); method public int getDataActivity(); - method public int getDataNetworkType(int); + method public int getDataNetworkType(); method public int getDataState(); method public java.lang.String getDeviceId(); method public java.lang.String getDeviceId(int); method public java.lang.String getDeviceSoftwareVersion(); method public java.lang.String getGroupIdLevel1(); - method public java.lang.String getGroupIdLevel1(int); method public java.lang.String getIccAuthentication(int, int, java.lang.String); - method public java.lang.String getIccAuthentication(int, int, int, java.lang.String); - method public java.lang.String getLine1AlphaTag(int); method public java.lang.String getLine1Number(); - method public java.lang.String getLine1Number(int); method public java.lang.String getMmsUAProfUrl(); method public java.lang.String getMmsUserAgent(); method public deprecated java.util.List<android.telephony.NeighboringCellInfo> getNeighboringCellInfo(); method public java.lang.String getNetworkCountryIso(); - method public java.lang.String getNetworkCountryIso(int); method public java.lang.String getNetworkOperator(); - method public java.lang.String getNetworkOperator(int); method public java.lang.String getNetworkOperatorName(); - method public java.lang.String getNetworkOperatorName(int); method public int getNetworkType(); - method public int getNetworkType(int); method public int getPhoneCount(); method public int getPhoneType(); method public java.lang.String getSimCountryIso(); - method public java.lang.String getSimCountryIso(int); method public java.lang.String getSimOperator(); - method public java.lang.String getSimOperator(int); method public java.lang.String getSimOperatorName(); - method public java.lang.String getSimOperatorName(int); method public java.lang.String getSimSerialNumber(); - method public java.lang.String getSimSerialNumber(int); method public int getSimState(); method public java.lang.String getSubscriberId(); - method public java.lang.String getSubscriberId(int); method public java.lang.String getVoiceMailAlphaTag(); - method public java.lang.String getVoiceMailAlphaTag(int); method public java.lang.String getVoiceMailNumber(); - method public java.lang.String getVoiceMailNumber(int); - method public int getVoiceNetworkType(int); + method public int getVoiceNetworkType(); method public android.net.Uri getVoicemailRingtoneUri(android.telecom.PhoneAccountHandle); method public boolean hasCarrierPrivileges(); - method public boolean hasCarrierPrivileges(int); method public boolean hasIccCard(); method public boolean iccCloseLogicalChannel(int); - method public boolean iccCloseLogicalChannel(int, int); method public byte[] iccExchangeSimIO(int, int, int, int, int, java.lang.String); - method public byte[] iccExchangeSimIO(int, int, int, int, int, int, java.lang.String); method public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannel(java.lang.String); - method public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannel(int, java.lang.String); method public java.lang.String iccTransmitApduBasicChannel(int, int, int, int, int, java.lang.String); - method public java.lang.String iccTransmitApduBasicChannel(int, int, int, int, int, int, java.lang.String); method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String); - method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, int, java.lang.String); method public boolean isHearingAidCompatibilitySupported(); method public boolean isNetworkRoaming(); - method public boolean isNetworkRoaming(int); method public boolean isSmsCapable(); method public boolean isTtyModeSupported(); method public boolean isVoiceCapable(); @@ -37350,15 +37328,10 @@ package android.telephony { method public boolean isWorldPhone(); method public void listen(android.telephony.PhoneStateListener, int); method public java.lang.String sendEnvelopeWithStatus(java.lang.String); - method public java.lang.String sendEnvelopeWithStatus(int, java.lang.String); method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String); - method public boolean setLine1NumberForDisplay(int, java.lang.String, java.lang.String); method public boolean setOperatorBrandOverride(java.lang.String); - method public boolean setOperatorBrandOverride(int, java.lang.String); method public boolean setPreferredNetworkTypeToGlobal(); - method public boolean setPreferredNetworkTypeToGlobal(int); method public boolean setVoiceMailNumber(java.lang.String, java.lang.String); - method public boolean setVoiceMailNumber(int, java.lang.String, java.lang.String); field public static final java.lang.String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL"; field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 5fed594d7207..2304346abdb4 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -66,6 +66,12 @@ import java.util.regex.Pattern; * a reference to an instance through * {@link android.content.Context#getSystemService * Context.getSystemService(Context.TELEPHONY_SERVICE)}. + * + * The returned TelephonyManager will use the default subscription for all calls. + * To call an API for a specific subscription, use {@link #createForSubscriptionId(int)}. e.g. + * <code> + * telephonyManager = defaultSubTelephonyManager.createForSubscriptionId(subId); + * </code> * <p> * Note that access to some telephony information is * permission-protected. Your application cannot access the protected @@ -101,6 +107,7 @@ public class TelephonyManager { } private final Context mContext; + private final int mSubId; private SubscriptionManager mSubscriptionManager; private static String multiSimConfig = @@ -121,6 +128,12 @@ public class TelephonyManager { /** @hide */ public TelephonyManager(Context context) { + this(context, SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); + } + + /** @hide */ + public TelephonyManager(Context context, int subId) { + mSubId = subId; Context appContext = context.getApplicationContext(); if (appContext != null) { mContext = appContext; @@ -138,6 +151,7 @@ public class TelephonyManager { /** @hide */ private TelephonyManager() { mContext = null; + mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; } private static TelephonyManager sInstance = new TelephonyManager(); @@ -231,6 +245,16 @@ public class TelephonyManager { return (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); } + /** + * Create a new TelephonyManager object pinned to the given subscription ID. + * + * @return a TelephonyManager that uses the given subId for all calls. + */ + public TelephonyManager createForSubscriptionId(int subId) { + // Don't reuse any TelephonyManager objects. + return new TelephonyManager(mContext, subId); + } + /** {@hide} */ public boolean isMultiSimEnabled() { return (multiSimConfig.equals("dsds") || multiSimConfig.equals("dsda") || @@ -923,7 +947,7 @@ public class TelephonyManager { * @hide */ public void enableLocationUpdates() { - enableLocationUpdates(getDefaultSubscription()); + enableLocationUpdates(getSubId()); } /** @@ -935,8 +959,8 @@ public class TelephonyManager { * CONTROL_LOCATION_UPDATES} * * @param subId for which the location updates are enabled + * @hide */ - /** @hide */ public void enableLocationUpdates(int subId) { try { ITelephony telephony = getITelephony(); @@ -957,7 +981,7 @@ public class TelephonyManager { * @hide */ public void disableLocationUpdates() { - disableLocationUpdates(getDefaultSubscription()); + disableLocationUpdates(getSubId()); } /** @hide */ @@ -1018,7 +1042,7 @@ public class TelephonyManager { */ @SystemApi public int getCurrentPhoneType() { - return getCurrentPhoneType(getDefaultSubscription()); + return getCurrentPhoneType(getSubId()); } /** @@ -1029,8 +1053,8 @@ public class TelephonyManager { * @see #PHONE_TYPE_CDMA * * @param subId for which phone type is returned + * @hide */ - /** {@hide} */ @SystemApi public int getCurrentPhoneType(int subId) { int phoneId; @@ -1258,7 +1282,7 @@ public class TelephonyManager { * on a CDMA network). */ public String getNetworkOperatorName() { - return getNetworkOperatorName(getDefaultSubscription()); + return getNetworkOperatorName(getSubId()); } /** @@ -1269,6 +1293,7 @@ public class TelephonyManager { * unreliable on CDMA networks (use {@link #getPhoneType()} to determine if * on a CDMA network). * @param subId + * @hide */ public String getNetworkOperatorName(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); @@ -1295,6 +1320,7 @@ public class TelephonyManager { * on a CDMA network). * * @param subId + * @hide */ public String getNetworkOperator(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); @@ -1323,7 +1349,7 @@ public class TelephonyManager { * Availability: Only when user registered to a network. */ public boolean isNetworkRoaming() { - return isNetworkRoaming(getDefaultSubscription()); + return isNetworkRoaming(getSubId()); } /** @@ -1333,6 +1359,7 @@ public class TelephonyManager { * Availability: Only when user registered to a network. * * @param subId + * @hide */ public boolean isNetworkRoaming(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); @@ -1361,6 +1388,7 @@ public class TelephonyManager { * on a CDMA network). * * @param subId for which Network CountryIso is returned + * @hide */ public String getNetworkCountryIso(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); @@ -1469,6 +1497,7 @@ public class TelephonyManager { * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide */ public int getNetworkType(int subId) { try { @@ -1513,10 +1542,9 @@ public class TelephonyManager { * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} - * @hide */ public int getDataNetworkType() { - return getDataNetworkType(getDefaultSubscription()); + return getDataNetworkType(getSubId()); } /** @@ -1529,6 +1557,7 @@ public class TelephonyManager { * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide */ public int getDataNetworkType(int subId) { try{ @@ -1554,10 +1583,9 @@ public class TelephonyManager { * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} - * @hide */ public int getVoiceNetworkType() { - return getVoiceNetworkType(getDefaultSubscription()); + return getVoiceNetworkType(getSubId()); } /** @@ -1566,6 +1594,7 @@ public class TelephonyManager { * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide */ public int getVoiceNetworkType(int subId) { try{ @@ -1835,6 +1864,7 @@ public class TelephonyManager { * @see #getSimState * * @param subId for which SimOperator is returned + * @hide */ public String getSimOperator(int subId) { return getSimOperatorNumeric(subId); @@ -1911,6 +1941,7 @@ public class TelephonyManager { * @see #getSimState * * @param subId for which SimOperatorName is returned + * @hide */ public String getSimOperatorName(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); @@ -1938,6 +1969,7 @@ public class TelephonyManager { * Returns the ISO country code equivalent for the SIM provider's country code. * * @param subId for which SimCountryIso is returned + * @hide */ public String getSimCountryIso(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); @@ -1962,7 +1994,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getSimSerialNumber() { - return getSimSerialNumber(getDefaultSubscription()); + return getSimSerialNumber(getSubId()); } /** @@ -1972,6 +2004,7 @@ public class TelephonyManager { * @param subId for which Sim Serial number is returned * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide */ public String getSimSerialNumber(int subId) { try { @@ -2002,7 +2035,7 @@ public class TelephonyManager { * @hide */ public int getLteOnCdmaMode() { - return getLteOnCdmaMode(getDefaultSubscription()); + return getLteOnCdmaMode(getSubId()); } /** @@ -2017,8 +2050,8 @@ public class TelephonyManager { * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide */ - /** {@hide} */ public int getLteOnCdmaMode(int subId) { try { ITelephony telephony = getITelephony(); @@ -2048,7 +2081,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getSubscriberId() { - return getSubscriberId(getDefaultSubscription()); + return getSubscriberId(getSubId()); } /** @@ -2060,6 +2093,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * * @param subId whose subscriber id is returned + * @hide */ public String getSubscriberId(int subId) { try { @@ -2104,6 +2138,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * * @param subId whose subscriber id is returned + * @hide */ public String getGroupIdLevel1(int subId) { try { @@ -2131,7 +2166,7 @@ public class TelephonyManager { * The default SMS app can also use this. */ public String getLine1Number() { - return getLine1Number(getDefaultSubscription()); + return getLine1Number(getSubId()); } /** @@ -2146,6 +2181,7 @@ public class TelephonyManager { * The default SMS app can also use this. * * @param subId whose phone number for line 1 is returned + * @hide */ public String getLine1Number(int subId) { String number = null; @@ -2186,7 +2222,7 @@ public class TelephonyManager { * @return true if the operation was executed correctly. */ public boolean setLine1NumberForDisplay(String alphaTag, String number) { - return setLine1NumberForDisplay(getDefaultSubscription(), alphaTag, number); + return setLine1NumberForDisplay(getSubId(), alphaTag, number); } /** @@ -2202,6 +2238,7 @@ public class TelephonyManager { * @param alphaTag alpha-tagging of the dailing nubmer * @param number The dialing number * @return true if the operation was executed correctly. + * @hide */ public boolean setLine1NumberForDisplay(int subId, String alphaTag, String number) { try { @@ -2224,7 +2261,7 @@ public class TelephonyManager { * nobody seems to call this. */ public String getLine1AlphaTag() { - return getLine1AlphaTag(getDefaultSubscription()); + return getLine1AlphaTag(getSubId()); } /** @@ -2236,6 +2273,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * @param subId whose alphabetic identifier associated with line 1 is returned * nobody seems to call this. + * @hide */ public String getLine1AlphaTag(int subId) { String alphaTag = null; @@ -2292,7 +2330,7 @@ public class TelephonyManager { * @hide */ public String getMsisdn() { - return getMsisdn(getDefaultSubscription()); + return getMsisdn(getSubId()); } /** @@ -2303,8 +2341,8 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * * @param subId for which msisdn is returned + * @hide */ - /** {@hide} */ public String getMsisdn(int subId) { try { IPhoneSubInfo info = getSubscriberInfo(); @@ -2326,7 +2364,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getVoiceMailNumber() { - return getVoiceMailNumber(getDefaultSubscription()); + return getVoiceMailNumber(getSubId()); } /** @@ -2336,6 +2374,7 @@ public class TelephonyManager { * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * @param subId whose voice mail number is returned + * @hide */ public String getVoiceMailNumber(int subId) { try { @@ -2360,7 +2399,7 @@ public class TelephonyManager { * @hide */ public String getCompleteVoiceMailNumber() { - return getCompleteVoiceMailNumber(getDefaultSubscription()); + return getCompleteVoiceMailNumber(getSubId()); } /** @@ -2370,8 +2409,8 @@ public class TelephonyManager { * {@link android.Manifest.permission#CALL_PRIVILEGED CALL_PRIVILEGED} * * @param subId + * @hide */ - /** {@hide} */ public String getCompleteVoiceMailNumber(int subId) { try { IPhoneSubInfo info = getSubscriberInfo(); @@ -2396,7 +2435,7 @@ public class TelephonyManager { * @param number The voicemail number. */ public boolean setVoiceMailNumber(String alphaTag, String number) { - return setVoiceMailNumber(getDefaultSubscription(), alphaTag, number); + return setVoiceMailNumber(getSubId(), alphaTag, number); } /** @@ -2408,6 +2447,7 @@ public class TelephonyManager { * @param subId The subscription id. * @param alphaTag The alpha tag to display. * @param number The voicemail number. + * @hide */ public boolean setVoiceMailNumber(int subId, String alphaTag, String number) { try { @@ -2429,7 +2469,7 @@ public class TelephonyManager { * @hide */ public int getVoiceMessageCount() { - return getVoiceMessageCount(getDefaultSubscription()); + return getVoiceMessageCount(getSubId()); } /** @@ -2438,8 +2478,8 @@ public class TelephonyManager { * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * @param subId whose voice message count is returned + * @hide */ - /** {@hide} */ public int getVoiceMessageCount(int subId) { try { ITelephony telephony = getITelephony(); @@ -2462,7 +2502,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} */ public String getVoiceMailAlphaTag() { - return getVoiceMailAlphaTag(getDefaultSubscription()); + return getVoiceMailAlphaTag(getSubId()); } /** @@ -2473,6 +2513,7 @@ public class TelephonyManager { * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} * @param subId whose alphabetic identifier associated with the * voice mail number is returned + * @hide */ public String getVoiceMailAlphaTag(int subId) { try { @@ -2590,6 +2631,7 @@ public class TelephonyManager { * for a subscription. * * @param subId whose call state is returned + * @hide */ public int getCallState(int subId) { int phoneId = SubscriptionManager.getPhoneId(subId); @@ -2759,7 +2801,7 @@ public class TelephonyManager { * @hide */ public int getCdmaEriIconIndex() { - return getCdmaEriIconIndex(getDefaultSubscription()); + return getCdmaEriIconIndex(getSubId()); } /** @@ -2767,8 +2809,8 @@ public class TelephonyManager { * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide */ - /** {@hide} */ public int getCdmaEriIconIndex(int subId) { try { ITelephony telephony = getITelephony(); @@ -2794,7 +2836,7 @@ public class TelephonyManager { * @hide */ public int getCdmaEriIconMode() { - return getCdmaEriIconMode(getDefaultSubscription()); + return getCdmaEriIconMode(getSubId()); } /** @@ -2805,8 +2847,8 @@ public class TelephonyManager { * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide */ - /** {@hide} */ public int getCdmaEriIconMode(int subId) { try { ITelephony telephony = getITelephony(); @@ -2830,7 +2872,7 @@ public class TelephonyManager { * @hide */ public String getCdmaEriText() { - return getCdmaEriText(getDefaultSubscription()); + return getCdmaEriText(getSubId()); } /** @@ -2839,8 +2881,8 @@ public class TelephonyManager { * <p> * Requires Permission: * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} + * @hide */ - /** {@hide} */ public String getCdmaEriText(int subId) { try { ITelephony telephony = getITelephony(); @@ -2993,7 +3035,7 @@ public class TelephonyManager { * @return an IccOpenLogicalChannelResponse object. */ public IccOpenLogicalChannelResponse iccOpenLogicalChannel(String AID) { - return iccOpenLogicalChannel(getDefaultSubscription(), AID); + return iccOpenLogicalChannel(getSubId(), AID); } /** @@ -3008,6 +3050,7 @@ public class TelephonyManager { * @param subId The subscription to use. * @param AID Application id. See ETSI 102.221 and 101.220. * @return an IccOpenLogicalChannelResponse object. + * @hide */ public IccOpenLogicalChannelResponse iccOpenLogicalChannel(int subId, String AID) { try { @@ -3034,7 +3077,7 @@ public class TelephonyManager { * @return true if the channel was closed successfully. */ public boolean iccCloseLogicalChannel(int channel) { - return iccCloseLogicalChannel(getDefaultSubscription(), channel); + return iccCloseLogicalChannel(getSubId(), channel); } /** @@ -3050,6 +3093,7 @@ public class TelephonyManager { * @param channel is the channel id to be closed as retruned by a successful * iccOpenLogicalChannel. * @return true if the channel was closed successfully. + * @hide */ public boolean iccCloseLogicalChannel(int subId, int channel) { try { @@ -3085,7 +3129,7 @@ public class TelephonyManager { */ public String iccTransmitApduLogicalChannel(int channel, int cla, int instruction, int p1, int p2, int p3, String data) { - return iccTransmitApduLogicalChannel(getDefaultSubscription(), channel, cla, + return iccTransmitApduLogicalChannel(getSubId(), channel, cla, instruction, p1, p2, p3, data); } @@ -3110,6 +3154,7 @@ public class TelephonyManager { * @param data Data to be sent with the APDU. * @return The APDU response from the ICC card with the status appended at * the end. + * @hide */ public String iccTransmitApduLogicalChannel(int subId, int channel, int cla, int instruction, int p1, int p2, int p3, String data) { @@ -3145,7 +3190,7 @@ public class TelephonyManager { */ public String iccTransmitApduBasicChannel(int cla, int instruction, int p1, int p2, int p3, String data) { - return iccTransmitApduBasicChannel(getDefaultSubscription(), cla, + return iccTransmitApduBasicChannel(getSubId(), cla, instruction, p1, p2, p3, data); } @@ -3168,6 +3213,7 @@ public class TelephonyManager { * @param data Data to be sent with the APDU. * @return The APDU response from the ICC card with the status appended at * the end. + * @hide */ public String iccTransmitApduBasicChannel(int subId, int cla, int instruction, int p1, int p2, int p3, String data) { @@ -3199,7 +3245,7 @@ public class TelephonyManager { */ public byte[] iccExchangeSimIO(int fileID, int command, int p1, int p2, int p3, String filePath) { - return iccExchangeSimIO(getDefaultSubscription(), fileID, command, p1, p2, p3, filePath); + return iccExchangeSimIO(getSubId(), fileID, command, p1, p2, p3, filePath); } /** @@ -3217,6 +3263,7 @@ public class TelephonyManager { * @param p3 P3 value of the APDU command. * @param filePath * @return The APDU response. + * @hide */ public byte[] iccExchangeSimIO(int subId, int fileID, int command, int p1, int p2, int p3, String filePath) { @@ -3245,7 +3292,7 @@ public class TelephonyManager { * returns an empty string. */ public String sendEnvelopeWithStatus(String content) { - return sendEnvelopeWithStatus(getDefaultSubscription(), content); + return sendEnvelopeWithStatus(getSubId(), content); } /** @@ -3262,6 +3309,7 @@ public class TelephonyManager { * @return The APDU response from the ICC card in hexadecimal format * with the last 4 bytes being the status word. If the command fails, * returns an empty string. + * @hide */ public String sendEnvelopeWithStatus(int subId, String content) { try { @@ -3381,6 +3429,19 @@ public class TelephonyManager { } /** + * Return an appropriate subscription ID for any situation. + * + * If this object has been created with {@link #createForSubscriptionId}, then the provided + * subId is returned. Otherwise, the default subId will be returned. + */ + private int getSubId() { + if (mSubId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { + return getDefaultSubscription(); + } + return mSubId; + } + + /** * Returns Default subscription. */ private static int getDefaultSubscription() { @@ -3662,7 +3723,7 @@ public class TelephonyManager { * @see #hasCarrierPrivileges */ public String getIccAuthentication(int appType, int authType, String data) { - return getIccAuthentication(getDefaultSubscription(), appType, authType, data); + return getIccAuthentication(getSubId(), appType, authType, data); } /** @@ -3680,8 +3741,8 @@ public class TelephonyManager { * @return the response of authentication, or null if not available * * @see #hasCarrierPrivileges + * @hide */ - public String getIccAuthentication(int subId, int appType, int authType, String data) { try { IPhoneSubInfo info = getSubscriberInfo(); @@ -3760,6 +3821,7 @@ public class TelephonyManager { * Or the calling app has carrier privileges. @see #hasCarrierPrivileges * * @hide + * TODO: Add an overload that takes no args. */ public void setNetworkSelectionModeAutomatic(int subId) { try { @@ -3785,6 +3847,7 @@ public class TelephonyManager { * Or the calling app has carrier privileges. @see #hasCarrierPrivileges * * @hide + * TODO: Add an overload that takes no args. */ public CellNetworkScanResult getCellNetworkScanResults(int subId) { try { @@ -3808,6 +3871,7 @@ public class TelephonyManager { * Or the calling app has carrier privileges. @see #hasCarrierPrivileges * * @hide + * TODO: Add an overload that takes no args. */ public boolean setNetworkSelectionModeManual(int subId, OperatorInfo operator, boolean persistSelection) { @@ -3859,7 +3923,7 @@ public class TelephonyManager { * @return true on success; false on any failure. */ public boolean setPreferredNetworkTypeToGlobal() { - return setPreferredNetworkTypeToGlobal(getDefaultSubscription()); + return setPreferredNetworkTypeToGlobal(getSubId()); } /** @@ -3870,6 +3934,7 @@ public class TelephonyManager { * @see #hasCarrierPrivileges * * @return true on success; false on any failure. + * @hide */ public boolean setPreferredNetworkTypeToGlobal(int subId) { return setPreferredNetworkType(subId, RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA); @@ -3919,7 +3984,7 @@ public class TelephonyManager { * @return true if the app has carrier privileges. */ public boolean hasCarrierPrivileges() { - return hasCarrierPrivileges(getDefaultSubscription()); + return hasCarrierPrivileges(getSubId()); } /** @@ -3931,12 +3996,13 @@ public class TelephonyManager { * * @param subId The subscription to use. * @return true if the app has carrier privileges. + * @hide */ public boolean hasCarrierPrivileges(int subId) { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.getCarrierPrivilegeStatus(subId) == + return telephony.getCarrierPrivilegeStatus(mSubId) == CARRIER_PRIVILEGE_STATUS_HAS_ACCESS; } } catch (RemoteException ex) { @@ -3962,7 +4028,7 @@ public class TelephonyManager { * @return true if the operation was executed correctly. */ public boolean setOperatorBrandOverride(String brand) { - return setOperatorBrandOverride(getDefaultSubscription(), brand); + return setOperatorBrandOverride(getSubId(), brand); } /** @@ -3979,6 +4045,7 @@ public class TelephonyManager { * @param subId The subscription to use. * @param brand The brand name to display/set. * @return true if the operation was executed correctly. + * @hide */ public boolean setOperatorBrandOverride(int subId, String brand) { try { @@ -4015,7 +4082,7 @@ public class TelephonyManager { public boolean setRoamingOverride(List<String> gsmRoamingList, List<String> gsmNonRoamingList, List<String> cdmaRoamingList, List<String> cdmaNonRoamingList) { - return setRoamingOverride(getDefaultSubscription(), gsmRoamingList, gsmNonRoamingList, + return setRoamingOverride(getSubId(), gsmRoamingList, gsmNonRoamingList, cdmaRoamingList, cdmaNonRoamingList); } @@ -4062,7 +4129,7 @@ public class TelephonyManager { /** @hide */ @SystemApi public String getCdmaMdn() { - return getCdmaMdn(getDefaultSubscription()); + return getCdmaMdn(getSubId()); } /** @hide */ @@ -4083,7 +4150,7 @@ public class TelephonyManager { /** @hide */ @SystemApi public String getCdmaMin() { - return getCdmaMin(getDefaultSubscription()); + return getCdmaMin(getSubId()); } /** @hide */ @@ -4626,7 +4693,8 @@ public class TelephonyManager { * retrieves value for setting "name", and if that is not found throws * SettingNotFoundException * - * @hide */ + * @hide + */ public static int getIntWithSubId(ContentResolver cr, String name, int subId) throws SettingNotFoundException { try { |