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

Commit 2105a373 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Make SLOT_INDEX invalid for all subs on boot/process start.

Test: manual
Bug: 132734424
Merged-in: Icb73a5139bde7295c94345503ddb4f612f67efd9
Change-Id: Icb73a5139bde7295c94345503ddb4f612f67efd9
(cherry picked from commit bdc0a31c)
parent 601913be
Loading
Loading
Loading
Loading
+10 −17
Original line number Diff line number Diff line
@@ -148,7 +148,6 @@ public class SubscriptionController extends ISub.Stub {
    @UnsupportedAppUsage
    private int[] colorArr;
    private long mLastISubServiceRegTime;
    private int mPreferredDataSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;

    public static SubscriptionController init(Phone phone) {
        synchronized (SubscriptionController.class) {
@@ -205,10 +204,7 @@ public class SubscriptionController extends ISub.Stub {
            mLastISubServiceRegTime = System.currentTimeMillis();
        }

        /**
         * Switching between DSDS and single sim mode needs to clear the slot index of
         * subscription info.
         */
        // clear SLOT_INDEX for all subs
        clearSlotIndexForSubInfoRecords();

        if (DBG) logdl("[SubscriptionController] init by Context");
@@ -238,22 +234,22 @@ public class SubscriptionController extends ISub.Stub {
    }

    /**
     * Switching between DSDS and single sim mode needs to update the slot index of subscription
     * info into invalid if the slot index is not active.
     * This function marks SIM_SLOT_INDEX as INVALID for all subscriptions in the database. This
     * should be done as part of initialization.
     *
     * TODO: SIM_SLOT_INDEX is based on current state and should not even be persisted in the
     * database.
     */
    private void clearSlotIndexForSubInfoRecords() {
        if (mTelephonyManager == null || mContext == null) {
        if (mContext == null) {
            logel("[clearSlotIndexForSubInfoRecords] TelephonyManager or mContext is null");
            return;
        }
        int phoneCount = mTelephonyManager.getPhoneCount();

        // Update simInfo db with invalid slot index
        ContentResolver resolver = mContext.getContentResolver();
        // Update all subscriptions in simInfo db with invalid slot index
        ContentValues value = new ContentValues(1);
        value.put(SubscriptionManager.SIM_SLOT_INDEX, SubscriptionManager.INVALID_SIM_SLOT_INDEX);
        mContext.getContentResolver().update(SubscriptionManager.CONTENT_URI,
                value, SubscriptionManager.SIM_SLOT_INDEX + ">=" + phoneCount, null);
        mContext.getContentResolver().update(SubscriptionManager.CONTENT_URI, value, null, null);
    }

    private SubscriptionController(Phone phone) {
@@ -266,10 +262,7 @@ public class SubscriptionController extends ISub.Stub {

        migrateImsSettings();

        /**
         * Switching between DSDS and single sim mode needs to clear the slot index of
         * subscription info.
         */
        // clear SLOT_INDEX for all subs
        clearSlotIndexForSubInfoRecords();

        if (DBG) logdl("[SubscriptionController] init by Phone");