diff options
9 files changed, 44 insertions, 28 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 44dc8e2f4cb7..afbefca0cefe 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -1126,8 +1126,8 @@ public class Activity extends ContextThemeWrapper * @hide */ @Override - public void updateStatusBarAppearance(int appearance) { - mTaskDescription.setStatusBarAppearance(appearance); + public void updateSystemBarsAppearance(int appearance) { + mTaskDescription.setSystemBarsAppearance(appearance); setTaskDescription(mTaskDescription); } @@ -5546,6 +5546,15 @@ public class Activity extends ContextThemeWrapper } a.recycle(); + if (first && mTaskDescription.getSystemBarsAppearance() == 0 + && mWindow != null && mWindow.getSystemBarAppearance() != 0) { + // When the theme is applied for the first time during the activity re-creation process, + // the attached window restores the system bars appearance from the old window/activity. + // Make sure to restore this appearance in TaskDescription too, to prevent the + // #setTaskDescription() call below from incorrectly sending an empty value to the + // server. + mTaskDescription.setSystemBarsAppearance(mWindow.getSystemBarAppearance()); + } setTaskDescription(mTaskDescription); } diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index f3585229d823..39823a863b4a 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -1604,7 +1604,7 @@ public class ActivityManager { private int mStatusBarColor; private int mNavigationBarColor; @Appearance - private int mStatusBarAppearance; + private int mSystemBarsAppearance; private boolean mEnsureStatusBarContrastWhenTransparent; private boolean mEnsureNavigationBarContrastWhenTransparent; private int mResizeMode; @@ -1804,7 +1804,7 @@ public class ActivityManager { public TaskDescription(@Nullable String label, @Nullable Icon icon, int colorPrimary, int colorBackground, int statusBarColor, int navigationBarColor, - @Appearance int statusBarAppearance, + @Appearance int systemBarsAppearance, boolean ensureStatusBarContrastWhenTransparent, boolean ensureNavigationBarContrastWhenTransparent, int resizeMode, int minWidth, int minHeight, int colorBackgroundFloating) { @@ -1814,7 +1814,7 @@ public class ActivityManager { mColorBackground = colorBackground; mStatusBarColor = statusBarColor; mNavigationBarColor = navigationBarColor; - mStatusBarAppearance = statusBarAppearance; + mSystemBarsAppearance = systemBarsAppearance; mEnsureStatusBarContrastWhenTransparent = ensureStatusBarContrastWhenTransparent; mEnsureNavigationBarContrastWhenTransparent = ensureNavigationBarContrastWhenTransparent; @@ -1843,7 +1843,7 @@ public class ActivityManager { mColorBackground = other.mColorBackground; mStatusBarColor = other.mStatusBarColor; mNavigationBarColor = other.mNavigationBarColor; - mStatusBarAppearance = other.mStatusBarAppearance; + mSystemBarsAppearance = other.mSystemBarsAppearance; mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent; mEnsureNavigationBarContrastWhenTransparent = other.mEnsureNavigationBarContrastWhenTransparent; @@ -1873,8 +1873,8 @@ public class ActivityManager { if (other.mNavigationBarColor != 0) { mNavigationBarColor = other.mNavigationBarColor; } - if (other.mStatusBarAppearance != 0) { - mStatusBarAppearance = other.mStatusBarAppearance; + if (other.mSystemBarsAppearance != 0) { + mSystemBarsAppearance = other.mSystemBarsAppearance; } mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent; @@ -2148,8 +2148,8 @@ public class ActivityManager { * @hide */ @Appearance - public int getStatusBarAppearance() { - return mStatusBarAppearance; + public int getSystemBarsAppearance() { + return mSystemBarsAppearance; } /** @@ -2163,8 +2163,8 @@ public class ActivityManager { /** * @hide */ - public void setStatusBarAppearance(@Appearance int statusBarAppearance) { - mStatusBarAppearance = statusBarAppearance; + public void setSystemBarsAppearance(@Appearance int systemBarsAppearance) { + mSystemBarsAppearance = systemBarsAppearance; } /** @@ -2291,7 +2291,7 @@ public class ActivityManager { dest.writeInt(mColorBackground); dest.writeInt(mStatusBarColor); dest.writeInt(mNavigationBarColor); - dest.writeInt(mStatusBarAppearance); + dest.writeInt(mSystemBarsAppearance); dest.writeBoolean(mEnsureStatusBarContrastWhenTransparent); dest.writeBoolean(mEnsureNavigationBarContrastWhenTransparent); dest.writeInt(mResizeMode); @@ -2315,7 +2315,7 @@ public class ActivityManager { mColorBackground = source.readInt(); mStatusBarColor = source.readInt(); mNavigationBarColor = source.readInt(); - mStatusBarAppearance = source.readInt(); + mSystemBarsAppearance = source.readInt(); mEnsureStatusBarContrastWhenTransparent = source.readBoolean(); mEnsureNavigationBarContrastWhenTransparent = source.readBoolean(); mResizeMode = source.readInt(); @@ -2347,7 +2347,8 @@ public class ActivityManager { ? " (contrast when transparent)" : "") + " resizeMode: " + ActivityInfo.resizeModeToString(mResizeMode) + " minWidth: " + mMinWidth + " minHeight: " + mMinHeight - + " colorBackgrounFloating: " + mColorBackgroundFloating; + + " colorBackgrounFloating: " + mColorBackgroundFloating + + " systemBarsAppearance: " + mSystemBarsAppearance; } @Override @@ -2367,7 +2368,7 @@ public class ActivityManager { result = result * 31 + mColorBackgroundFloating; result = result * 31 + mStatusBarColor; result = result * 31 + mNavigationBarColor; - result = result * 31 + mStatusBarAppearance; + result = result * 31 + mSystemBarsAppearance; result = result * 31 + (mEnsureStatusBarContrastWhenTransparent ? 1 : 0); result = result * 31 + (mEnsureNavigationBarContrastWhenTransparent ? 1 : 0); result = result * 31 + mResizeMode; @@ -2390,7 +2391,7 @@ public class ActivityManager { && mColorBackground == other.mColorBackground && mStatusBarColor == other.mStatusBarColor && mNavigationBarColor == other.mNavigationBarColor - && mStatusBarAppearance == other.mStatusBarAppearance + && mSystemBarsAppearance == other.mSystemBarsAppearance && mEnsureStatusBarContrastWhenTransparent == other.mEnsureStatusBarContrastWhenTransparent && mEnsureNavigationBarContrastWhenTransparent diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 6b427fc00766..51229a75edf8 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -666,7 +666,7 @@ public abstract class Window { * Update the status bar appearance. */ - void updateStatusBarAppearance(int appearance); + void updateSystemBarsAppearance(int appearance); /** * Update the navigation bar color to a forced one. @@ -1038,6 +1038,11 @@ public abstract class Window { } /** @hide */ + public final void setSystemBarAppearance(@WindowInsetsController.Appearance int appearance) { + mSystemBarAppearance = appearance; + } + + /** @hide */ @WindowInsetsController.Appearance public final int getSystemBarAppearance() { return mSystemBarAppearance; @@ -1046,12 +1051,12 @@ public abstract class Window { /** @hide */ public final void dispatchOnSystemBarAppearanceChanged( @WindowInsetsController.Appearance int appearance) { - mSystemBarAppearance = appearance; + setSystemBarAppearance(appearance); if (mDecorCallback != null) { mDecorCallback.onSystemBarAppearanceChanged(appearance); } if (mWindowControllerCallback != null) { - mWindowControllerCallback.updateStatusBarAppearance(appearance); + mWindowControllerCallback.updateSystemBarsAppearance(appearance); } } diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index 0dd01e48db0a..2f1d654c8b37 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -406,6 +406,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { mElevation = preservedWindow.getElevation(); mLoadElevation = false; mForceDecorInstall = true; + setSystemBarAppearance(preservedWindow.getSystemBarAppearance()); // If we're preserving window, carry over the app token from the preserved // window, as we'll be skipping the addView in handleResumeActivity(), and // the token will not be updated as for a new window. diff --git a/core/tests/coretests/src/android/app/activity/ActivityManagerTest.java b/core/tests/coretests/src/android/app/activity/ActivityManagerTest.java index 5ac99db3aea5..89c2b3cecfef 100644 --- a/core/tests/coretests/src/android/app/activity/ActivityManagerTest.java +++ b/core/tests/coretests/src/android/app/activity/ActivityManagerTest.java @@ -255,7 +255,7 @@ public class ActivityManagerTest extends AndroidTestCase { assertEquals(td1.getBackgroundColor(), td2.getBackgroundColor()); assertEquals(td1.getStatusBarColor(), td2.getStatusBarColor()); assertEquals(td1.getNavigationBarColor(), td2.getNavigationBarColor()); - assertEquals(td1.getStatusBarAppearance(), td2.getStatusBarAppearance()); + assertEquals(td1.getSystemBarsAppearance(), td2.getSystemBarsAppearance()); assertEquals(td1.getResizeMode(), td2.getResizeMode()); assertEquals(td1.getMinWidth(), td2.getMinWidth()); assertEquals(td1.getMinHeight(), td2.getMinHeight()); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/extension/TaskInfo.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/extension/TaskInfo.kt index 5dd96aceaec7..7a64a47a46cc 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/extension/TaskInfo.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/extension/TaskInfo.kt @@ -22,12 +22,12 @@ import android.view.WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BA val TaskInfo.isTransparentCaptionBarAppearance: Boolean get() { - val appearance = taskDescription?.statusBarAppearance ?: 0 + val appearance = taskDescription?.systemBarsAppearance ?: 0 return (appearance and APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND) != 0 } val TaskInfo.isLightCaptionBarAppearance: Boolean get() { - val appearance = taskDescription?.statusBarAppearance ?: 0 + val appearance = taskDescription?.systemBarsAppearance ?: 0 return (appearance and APPEARANCE_LIGHT_CAPTION_BARS) != 0 } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt index 6dcae2776847..96bc4a146ebd 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt @@ -65,7 +65,7 @@ internal class DesktopModeFocusedWindowDecorationViewHolder( taskInfo.windowingMode == WINDOWING_MODE_FREEFORM) { Color.valueOf(taskDescription.statusBarColor).luminance() < 0.5 } else { - taskDescription.statusBarAppearance and APPEARANCE_LIGHT_STATUS_BARS == 0 + taskDescription.systemBarsAppearance and APPEARANCE_LIGHT_STATUS_BARS == 0 } } ?: false } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java index 9e62bd254ac5..ba3f6ddfa7d4 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java @@ -176,7 +176,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { public void updateRelayoutParams_freeformAndTransparent_allowsInputFallthrough() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); - taskInfo.taskDescription.setStatusBarAppearance( + taskInfo.taskDescription.setSystemBarsAppearance( APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND); final RelayoutParams relayoutParams = new RelayoutParams(); @@ -194,7 +194,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { public void updateRelayoutParams_freeformButOpaque_disallowsInputFallthrough() { final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); - taskInfo.taskDescription.setStatusBarAppearance(0); + taskInfo.taskDescription.setSystemBarsAppearance(0); final RelayoutParams relayoutParams = new RelayoutParams(); DesktopModeWindowDecoration.updateRelayoutParams( diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 73aa3078d12b..d87e21c0ac92 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1933,8 +1933,8 @@ class Task extends TaskFragment { td.setEnsureStatusBarContrastWhenTransparent( atd.getEnsureStatusBarContrastWhenTransparent()); } - if (td.getStatusBarAppearance() == 0) { - td.setStatusBarAppearance(atd.getStatusBarAppearance()); + if (td.getSystemBarsAppearance() == 0) { + td.setSystemBarsAppearance(atd.getSystemBarsAppearance()); } if (td.getNavigationBarColor() == 0) { td.setNavigationBarColor(atd.getNavigationBarColor()); |