Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10960bd1 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Use Sim state cache when available

We were making unnecessary calls to the system process, when we
already had all the data cached in KeyguardUpdateMonitor

Fixes: 140827562
Test: add locked sim card, solve challenge
Test: reboot with locked sim card, solve challenge
Change-Id: I0457c99a403c4c32d3681fb80ea094bdca3c57b0
parent 4bec4b2f
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {

    private final Context mContext;
    private final boolean mIsPrimaryUser;
    HashMap<Integer, SimData> mSimDatas = new HashMap<Integer, SimData>();
    HashMap<Integer, SimData> mSimDatas = new HashMap<>();
    HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>();

    private int mRingMode;
@@ -2512,8 +2512,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    @MainThread
    public void reportSimUnlocked(int subId) {
        if (DEBUG_SIM_STATES) Log.v(TAG, "reportSimUnlocked(subId=" + subId + ")");
        int slotId = SubscriptionManager.getSlotIndex(subId);
        handleSimStateChange(subId, slotId, State.READY);
        handleSimStateChange(subId, getSlotId(subId), State.READY);
    }

    /**
@@ -2586,6 +2585,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        }
    }

    private int getSlotId(int subId) {
        if (!mSimDatas.containsKey(subId)) {
            refreshSimState(subId, SubscriptionManager.getSlotIndex(subId));
        }
        return mSimDatas.get(subId).slotId;
    }

    private final TaskStackChangeListener
            mTaskStackListener = new TaskStackChangeListener() {
        @Override
@@ -2710,7 +2716,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        for (int i = 0; i < list.size(); i++) {
            final SubscriptionInfo info = list.get(i);
            final int id = info.getSubscriptionId();
            int slotId = SubscriptionManager.getSlotIndex(id);
            int slotId = getSlotId(id);
            if (state == getSimState(id) && bestSlotId > slotId) {
                resultId = id;
                bestSlotId = slotId;