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

Commit 23f498b9 authored by Shuo Qian's avatar Shuo Qian Committed by Gerrit Code Review
Browse files

Merge "Cache Setting values"

parents d163e72a 1ba6ca2b
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(