diff options
author | Nate(Qiang) Jiang <qiangjiang@google.com> | 2020-02-20 13:19:50 -0800 |
---|---|---|
committer | Nate(Qiang) Jiang <qiangjiang@google.com> | 2020-02-20 15:05:51 -0800 |
commit | 3216702599cb7205986f657891cd66df75fd989a (patch) | |
tree | faf7877921f32c56993696f4f90b3a827234e93e /service | |
parent | b9ef0b282078cbec92d18e50356dd7ccae35a85a (diff) |
Consider SIM state not ready as absent.
Bug: 149416317
Test: atest com.android.server.wifi
Change-Id: Ief773f575b6b40ff4a16ee9371abb3ea3b74aff7
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/util/TelephonyUtil.java | 15 |
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 * |