Loading packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +30 −45 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,7 @@ import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.util.Log; import android.util.Log; import android.util.Slog; import android.util.SparseBooleanArray; import android.util.SparseBooleanArray; import android.util.SparseIntArray; import android.util.SparseIntArray; Loading @@ -87,7 +88,6 @@ import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.ArrayList; import java.util.HashMap; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.List; import java.util.Map.Entry; import java.util.Map.Entry; Loading Loading @@ -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 // 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 // first update in handleSimStateChange, we need to force refresh all all SIM states // so the subscription id for them is consistent. // so the subscription id for them is consistent. List<Integer> changedSubscriptionIds = refreshSimState(subscriptionInfos); ArrayList<SubscriptionInfo> changedSubscriptions = new ArrayList<>(); for (int i = 0; i < changedSubscriptionIds.size(); i++) { for (int i = 0; i < subscriptionInfos.size(); i++) { SimData data = mSimDatas.get(changedSubscriptionIds.get(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++) { for (int j = 0; j < mCallbacks.size(); j++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get(); KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get(); if (cb != null) { if (cb != null) { Loading Loading @@ -1839,21 +1846,15 @@ 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 // 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 // that don't return the complete set of values and have different types. In Keyguard we // need IccCardConstants, but TelephonyManager would only give us // need IccCardConstants, but TelephonyManager would only give us // TelephonyManager.SIM_STATE*, so we retrieve it manually. // TelephonyManager.SIM_STATE*, so we retrieve it manually. final TelephonyManager tele = TelephonyManager.from(mContext); 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); int simState = tele.getSimState(slotId); State state; State state; try { try { Loading @@ -1862,7 +1863,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { Log.w(TAG, "Unknown sim state: " + simState); Log.w(TAG, "Unknown sim state: " + simState); state = State.UNKNOWN; state = State.UNKNOWN; } } SimData data = mSimDatas.get(subId); SimData data = mSimDatas.get(subId); final boolean changed; final boolean changed; if (data == null) { if (data == null) { Loading @@ -1873,22 +1873,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { changed = data.simState != state; changed = data.simState != state; data.simState = state; data.simState = state; } } if (changed) { return changed; changedSubscriptionIds.add(subId); } activeSubIds.add(subId); } 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); } } return changedSubscriptionIds; } } public static boolean isSimPinSecure(IccCardConstants.State state) { public static boolean isSimPinSecure(IccCardConstants.State state) { Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +30 −45 Original line number Original line Diff line number Diff line Loading @@ -68,6 +68,7 @@ import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.util.Log; import android.util.Log; import android.util.Slog; import android.util.SparseBooleanArray; import android.util.SparseBooleanArray; import android.util.SparseIntArray; import android.util.SparseIntArray; Loading @@ -87,7 +88,6 @@ import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.ArrayList; import java.util.HashMap; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.List; import java.util.Map.Entry; import java.util.Map.Entry; Loading Loading @@ -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 // 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 // first update in handleSimStateChange, we need to force refresh all all SIM states // so the subscription id for them is consistent. // so the subscription id for them is consistent. List<Integer> changedSubscriptionIds = refreshSimState(subscriptionInfos); ArrayList<SubscriptionInfo> changedSubscriptions = new ArrayList<>(); for (int i = 0; i < changedSubscriptionIds.size(); i++) { for (int i = 0; i < subscriptionInfos.size(); i++) { SimData data = mSimDatas.get(changedSubscriptionIds.get(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++) { for (int j = 0; j < mCallbacks.size(); j++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get(); KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get(); if (cb != null) { if (cb != null) { Loading Loading @@ -1839,21 +1846,15 @@ 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 // 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 // that don't return the complete set of values and have different types. In Keyguard we // need IccCardConstants, but TelephonyManager would only give us // need IccCardConstants, but TelephonyManager would only give us // TelephonyManager.SIM_STATE*, so we retrieve it manually. // TelephonyManager.SIM_STATE*, so we retrieve it manually. final TelephonyManager tele = TelephonyManager.from(mContext); 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); int simState = tele.getSimState(slotId); State state; State state; try { try { Loading @@ -1862,7 +1863,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { Log.w(TAG, "Unknown sim state: " + simState); Log.w(TAG, "Unknown sim state: " + simState); state = State.UNKNOWN; state = State.UNKNOWN; } } SimData data = mSimDatas.get(subId); SimData data = mSimDatas.get(subId); final boolean changed; final boolean changed; if (data == null) { if (data == null) { Loading @@ -1873,22 +1873,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { changed = data.simState != state; changed = data.simState != state; data.simState = state; data.simState = state; } } if (changed) { return changed; changedSubscriptionIds.add(subId); } activeSubIds.add(subId); } 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); } } return changedSubscriptionIds; } } public static boolean isSimPinSecure(IccCardConstants.State state) { public static boolean isSimPinSecure(IccCardConstants.State state) { Loading