summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--telephony/java/android/telephony/SubscriptionManager.java10
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java27
-rwxr-xr-xtelephony/java/com/android/internal/telephony/ISub.aidl4
3 files changed, 27 insertions, 14 deletions
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 193285f..e085d89 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -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}
@@ -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;
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 2445bf6..4b15f66 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -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);
}
/**
@@ -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;
}
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
index 1037f2d..918a2eb 100755
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -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);
}