Loading telephony/java/android/telephony/SubscriptionManager.java +30 −0 Original line number Diff line number Diff line Loading @@ -1103,5 +1103,35 @@ public class SubscriptionManager { return Boolean.parseBoolean(TelephonyManager.getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, null)); } /** * Returns a constant indicating the state of sim for the subscription. * * @param subId * * {@See TelephonyManager#SIM_STATE_UNKNOWN} * {@See TelephonyManager#SIM_STATE_ABSENT} * {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} * {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} * {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} * {@See TelephonyManager#SIM_STATE_READY} * {@See TelephonyManager#SIM_STATE_NOT_READY} * {@See TelephonyManager#SIM_STATE_PERM_DISABLED} * {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR} * * {@hide} */ public static int getSimStateForSubscriber(int subId) { int simState; try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); simState = iSub.getSimStateForSubscriber(subId); } catch (RemoteException ex) { simState = TelephonyManager.SIM_STATE_UNKNOWN; } logd("getSimStateForSubscriber: simState=" + simState + " subId=" + subId); return simState; } } telephony/java/android/telephony/TelephonyManager.java +46 −49 Original line number Diff line number Diff line Loading @@ -1416,10 +1416,14 @@ public class TelephonyManager { // // /** SIM card state: Unknown. Signifies that the SIM is in transition /** * SIM card state: Unknown. Signifies that the SIM is in transition * between states. For example, when the user inputs the SIM pin * under PIN_REQUIRED state, a query for sim status returns * this state before turning to SIM_STATE_READY. */ * this state before turning to SIM_STATE_READY. * * These are the ordinal value of IccCardConstants.State. */ public static final int SIM_STATE_UNKNOWN = 0; /** SIM card state: no SIM card is available in the device */ public static final int SIM_STATE_ABSENT = 1; Loading @@ -1427,14 +1431,22 @@ public class TelephonyManager { public static final int SIM_STATE_PIN_REQUIRED = 2; /** SIM card state: Locked: requires the user's SIM PUK to unlock */ public static final int SIM_STATE_PUK_REQUIRED = 3; /** SIM card state: Locked: requries a network PIN to unlock */ /** SIM card state: Locked: requires a network PIN to unlock */ public static final int SIM_STATE_NETWORK_LOCKED = 4; /** SIM card state: Ready */ public static final int SIM_STATE_READY = 5; /** SIM card state: SIM Card Error, Sim Card is present but faulty /** SIM card state: SIM Card is NOT READY *@hide */ public static final int SIM_STATE_NOT_READY = 6; /** SIM card state: SIM Card Error, permanently disabled *@hide */ public static final int SIM_STATE_PERM_DISABLED = 7; /** SIM card state: SIM Card Error, present but faulty *@hide */ public static final int SIM_STATE_CARD_IO_ERROR = 6; public static final int SIM_STATE_CARD_IO_ERROR = 8; /** * @return true if a ICC card is present Loading Loading @@ -1464,8 +1476,7 @@ public class TelephonyManager { } /** * Returns a constant indicating the state of the * device SIM card. * Returns a constant indicating the state of the default SIM card. * * @see #SIM_STATE_UNKNOWN * @see #SIM_STATE_ABSENT Loading @@ -1473,6 +1484,8 @@ public class TelephonyManager { * @see #SIM_STATE_PUK_REQUIRED * @see #SIM_STATE_NETWORK_LOCKED * @see #SIM_STATE_READY * @see #SIM_STATE_NOT_READY * @see #SIM_STATE_PERM_DISABLED * @see #SIM_STATE_CARD_IO_ERROR */ public int getSimState() { Loading @@ -1480,10 +1493,9 @@ public class TelephonyManager { } /** * Returns a constant indicating the state of the * device SIM card in a slot. * Returns a constant indicating the state of the device SIM card in a slot. * * @param slotId * @param slotIdx * * @see #SIM_STATE_UNKNOWN * @see #SIM_STATE_ABSENT Loading @@ -1491,39 +1503,20 @@ public class TelephonyManager { * @see #SIM_STATE_PUK_REQUIRED * @see #SIM_STATE_NETWORK_LOCKED * @see #SIM_STATE_READY * @see #SIM_STATE_NOT_READY * @see #SIM_STATE_PERM_DISABLED * @see #SIM_STATE_CARD_IO_ERROR */ /** {@hide} */ // FIXME the argument to pass is subId ?? public int getSimState(int slotId) { int[] subId = SubscriptionManager.getSubId(slotId); public int getSimState(int slotIdx) { int[] subId = SubscriptionManager.getSubId(slotIdx); if (subId == null || subId.length == 0) { return SIM_STATE_ABSENT; } // FIXME Do not use a property to determine SIM_STATE, call // appropriate method on some object. int phoneId = SubscriptionManager.getPhoneId(subId[0]); String prop = getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_SIM_STATE, ""); if ("ABSENT".equals(prop)) { return SIM_STATE_ABSENT; } else if ("PIN_REQUIRED".equals(prop)) { return SIM_STATE_PIN_REQUIRED; } else if ("PUK_REQUIRED".equals(prop)) { return SIM_STATE_PUK_REQUIRED; } else if ("NETWORK_LOCKED".equals(prop)) { return SIM_STATE_NETWORK_LOCKED; } else if ("READY".equals(prop)) { return SIM_STATE_READY; } else if ("CARD_IO_ERROR".equals(prop)) { return SIM_STATE_CARD_IO_ERROR; } else { Rlog.d(TAG, "getSimState:- empty subId return SIM_STATE_ABSENT"); return SIM_STATE_UNKNOWN; } int simState = SubscriptionManager.getSimStateForSubscriber(subId[0]); Rlog.d(TAG, "getSimState: simState=" + simState + " slotIdx=" + slotIdx); return simState; } /** Loading @@ -1535,7 +1528,7 @@ public class TelephonyManager { * @see #getSimState */ public String getSimOperator() { int subId = mSubscriptionManager.getDefaultDataSubId(); int subId = SubscriptionManager.getDefaultDataSubId(); if (!SubscriptionManager.isUsableSubIdValue(subId)) { subId = SubscriptionManager.getDefaultSmsSubId(); if (!SubscriptionManager.isUsableSubIdValue(subId)) { Loading Loading @@ -2758,8 +2751,6 @@ public class TelephonyManager { * @hide */ public static void setTelephonyProperty(int phoneId, String property, String value) { Rlog.d(TAG, "setTelephonyProperty property: " + property + " phoneId: " + phoneId + " value: " + value); String propVal = ""; String p[] = null; String prop = SystemProperties.get(property); Loading @@ -2773,7 +2764,8 @@ public class TelephonyManager { } if (!SubscriptionManager.isValidPhoneId(phoneId)) { Rlog.d(TAG, "setTelephonyProperty invalid phone id"); Rlog.d(TAG, "setTelephonyProperty: invalid phoneId=" + phoneId + " property=" + property + " value: " + value + " prop=" + prop); return; } Loading @@ -2792,13 +2784,15 @@ public class TelephonyManager { } } // TODO: workaround for QC if (property.length() > SystemProperties.PROP_NAME_MAX || propVal.length() > SystemProperties.PROP_VALUE_MAX) { Rlog.d(TAG, "setTelephonyProperty length too long:" + property + ", " + propVal); if (property.length() > SystemProperties.PROP_NAME_MAX || propVal.length() > SystemProperties.PROP_VALUE_MAX) { Rlog.d(TAG, "setTelephonyProperty: property to long phoneId=" + phoneId + " property=" + property + " value: " + value + " propVal=" + propVal); return; } Rlog.d(TAG, "setTelephonyProperty property=" + property + " propVal=" + propVal); Rlog.d(TAG, "setTelephonyProperty: success phoneId=" + phoneId + " property=" + property + " value: " + value + " propVal=" + propVal); SystemProperties.set(property, propVal); } Loading Loading @@ -2904,13 +2898,16 @@ public class TelephonyManager { propVal = values[phoneId]; } } Rlog.d(TAG, "getTelephonyProperty: return propVal='" + propVal + "' phoneId=" + phoneId + " property='" + property + "' defaultVal='" + defaultVal + "' prop=" + prop); return propVal == null ? defaultVal : propVal; } /** @hide */ public int getSimCount() { // FIXME Need to get it from Telephony Dev Controller when that gets implemented! // and then this method shouldn't be used at all! if(isMultiSimEnabled()) { //FIXME Need to get it from Telephony Devcontroller return 2; } else { return 1; Loading telephony/java/com/android/internal/telephony/ISub.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -164,4 +164,11 @@ interface ISub { void clearDefaultsForInactiveSubIds(); int[] getActiveSubIdList(); /** * Get the SIM state for the subscriber * @return SIM state as the ordinal of IccCardConstants.State */ int getSimStateForSubscriber(int subId); } telephony/java/com/android/internal/telephony/IccCardConstants.java +15 −11 Original line number Diff line number Diff line Loading @@ -15,12 +15,14 @@ */ package com.android.internal.telephony; import android.telephony.TelephonyManager; /** * {@hide} */ public class IccCardConstants { /* The extra data for broacasting intent INTENT_ICC_STATE_CHANGE */ /* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */ public static final String INTENT_KEY_ICC_STATE = "ss"; /* UNKNOWN means the ICC state is unknown */ public static final String INTENT_VALUE_ICC_UNKNOWN = "UNKNOWN"; Loading @@ -38,7 +40,7 @@ public class IccCardConstants { public static final String INTENT_VALUE_ICC_IMSI = "IMSI"; /* LOADED means all ICC records, including IMSI, are loaded */ public static final String INTENT_VALUE_ICC_LOADED = "LOADED"; /* The extra data for broacasting intent INTENT_ICC_STATE_CHANGE */ /* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */ public static final String INTENT_KEY_LOCKED_REASON = "reason"; /* PIN means ICC is locked on PIN1 */ public static final String INTENT_VALUE_LOCKED_ON_PIN = "PIN"; Loading @@ -56,17 +58,19 @@ public class IccCardConstants { * UNKNOWN is a transient state, for example, after user inputs ICC pin under * PIN_REQUIRED state, the query for ICC status returns UNKNOWN before it * turns to READY * * The ordinal values much match {@link TelephonyManager#SIM_STATE_UNKNOWN} ... */ public enum State { UNKNOWN, ABSENT, PIN_REQUIRED, PUK_REQUIRED, NETWORK_LOCKED, READY, NOT_READY, PERM_DISABLED, CARD_IO_ERROR; UNKNOWN, /** ordinal(0) == {@See TelephonyManager#SIM_STATE_UNKNOWN} */ ABSENT, /** ordinal(1) == {@See TelephonyManager#SIM_STATE_ABSENT} */ PIN_REQUIRED, /** ordinal(2) == {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} */ PUK_REQUIRED, /** ordinal(3) == {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} */ NETWORK_LOCKED, /** ordinal(4) == {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} */ READY, /** ordinal(5) == {@See TelephonyManager#SIM_STATE_READY} */ NOT_READY, /** ordinal(6) == {@See TelephonyManager#SIM_STATE_NOT_READY} */ PERM_DISABLED, /** ordinal(7) == {@See TelephonyManager#SIM_STATE_PERM_DISABLED} */ CARD_IO_ERROR; /** ordinal(8) == {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR} */ public boolean isPinLocked() { return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED)); Loading Loading
telephony/java/android/telephony/SubscriptionManager.java +30 −0 Original line number Diff line number Diff line Loading @@ -1103,5 +1103,35 @@ public class SubscriptionManager { return Boolean.parseBoolean(TelephonyManager.getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, null)); } /** * Returns a constant indicating the state of sim for the subscription. * * @param subId * * {@See TelephonyManager#SIM_STATE_UNKNOWN} * {@See TelephonyManager#SIM_STATE_ABSENT} * {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} * {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} * {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} * {@See TelephonyManager#SIM_STATE_READY} * {@See TelephonyManager#SIM_STATE_NOT_READY} * {@See TelephonyManager#SIM_STATE_PERM_DISABLED} * {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR} * * {@hide} */ public static int getSimStateForSubscriber(int subId) { int simState; try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); simState = iSub.getSimStateForSubscriber(subId); } catch (RemoteException ex) { simState = TelephonyManager.SIM_STATE_UNKNOWN; } logd("getSimStateForSubscriber: simState=" + simState + " subId=" + subId); return simState; } }
telephony/java/android/telephony/TelephonyManager.java +46 −49 Original line number Diff line number Diff line Loading @@ -1416,10 +1416,14 @@ public class TelephonyManager { // // /** SIM card state: Unknown. Signifies that the SIM is in transition /** * SIM card state: Unknown. Signifies that the SIM is in transition * between states. For example, when the user inputs the SIM pin * under PIN_REQUIRED state, a query for sim status returns * this state before turning to SIM_STATE_READY. */ * this state before turning to SIM_STATE_READY. * * These are the ordinal value of IccCardConstants.State. */ public static final int SIM_STATE_UNKNOWN = 0; /** SIM card state: no SIM card is available in the device */ public static final int SIM_STATE_ABSENT = 1; Loading @@ -1427,14 +1431,22 @@ public class TelephonyManager { public static final int SIM_STATE_PIN_REQUIRED = 2; /** SIM card state: Locked: requires the user's SIM PUK to unlock */ public static final int SIM_STATE_PUK_REQUIRED = 3; /** SIM card state: Locked: requries a network PIN to unlock */ /** SIM card state: Locked: requires a network PIN to unlock */ public static final int SIM_STATE_NETWORK_LOCKED = 4; /** SIM card state: Ready */ public static final int SIM_STATE_READY = 5; /** SIM card state: SIM Card Error, Sim Card is present but faulty /** SIM card state: SIM Card is NOT READY *@hide */ public static final int SIM_STATE_NOT_READY = 6; /** SIM card state: SIM Card Error, permanently disabled *@hide */ public static final int SIM_STATE_PERM_DISABLED = 7; /** SIM card state: SIM Card Error, present but faulty *@hide */ public static final int SIM_STATE_CARD_IO_ERROR = 6; public static final int SIM_STATE_CARD_IO_ERROR = 8; /** * @return true if a ICC card is present Loading Loading @@ -1464,8 +1476,7 @@ public class TelephonyManager { } /** * Returns a constant indicating the state of the * device SIM card. * Returns a constant indicating the state of the default SIM card. * * @see #SIM_STATE_UNKNOWN * @see #SIM_STATE_ABSENT Loading @@ -1473,6 +1484,8 @@ public class TelephonyManager { * @see #SIM_STATE_PUK_REQUIRED * @see #SIM_STATE_NETWORK_LOCKED * @see #SIM_STATE_READY * @see #SIM_STATE_NOT_READY * @see #SIM_STATE_PERM_DISABLED * @see #SIM_STATE_CARD_IO_ERROR */ public int getSimState() { Loading @@ -1480,10 +1493,9 @@ public class TelephonyManager { } /** * Returns a constant indicating the state of the * device SIM card in a slot. * Returns a constant indicating the state of the device SIM card in a slot. * * @param slotId * @param slotIdx * * @see #SIM_STATE_UNKNOWN * @see #SIM_STATE_ABSENT Loading @@ -1491,39 +1503,20 @@ public class TelephonyManager { * @see #SIM_STATE_PUK_REQUIRED * @see #SIM_STATE_NETWORK_LOCKED * @see #SIM_STATE_READY * @see #SIM_STATE_NOT_READY * @see #SIM_STATE_PERM_DISABLED * @see #SIM_STATE_CARD_IO_ERROR */ /** {@hide} */ // FIXME the argument to pass is subId ?? public int getSimState(int slotId) { int[] subId = SubscriptionManager.getSubId(slotId); public int getSimState(int slotIdx) { int[] subId = SubscriptionManager.getSubId(slotIdx); if (subId == null || subId.length == 0) { return SIM_STATE_ABSENT; } // FIXME Do not use a property to determine SIM_STATE, call // appropriate method on some object. int phoneId = SubscriptionManager.getPhoneId(subId[0]); String prop = getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_SIM_STATE, ""); if ("ABSENT".equals(prop)) { return SIM_STATE_ABSENT; } else if ("PIN_REQUIRED".equals(prop)) { return SIM_STATE_PIN_REQUIRED; } else if ("PUK_REQUIRED".equals(prop)) { return SIM_STATE_PUK_REQUIRED; } else if ("NETWORK_LOCKED".equals(prop)) { return SIM_STATE_NETWORK_LOCKED; } else if ("READY".equals(prop)) { return SIM_STATE_READY; } else if ("CARD_IO_ERROR".equals(prop)) { return SIM_STATE_CARD_IO_ERROR; } else { Rlog.d(TAG, "getSimState:- empty subId return SIM_STATE_ABSENT"); return SIM_STATE_UNKNOWN; } int simState = SubscriptionManager.getSimStateForSubscriber(subId[0]); Rlog.d(TAG, "getSimState: simState=" + simState + " slotIdx=" + slotIdx); return simState; } /** Loading @@ -1535,7 +1528,7 @@ public class TelephonyManager { * @see #getSimState */ public String getSimOperator() { int subId = mSubscriptionManager.getDefaultDataSubId(); int subId = SubscriptionManager.getDefaultDataSubId(); if (!SubscriptionManager.isUsableSubIdValue(subId)) { subId = SubscriptionManager.getDefaultSmsSubId(); if (!SubscriptionManager.isUsableSubIdValue(subId)) { Loading Loading @@ -2758,8 +2751,6 @@ public class TelephonyManager { * @hide */ public static void setTelephonyProperty(int phoneId, String property, String value) { Rlog.d(TAG, "setTelephonyProperty property: " + property + " phoneId: " + phoneId + " value: " + value); String propVal = ""; String p[] = null; String prop = SystemProperties.get(property); Loading @@ -2773,7 +2764,8 @@ public class TelephonyManager { } if (!SubscriptionManager.isValidPhoneId(phoneId)) { Rlog.d(TAG, "setTelephonyProperty invalid phone id"); Rlog.d(TAG, "setTelephonyProperty: invalid phoneId=" + phoneId + " property=" + property + " value: " + value + " prop=" + prop); return; } Loading @@ -2792,13 +2784,15 @@ public class TelephonyManager { } } // TODO: workaround for QC if (property.length() > SystemProperties.PROP_NAME_MAX || propVal.length() > SystemProperties.PROP_VALUE_MAX) { Rlog.d(TAG, "setTelephonyProperty length too long:" + property + ", " + propVal); if (property.length() > SystemProperties.PROP_NAME_MAX || propVal.length() > SystemProperties.PROP_VALUE_MAX) { Rlog.d(TAG, "setTelephonyProperty: property to long phoneId=" + phoneId + " property=" + property + " value: " + value + " propVal=" + propVal); return; } Rlog.d(TAG, "setTelephonyProperty property=" + property + " propVal=" + propVal); Rlog.d(TAG, "setTelephonyProperty: success phoneId=" + phoneId + " property=" + property + " value: " + value + " propVal=" + propVal); SystemProperties.set(property, propVal); } Loading Loading @@ -2904,13 +2898,16 @@ public class TelephonyManager { propVal = values[phoneId]; } } Rlog.d(TAG, "getTelephonyProperty: return propVal='" + propVal + "' phoneId=" + phoneId + " property='" + property + "' defaultVal='" + defaultVal + "' prop=" + prop); return propVal == null ? defaultVal : propVal; } /** @hide */ public int getSimCount() { // FIXME Need to get it from Telephony Dev Controller when that gets implemented! // and then this method shouldn't be used at all! if(isMultiSimEnabled()) { //FIXME Need to get it from Telephony Devcontroller return 2; } else { return 1; Loading
telephony/java/com/android/internal/telephony/ISub.aidl +7 −0 Original line number Diff line number Diff line Loading @@ -164,4 +164,11 @@ interface ISub { void clearDefaultsForInactiveSubIds(); int[] getActiveSubIdList(); /** * Get the SIM state for the subscriber * @return SIM state as the ordinal of IccCardConstants.State */ int getSimStateForSubscriber(int subId); }
telephony/java/com/android/internal/telephony/IccCardConstants.java +15 −11 Original line number Diff line number Diff line Loading @@ -15,12 +15,14 @@ */ package com.android.internal.telephony; import android.telephony.TelephonyManager; /** * {@hide} */ public class IccCardConstants { /* The extra data for broacasting intent INTENT_ICC_STATE_CHANGE */ /* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */ public static final String INTENT_KEY_ICC_STATE = "ss"; /* UNKNOWN means the ICC state is unknown */ public static final String INTENT_VALUE_ICC_UNKNOWN = "UNKNOWN"; Loading @@ -38,7 +40,7 @@ public class IccCardConstants { public static final String INTENT_VALUE_ICC_IMSI = "IMSI"; /* LOADED means all ICC records, including IMSI, are loaded */ public static final String INTENT_VALUE_ICC_LOADED = "LOADED"; /* The extra data for broacasting intent INTENT_ICC_STATE_CHANGE */ /* The extra data for broadcasting intent INTENT_ICC_STATE_CHANGE */ public static final String INTENT_KEY_LOCKED_REASON = "reason"; /* PIN means ICC is locked on PIN1 */ public static final String INTENT_VALUE_LOCKED_ON_PIN = "PIN"; Loading @@ -56,17 +58,19 @@ public class IccCardConstants { * UNKNOWN is a transient state, for example, after user inputs ICC pin under * PIN_REQUIRED state, the query for ICC status returns UNKNOWN before it * turns to READY * * The ordinal values much match {@link TelephonyManager#SIM_STATE_UNKNOWN} ... */ public enum State { UNKNOWN, ABSENT, PIN_REQUIRED, PUK_REQUIRED, NETWORK_LOCKED, READY, NOT_READY, PERM_DISABLED, CARD_IO_ERROR; UNKNOWN, /** ordinal(0) == {@See TelephonyManager#SIM_STATE_UNKNOWN} */ ABSENT, /** ordinal(1) == {@See TelephonyManager#SIM_STATE_ABSENT} */ PIN_REQUIRED, /** ordinal(2) == {@See TelephonyManager#SIM_STATE_PIN_REQUIRED} */ PUK_REQUIRED, /** ordinal(3) == {@See TelephonyManager#SIM_STATE_PUK_REQUIRED} */ NETWORK_LOCKED, /** ordinal(4) == {@See TelephonyManager#SIM_STATE_NETWORK_LOCKED} */ READY, /** ordinal(5) == {@See TelephonyManager#SIM_STATE_READY} */ NOT_READY, /** ordinal(6) == {@See TelephonyManager#SIM_STATE_NOT_READY} */ PERM_DISABLED, /** ordinal(7) == {@See TelephonyManager#SIM_STATE_PERM_DISABLED} */ CARD_IO_ERROR; /** ordinal(8) == {@See TelephonyManager#SIM_STATE_CARD_IO_ERROR} */ public boolean isPinLocked() { return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED)); Loading