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

Commit 32724ef3 authored by Shuo Qian's avatar Shuo Qian
Browse files

Cache Setting values

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.

Test: Treehugger
Bug: 148081953
Change-Id: Ia934d013b3643872677cd764865a1ae07eaa7ba7
parent 52300cde
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -219,6 +219,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");
    }

@@ -254,6 +257,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(