summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-02-21 01:58:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-02-21 01:58:19 +0000
commitb6239b514a7bc67c09d24db77b552a830b2d0b0a (patch)
tree680c0cc8aa148317cb132359686bd374809f4ac3 /service
parent9a85831f522cf413a3b3765848af01385628647a (diff)
parent3216702599cb7205986f657891cd66df75fd989a (diff)
Merge "Consider SIM state not ready as absent."
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/util/TelephonyUtil.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/util/TelephonyUtil.java b/service/java/com/android/server/wifi/util/TelephonyUtil.java
index 1dfa3812b..bfe514104 100644
--- a/service/java/com/android/server/wifi/util/TelephonyUtil.java
+++ b/service/java/com/android/server/wifi/util/TelephonyUtil.java
@@ -285,13 +285,26 @@ public class TelephonyUtil {
* @return true if the subId is active, otherwise false.
*/
public boolean isSimPresent(int subId) {
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+ return false;
+ }
List<SubscriptionInfo> subInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
if (subInfoList == null || subInfoList.isEmpty()) {
return false;
}
return subInfoList.stream()
- .anyMatch(info -> info.getSubscriptionId() == subId);
+ .anyMatch(info -> info.getSubscriptionId() == subId
+ && isSimStateReady(info));
+ }
+
+ /**
+ * Check if SIM card for SubscriptionInfo is ready.
+ */
+ private boolean isSimStateReady(SubscriptionInfo info) {
+ int simSlotIndex = info.getSimSlotIndex();
+ return mTelephonyManager.getSimState(simSlotIndex) == TelephonyManager.SIM_STATE_READY;
}
+
/**
* Get the identity for the current SIM or null if the SIM is not available
*