diff options
| author | 2023-09-20 15:29:45 +0000 | |
|---|---|---|
| committer | 2023-09-20 15:29:45 +0000 | |
| commit | d911f3a227a182a3ffc0c88b68bc97ed88fc26cc (patch) | |
| tree | 776e84f2d0fa06ead262bc1cb1d71e858e375600 | |
| parent | 8fc6b172502022f3f9321f107cedc5134c154811 (diff) | |
| parent | bbe3d7d21245d846585f5a24fa06f24fec8fcf62 (diff) | |
Merge "Use immutable window decor Configuration in RelayoutParams" into main
2 files changed, 16 insertions, 5 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java index dbff20e6026a..0cacdfc835e6 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java @@ -183,10 +183,20 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin mRelayoutParams.mCaptionHeightId = getCaptionHeightId(); mRelayoutParams.mShadowRadiusId = shadowRadiusID; mRelayoutParams.mApplyStartTransactionOnDraw = applyStartTransactionOnDraw; - - mRelayoutParams.mWindowDecorConfig = DesktopTasksController.isDesktopDensityOverrideSet() - ? mContext.getResources().getConfiguration() // Use system context - : mTaskInfo.configuration; // Use task configuration + // The configuration used to lay out the window decoration. The system context's config is + // used when the task density has been overridden to a custom density so that the resources + // and views of the decoration aren't affected and match the rest of the System UI, if not + // then just use the task's configuration. A copy is made instead of using the original + // reference so that the configuration isn't mutated on config changes and diff checks can + // be made in WindowDecoration#relayout using the pre/post-relayout configuration. + // See b/301119301. + // TODO(b/301119301): consider moving the config data needed for diffs to relayout params + // instead of using a whole Configuration as a parameter. + final Configuration windowDecorConfig = new Configuration(); + windowDecorConfig.setTo(DesktopTasksController.isDesktopDensityOverrideSet() + ? mContext.getResources().getConfiguration() // Use system context. + : mTaskInfo.configuration); // Use task configuration. + mRelayoutParams.mWindowDecorConfig = windowDecorConfig; mRelayoutParams.mCornerRadius = (int) ScreenDecorationsUtils.getWindowCornerRadius(mContext); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java index a26927586b61..2d5ef72d2362 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java @@ -196,7 +196,8 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> final int oldDensityDpi = mWindowDecorConfig.densityDpi; mWindowDecorConfig = params.mWindowDecorConfig != null ? params.mWindowDecorConfig : mTaskInfo.getConfiguration(); - if (oldDensityDpi != mWindowDecorConfig.densityDpi + final int newDensityDpi = mWindowDecorConfig.densityDpi; + if (oldDensityDpi != newDensityDpi || mDisplay == null || mDisplay.getDisplayId() != mTaskInfo.displayId || oldLayoutResId != mLayoutResId) { |