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

Commit 203e152d authored by Winson Chung's avatar Winson Chung
Browse files

Only create resources for the non-system user

- It is expensive to create resources, so skip recreating
  them for the system user (they already exist for the
  system ui context). We only recreate resources when
  switching to a non-system user.

Bug: 131856992
Test: Manual
Change-Id: I5353fd336134f98e1d48bbf705ea30310447bccd
parent 2f1382ea
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -2718,11 +2718,18 @@ public class DisplayPolicy {
    private void updateCurrentUserResources() {
        final int userId = mService.mAmInternal.getCurrentUserId();
        final Context uiContext = getSystemUiContext();

        if (userId == UserHandle.USER_SYSTEM) {
            // Skip the (expensive) recreation of resources for the system user below and just
            // use the resources from the system ui context
            mCurrentUserResources = uiContext.getResources();
            return;
        }

        // For non-system users, ensure that the resources are loaded from the current
        // user's package info (see ContextImpl.createDisplayContext)
        final LoadedApk pi = ActivityThread.currentActivityThread().getPackageInfo(
                uiContext.getPackageName(), null, 0, userId);

        // Create the resources from the current-user package info
        // (see ContextImpl.createDisplayContext)
        mCurrentUserResources = ResourcesManager.getInstance().getResources(null,
                pi.getResDir(),
                null /* splitResDirs */,