Loading services/core/java/com/android/server/wm/DisplayContent.java +1 −0 Original line number Diff line number Diff line Loading @@ -2462,6 +2462,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo void switchUser() { super.switchUser(); mWmService.mWindowsChanged = true; mDisplayPolicy.switchUser(); } private void resetAnimationBackgroundAnimator() { Loading services/core/java/com/android/server/wm/DisplayPolicy.java +51 −5 Original line number Diff line number Diff line Loading @@ -112,7 +112,10 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Px; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.ActivityThread; import android.app.LoadedApk; import android.app.ResourcesManager; import android.app.StatusBarManager; import android.content.Context; import android.content.Intent; Loading Loading @@ -210,6 +213,8 @@ public class DisplayPolicy { private final Object mLock; private final Handler mHandler; private Resources mCurrentUserResources; private final boolean mCarDockEnablesAccelerometer; private final boolean mDeskDockEnablesAccelerometer; private final AccessibilityManager mAccessibilityManager; Loading Loading @@ -2603,10 +2608,18 @@ public class DisplayPolicy { || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; } /** * Called when the user is switched. */ public void switchUser() { updateCurrentUserResources(); } /** * Called when the resource overlays change. */ public void onOverlayChangedLw() { updateCurrentUserResources(); onConfigurationChanged(); mSystemGestures.onConfigurationChanged(); } Loading @@ -2617,8 +2630,7 @@ public class DisplayPolicy { public void onConfigurationChanged() { final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation(); final Context uiContext = getSystemUiContext(); final Resources res = uiContext.getResources(); final Resources res = getCurrentUserResources(); final int portraitRotation = displayRotation.getPortraitRotation(); final int upsideDownRotation = displayRotation.getUpsideDownRotation(); final int landscapeRotation = displayRotation.getLandscapeRotation(); Loading Loading @@ -2693,15 +2705,49 @@ public class DisplayPolicy { } void updateConfigurationAndScreenSizeDependentBehaviors() { final Context uiContext = getSystemUiContext(); final Resources res = uiContext.getResources(); final Resources res = getCurrentUserResources(); mNavigationBarCanMove = mDisplayContent.mBaseDisplayWidth != mDisplayContent.mBaseDisplayHeight && res.getBoolean(R.bool.config_navBarCanMove); } /** * Updates the current user's resources to pick up any changes for the current user (including * overlay paths) */ private void updateCurrentUserResources() { final int userId = mService.mAmInternal.getCurrentUserId(); final Context uiContext = getSystemUiContext(); 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 */, pi.getOverlayDirs(), pi.getApplicationInfo().sharedLibraryFiles, mDisplayContent.getDisplayId(), null /* overrideConfig */, uiContext.getResources().getCompatibilityInfo(), null /* classLoader */); } @VisibleForTesting Context getSystemUiContext() { Resources getCurrentUserResources() { if (mCurrentUserResources == null) { updateCurrentUserResources(); } return mCurrentUserResources; } @VisibleForTesting Context getContext() { return mContext; } private Context getSystemUiContext() { final Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext(); return mDisplayContent.isDefaultDisplay ? uiContext : uiContext.createDisplayContext(mDisplayContent.getDisplay()); Loading services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java +5 −5 Original line number Diff line number Diff line Loading @@ -69,15 +69,15 @@ public class DisplayPolicyTestsBase extends WindowTestsBase { public void setUpDisplayPolicy() { mDisplayPolicy = spy(mDisplayContent.getDisplayPolicy()); final TestContextWrapper context = new TestContextWrapper(mDisplayPolicy.getSystemUiContext()); final TestContextWrapper context = new TestContextWrapper( mDisplayPolicy.getContext(), mDisplayPolicy.getCurrentUserResources()); final TestableResources resources = context.getResourceMocker(); resources.addOverride(R.dimen.status_bar_height_portrait, STATUS_BAR_HEIGHT); resources.addOverride(R.dimen.status_bar_height_landscape, STATUS_BAR_HEIGHT); resources.addOverride(R.dimen.navigation_bar_height, NAV_BAR_HEIGHT); resources.addOverride(R.dimen.navigation_bar_height_landscape, NAV_BAR_HEIGHT); resources.addOverride(R.dimen.navigation_bar_width, NAV_BAR_HEIGHT); doReturn(context).when(mDisplayPolicy).getSystemUiContext(); doReturn(resources.getResources()).when(mDisplayPolicy).getCurrentUserResources(); doReturn(true).when(mDisplayPolicy).hasNavigationBar(); doReturn(true).when(mDisplayPolicy).hasStatusBar(); Loading Loading @@ -157,9 +157,9 @@ public class DisplayPolicyTestsBase extends WindowTestsBase { static class TestContextWrapper extends ContextWrapper { private final TestableResources mResourceMocker; TestContextWrapper(Context targetContext) { TestContextWrapper(Context targetContext, Resources targetResources) { super(targetContext); mResourceMocker = new TestableResources(targetContext.getResources()); mResourceMocker = new TestableResources(targetResources); } @Override Loading Loading
services/core/java/com/android/server/wm/DisplayContent.java +1 −0 Original line number Diff line number Diff line Loading @@ -2462,6 +2462,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo void switchUser() { super.switchUser(); mWmService.mWindowsChanged = true; mDisplayPolicy.switchUser(); } private void resetAnimationBackgroundAnimator() { Loading
services/core/java/com/android/server/wm/DisplayPolicy.java +51 −5 Original line number Diff line number Diff line Loading @@ -112,7 +112,10 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Px; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.ActivityThread; import android.app.LoadedApk; import android.app.ResourcesManager; import android.app.StatusBarManager; import android.content.Context; import android.content.Intent; Loading Loading @@ -210,6 +213,8 @@ public class DisplayPolicy { private final Object mLock; private final Handler mHandler; private Resources mCurrentUserResources; private final boolean mCarDockEnablesAccelerometer; private final boolean mDeskDockEnablesAccelerometer; private final AccessibilityManager mAccessibilityManager; Loading Loading @@ -2603,10 +2608,18 @@ public class DisplayPolicy { || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; } /** * Called when the user is switched. */ public void switchUser() { updateCurrentUserResources(); } /** * Called when the resource overlays change. */ public void onOverlayChangedLw() { updateCurrentUserResources(); onConfigurationChanged(); mSystemGestures.onConfigurationChanged(); } Loading @@ -2617,8 +2630,7 @@ public class DisplayPolicy { public void onConfigurationChanged() { final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation(); final Context uiContext = getSystemUiContext(); final Resources res = uiContext.getResources(); final Resources res = getCurrentUserResources(); final int portraitRotation = displayRotation.getPortraitRotation(); final int upsideDownRotation = displayRotation.getUpsideDownRotation(); final int landscapeRotation = displayRotation.getLandscapeRotation(); Loading Loading @@ -2693,15 +2705,49 @@ public class DisplayPolicy { } void updateConfigurationAndScreenSizeDependentBehaviors() { final Context uiContext = getSystemUiContext(); final Resources res = uiContext.getResources(); final Resources res = getCurrentUserResources(); mNavigationBarCanMove = mDisplayContent.mBaseDisplayWidth != mDisplayContent.mBaseDisplayHeight && res.getBoolean(R.bool.config_navBarCanMove); } /** * Updates the current user's resources to pick up any changes for the current user (including * overlay paths) */ private void updateCurrentUserResources() { final int userId = mService.mAmInternal.getCurrentUserId(); final Context uiContext = getSystemUiContext(); 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 */, pi.getOverlayDirs(), pi.getApplicationInfo().sharedLibraryFiles, mDisplayContent.getDisplayId(), null /* overrideConfig */, uiContext.getResources().getCompatibilityInfo(), null /* classLoader */); } @VisibleForTesting Context getSystemUiContext() { Resources getCurrentUserResources() { if (mCurrentUserResources == null) { updateCurrentUserResources(); } return mCurrentUserResources; } @VisibleForTesting Context getContext() { return mContext; } private Context getSystemUiContext() { final Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext(); return mDisplayContent.isDefaultDisplay ? uiContext : uiContext.createDisplayContext(mDisplayContent.getDisplay()); Loading
services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java +5 −5 Original line number Diff line number Diff line Loading @@ -69,15 +69,15 @@ public class DisplayPolicyTestsBase extends WindowTestsBase { public void setUpDisplayPolicy() { mDisplayPolicy = spy(mDisplayContent.getDisplayPolicy()); final TestContextWrapper context = new TestContextWrapper(mDisplayPolicy.getSystemUiContext()); final TestContextWrapper context = new TestContextWrapper( mDisplayPolicy.getContext(), mDisplayPolicy.getCurrentUserResources()); final TestableResources resources = context.getResourceMocker(); resources.addOverride(R.dimen.status_bar_height_portrait, STATUS_BAR_HEIGHT); resources.addOverride(R.dimen.status_bar_height_landscape, STATUS_BAR_HEIGHT); resources.addOverride(R.dimen.navigation_bar_height, NAV_BAR_HEIGHT); resources.addOverride(R.dimen.navigation_bar_height_landscape, NAV_BAR_HEIGHT); resources.addOverride(R.dimen.navigation_bar_width, NAV_BAR_HEIGHT); doReturn(context).when(mDisplayPolicy).getSystemUiContext(); doReturn(resources.getResources()).when(mDisplayPolicy).getCurrentUserResources(); doReturn(true).when(mDisplayPolicy).hasNavigationBar(); doReturn(true).when(mDisplayPolicy).hasStatusBar(); Loading Loading @@ -157,9 +157,9 @@ public class DisplayPolicyTestsBase extends WindowTestsBase { static class TestContextWrapper extends ContextWrapper { private final TestableResources mResourceMocker; TestContextWrapper(Context targetContext) { TestContextWrapper(Context targetContext, Resources targetResources) { super(targetContext); mResourceMocker = new TestableResources(targetContext.getResources()); mResourceMocker = new TestableResources(targetResources); } @Override Loading