diff options
| author | 2018-04-25 18:55:03 +0000 | |
|---|---|---|
| committer | 2018-04-25 18:55:03 +0000 | |
| commit | c8836d82b108f4b54261d73b95989b9de40d925d (patch) | |
| tree | eb8dc4dabb1a6efe0202f269c62593060af83d83 | |
| parent | b1a3a5f5821d3c428b11bea172514ea6973f9f90 (diff) | |
| parent | e0381b893b31e901ab19e7b6b2ba86429c24f962 (diff) | |
Merge "Revert "Reset SIM state if the subscription is no longer active."" into pi-dev
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java | 75 |
1 files changed, 30 insertions, 45 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 1bab36be8cd8..d24675c67188 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -68,6 +68,7 @@ import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.TelephonyManager; import android.util.Log; +import android.util.Slog; import android.util.SparseBooleanArray; import android.util.SparseIntArray; @@ -87,7 +88,6 @@ import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map.Entry; @@ -400,9 +400,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { // Hack level over 9000: Because the subscription id is not yet valid when we see the // first update in handleSimStateChange, we need to force refresh all all SIM states // so the subscription id for them is consistent. - List<Integer> changedSubscriptionIds = refreshSimState(subscriptionInfos); - for (int i = 0; i < changedSubscriptionIds.size(); i++) { - SimData data = mSimDatas.get(changedSubscriptionIds.get(i)); + ArrayList<SubscriptionInfo> changedSubscriptions = new ArrayList<>(); + for (int i = 0; i < subscriptionInfos.size(); i++) { + SubscriptionInfo info = subscriptionInfos.get(i); + boolean changed = refreshSimState(info.getSubscriptionId(), info.getSimSlotIndex()); + if (changed) { + changedSubscriptions.add(info); + } + } + for (int i = 0; i < changedSubscriptions.size(); i++) { + SimData data = mSimDatas.get(changedSubscriptions.get(i).getSubscriptionId()); for (int j = 0; j < mCallbacks.size(); j++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get(); if (cb != null) { @@ -1839,56 +1846,34 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { }; /** - * @return A list of changed subscriptions, maybe empty but never null + * @return true if and only if the state has changed for the specified {@code slotId} */ - private List<Integer> refreshSimState(final List<SubscriptionInfo> activeSubscriptionInfos) { + private boolean refreshSimState(int subId, int slotId) { // This is awful. It exists because there are two APIs for getting the SIM status // that don't return the complete set of values and have different types. In Keyguard we // need IccCardConstants, but TelephonyManager would only give us // TelephonyManager.SIM_STATE*, so we retrieve it manually. final TelephonyManager tele = TelephonyManager.from(mContext); - ArrayList<Integer> changedSubscriptionIds = new ArrayList<>(); - HashSet<Integer> activeSubIds = new HashSet<>(); - - for (SubscriptionInfo info : activeSubscriptionInfos) { - int subId = info.getSubscriptionId(); - int slotId = info.getSimSlotIndex(); - int simState = tele.getSimState(slotId); - State state; - try { - state = State.intToState(simState); - } catch(IllegalArgumentException ex) { - Log.w(TAG, "Unknown sim state: " + simState); - state = State.UNKNOWN; - } - - SimData data = mSimDatas.get(subId); - final boolean changed; - if (data == null) { - data = new SimData(state, slotId, subId); - mSimDatas.put(subId, data); - changed = true; // no data yet; force update - } else { - changed = data.simState != state; - data.simState = state; - } - if (changed) { - changedSubscriptionIds.add(subId); - } - - activeSubIds.add(subId); + int simState = tele.getSimState(slotId); + State state; + try { + state = State.intToState(simState); + } catch(IllegalArgumentException ex) { + Log.w(TAG, "Unknown sim state: " + simState); + state = State.UNKNOWN; } - - for (SimData data : mSimDatas.values()) { - if (!activeSubIds.contains(data.subId) && data.simState != State.ABSENT) { - // for the inactive subscriptions, reset state to ABSENT - data.simState = State.ABSENT; - changedSubscriptionIds.add(data.subId); - } + SimData data = mSimDatas.get(subId); + final boolean changed; + if (data == null) { + data = new SimData(state, slotId, subId); + mSimDatas.put(subId, data); + changed = true; // no data yet; force update + } else { + changed = data.simState != state; + data.simState = state; } - - return changedSubscriptionIds; + return changed; } public static boolean isSimPinSecure(IccCardConstants.State state) { |