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

Commit b13a44a9 authored by Jorge Gil's avatar Jorge Gil Committed by Android (Google) Code Review
Browse files

Merge changes I0fee6244,Id1b74f70 into main

* changes:
  Restore systemBarsAppearance from preserved window
  Rename TaskDescription's statusBarAppearance to systemBarsAppearance
parents 67aeef80 5dfbd15f
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -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);
    }

+16 −15
Original line number Diff line number Diff line
@@ -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
+8 −3
Original line number Diff line number Diff line
@@ -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.
@@ -1037,6 +1037,11 @@ public abstract class Window {
        mDecorCallback = decorCallback;
    }

    /** @hide */
    public final void setSystemBarAppearance(@WindowInsetsController.Appearance int appearance) {
        mSystemBarAppearance = appearance;
    }

    /** @hide */
    @WindowInsetsController.Appearance
    public final int getSystemBarAppearance() {
@@ -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);
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -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.
+1 −1
Original line number Diff line number Diff line
@@ -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());
Loading