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

Commit 56bd87a3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Refresh embedded subscriptions on user unlock."

parents 26decd98 bb373f12
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArraySet;

/**
 *@hide
@@ -120,6 +121,28 @@ public class SubscriptionInfoUpdater extends Handler {
    private int mCurrentlyActiveUserId;
    private CarrierServiceBindHelper mCarrierServiceBindHelper;

    private volatile boolean shouldRetryUpdateEmbeddedSubscriptions = false;
    private final CopyOnWriteArraySet<Integer> retryUpdateEmbeddedSubscriptionCards =
        new CopyOnWriteArraySet<>();
    private final BroadcastReceiver mUserUnlockedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) {
                // The LPA may not have been ready before user unlock, and so previous attempts
                // to refresh the list of embedded subscriptions may have failed. This retries
                // the refresh operation after user unlock.
                if (shouldRetryUpdateEmbeddedSubscriptions) {
                    logd("Retrying refresh embedded subscriptions after user unlock.");
                    for (int cardId : retryUpdateEmbeddedSubscriptionCards){
                        requestEmbeddedSubscriptionInfoListRefresh(cardId, null);
                    }
                    retryUpdateEmbeddedSubscriptionCards.clear();
                    sContext.unregisterReceiver(mUserUnlockedReceiver);
                }
            }
        }
    };

    /**
     * Runnable with a boolean parameter. This is used in
     * updateEmbeddedSubscriptions(List<Integer> cardIds, @Nullable UpdateEmbeddedSubsCallback).
@@ -144,6 +167,10 @@ public class SubscriptionInfoUpdater extends Handler {
        mEuiccManager = (EuiccManager) sContext.getSystemService(Context.EUICC_SERVICE);

        mCarrierServiceBindHelper = new CarrierServiceBindHelper(sContext);

        sContext.registerReceiver(
                mUserUnlockedReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));

        initializeCarrierApps();

        PhoneConfigurationManager.registerForMultiSimConfigChange(
@@ -822,6 +849,7 @@ public class SubscriptionInfoUpdater extends Handler {
        // Do nothing if eUICCs are disabled. (Previous entries may remain in the cache, but they
        // are filtered out of list calls as long as EuiccManager.isEnabled returns false).
        if (!mEuiccManager.isEnabled()) {
            if (DBG) logd("updateEmbeddedSubscriptions: eUICC not enabled");
            callback.run(false /* hasChanges */);
            return;
        }
@@ -866,7 +894,9 @@ public class SubscriptionInfoUpdater extends Handler {
        if (DBG) logd("updateEmbeddedSubscriptionsCache");

        if (result == null) {
            // IPC to the eUICC controller failed.
            if (DBG) logd("updateEmbeddedSubscriptionsCache: IPC to the eUICC controller failed");
            retryUpdateEmbeddedSubscriptionCards.add(cardId);
            shouldRetryUpdateEmbeddedSubscriptions = true;
            return false;
        }