Loading telephony/java/android/telephony/SubscriptionManager.java +5 −5 Original line number Diff line number Diff line Loading @@ -1107,9 +1107,9 @@ public class SubscriptionManager { } /** * Returns a constant indicating the state of sim for the subscription. * Returns a constant indicating the state of sim for the slot idx. * * @param subId * @param slotIdx * * {@See TelephonyManager#SIM_STATE_UNKNOWN} * {@See TelephonyManager#SIM_STATE_ABSENT} Loading @@ -1123,16 +1123,16 @@ public class SubscriptionManager { * * {@hide} */ public static int getSimStateForSubscriber(int subId) { public static int getSimStateForSlotIdx(int slotIdx) { int simState; try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); simState = iSub.getSimStateForSubscriber(subId); simState = iSub.getSimStateForSlotIdx(slotIdx); } catch (RemoteException ex) { simState = TelephonyManager.SIM_STATE_UNKNOWN; } logd("getSimStateForSubscriber: simState=" + simState + " subId=" + subId); logd("getSimStateForSubscriber: simState=" + simState + " slotIdx=" + slotIdx); return simState; } Loading telephony/java/android/telephony/TelephonyManager.java +20 −7 Original line number Diff line number Diff line Loading @@ -1625,7 +1625,25 @@ public class TelephonyManager { * @see #SIM_STATE_CARD_IO_ERROR */ public int getSimState() { return getSimState(getDefaultSim()); int slotIdx = getDefaultSim(); // slotIdx may be invalid due to sim being absent. In that case query all slots to get // sim state if (slotIdx < 0) { // query for all slots and return absent if all sim states are absent, otherwise // return unknown for (int i = 0; i < getPhoneCount(); i++) { int simState = getSimState(i); if (simState != SIM_STATE_ABSENT) { Rlog.d(TAG, "getSimState: default sim:" + slotIdx + ", sim state for " + "slotIdx=" + i + " is " + simState + ", return state as unknown"); return SIM_STATE_UNKNOWN; } } Rlog.d(TAG, "getSimState: default sim:" + slotIdx + ", all SIMs absent, return " + "state as absent"); return SIM_STATE_ABSENT; } return getSimState(slotIdx); } /** Loading @@ -1645,12 +1663,7 @@ public class TelephonyManager { */ /** {@hide} */ public int getSimState(int slotIdx) { int[] subId = SubscriptionManager.getSubId(slotIdx); if (subId == null || subId.length == 0) { Rlog.d(TAG, "getSimState:- empty subId return SIM_STATE_ABSENT"); return SIM_STATE_UNKNOWN; } int simState = SubscriptionManager.getSimStateForSubscriber(subId[0]); int simState = SubscriptionManager.getSimStateForSlotIdx(slotIdx); return simState; } Loading telephony/java/com/android/internal/telephony/ISub.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -180,10 +180,10 @@ interface ISub { int[] getActiveSubIdList(); /** * Get the SIM state for the subscriber * Get the SIM state for the slot idx * @return SIM state as the ordinal of IccCardConstants.State */ int getSimStateForSubscriber(int subId); int getSimStateForSlotIdx(int slotIdx); boolean isActiveSubId(int subId); } Loading
telephony/java/android/telephony/SubscriptionManager.java +5 −5 Original line number Diff line number Diff line Loading @@ -1107,9 +1107,9 @@ public class SubscriptionManager { } /** * Returns a constant indicating the state of sim for the subscription. * Returns a constant indicating the state of sim for the slot idx. * * @param subId * @param slotIdx * * {@See TelephonyManager#SIM_STATE_UNKNOWN} * {@See TelephonyManager#SIM_STATE_ABSENT} Loading @@ -1123,16 +1123,16 @@ public class SubscriptionManager { * * {@hide} */ public static int getSimStateForSubscriber(int subId) { public static int getSimStateForSlotIdx(int slotIdx) { int simState; try { ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub")); simState = iSub.getSimStateForSubscriber(subId); simState = iSub.getSimStateForSlotIdx(slotIdx); } catch (RemoteException ex) { simState = TelephonyManager.SIM_STATE_UNKNOWN; } logd("getSimStateForSubscriber: simState=" + simState + " subId=" + subId); logd("getSimStateForSubscriber: simState=" + simState + " slotIdx=" + slotIdx); return simState; } Loading
telephony/java/android/telephony/TelephonyManager.java +20 −7 Original line number Diff line number Diff line Loading @@ -1625,7 +1625,25 @@ public class TelephonyManager { * @see #SIM_STATE_CARD_IO_ERROR */ public int getSimState() { return getSimState(getDefaultSim()); int slotIdx = getDefaultSim(); // slotIdx may be invalid due to sim being absent. In that case query all slots to get // sim state if (slotIdx < 0) { // query for all slots and return absent if all sim states are absent, otherwise // return unknown for (int i = 0; i < getPhoneCount(); i++) { int simState = getSimState(i); if (simState != SIM_STATE_ABSENT) { Rlog.d(TAG, "getSimState: default sim:" + slotIdx + ", sim state for " + "slotIdx=" + i + " is " + simState + ", return state as unknown"); return SIM_STATE_UNKNOWN; } } Rlog.d(TAG, "getSimState: default sim:" + slotIdx + ", all SIMs absent, return " + "state as absent"); return SIM_STATE_ABSENT; } return getSimState(slotIdx); } /** Loading @@ -1645,12 +1663,7 @@ public class TelephonyManager { */ /** {@hide} */ public int getSimState(int slotIdx) { int[] subId = SubscriptionManager.getSubId(slotIdx); if (subId == null || subId.length == 0) { Rlog.d(TAG, "getSimState:- empty subId return SIM_STATE_ABSENT"); return SIM_STATE_UNKNOWN; } int simState = SubscriptionManager.getSimStateForSubscriber(subId[0]); int simState = SubscriptionManager.getSimStateForSlotIdx(slotIdx); return simState; } Loading
telephony/java/com/android/internal/telephony/ISub.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -180,10 +180,10 @@ interface ISub { int[] getActiveSubIdList(); /** * Get the SIM state for the subscriber * Get the SIM state for the slot idx * @return SIM state as the ordinal of IccCardConstants.State */ int getSimStateForSubscriber(int subId); int getSimStateForSlotIdx(int slotIdx); boolean isActiveSubId(int subId); }