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

Commit f11b2f85 authored by Shuo Qian's avatar Shuo Qian Committed by Automerger Merge Worker
Browse files

Merge "Cache Setting values" am: 23f498b9

Change-Id: I2e67a514d5885385688816447bff502c68c29feb
parents 2b68e607 23f498b9
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -213,6 +213,9 @@ public class SubscriptionController extends ISub.Stub {
        // clear SLOT_INDEX for all subs
        clearSlotIndexForSubInfoRecords();

        // Cache Setting values
        cacheSettingValues();

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

@@ -248,6 +251,26 @@ public class SubscriptionController extends ISub.Stub {
        mContext.getContentResolver().update(SubscriptionManager.CONTENT_URI, value, null, null);
    }

    /**
     * Cache the Settings values by reading these values from Setting from disk to prevent disk I/O
     * access during the API calling. This is based on an assumption that the Settings system will
     * itself cache this value after the first read and thus only the first read after boot will
     * access the disk.
     */
    private void cacheSettingValues() {
        Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.MULTI_SIM_SMS_SUBSCRIPTION,
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);

        Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION,
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);

        Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION,
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    }

    @UnsupportedAppUsage
    protected void enforceModifyPhoneState(String message) {
        mContext.enforceCallingOrSelfPermission(