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

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

Merge "Add TaskDescription#topOpaqueSystemBarsAppearance" into main

parents ac8a3743 2d93f503
Loading
Loading
Loading
Loading
+40 −8
Original line number Diff line number Diff line
@@ -1755,6 +1755,12 @@ public class ActivityManager {
        private int mNavigationBarColor;
        @Appearance
        private int mSystemBarsAppearance;
        /**
         * Similar to {@link TaskDescription#mSystemBarsAppearance}, but is taken from the topmost
         * fully opaque (i.e. non transparent) activity in the task.
         */
        @Appearance
        private int mTopOpaqueSystemBarsAppearance;
        private boolean mEnsureStatusBarContrastWhenTransparent;
        private boolean mEnsureNavigationBarContrastWhenTransparent;
        private int mResizeMode;
@@ -1855,7 +1861,7 @@ public class ActivityManager {
                final Icon icon = mIconRes == Resources.ID_NULL ? null :
                        Icon.createWithResource(ActivityThread.currentPackageName(), mIconRes);
                return new TaskDescription(mLabel, icon, mPrimaryColor, mBackgroundColor,
                        mStatusBarColor, mNavigationBarColor, 0, false, false,
                        mStatusBarColor, mNavigationBarColor, 0, 0, false, false,
                        RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            }
        }
@@ -1874,7 +1880,7 @@ public class ActivityManager {
        @Deprecated
        public TaskDescription(String label, @DrawableRes int iconRes, int colorPrimary) {
            this(label, Icon.createWithResource(ActivityThread.currentPackageName(), iconRes),
                    colorPrimary, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
                    colorPrimary, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) {
                throw new RuntimeException("A TaskDescription's primary color should be opaque");
            }
@@ -1892,7 +1898,7 @@ public class ActivityManager {
        @Deprecated
        public TaskDescription(String label, @DrawableRes int iconRes) {
            this(label, Icon.createWithResource(ActivityThread.currentPackageName(), iconRes),
                    0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
                    0, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /**
@@ -1904,7 +1910,7 @@ public class ActivityManager {
         */
        @Deprecated
        public TaskDescription(String label) {
            this(label, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            this(label, null, 0, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /**
@@ -1914,7 +1920,7 @@ public class ActivityManager {
         */
        @Deprecated
        public TaskDescription() {
            this(null, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            this(null, null, 0, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /**
@@ -1930,7 +1936,7 @@ public class ActivityManager {
        @Deprecated
        public TaskDescription(String label, Bitmap icon, int colorPrimary) {
            this(label, icon != null ? Icon.createWithBitmap(icon) : null, colorPrimary, 0, 0, 0,
                    0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
                    0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) {
                throw new RuntimeException("A TaskDescription's primary color should be opaque");
            }
@@ -1946,7 +1952,7 @@ public class ActivityManager {
         */
        @Deprecated
        public TaskDescription(String label, Bitmap icon) {
            this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, 0, false,
            this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, 0, 0, false,
                    false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

@@ -1955,6 +1961,7 @@ public class ActivityManager {
                int colorPrimary, int colorBackground,
                int statusBarColor, int navigationBarColor,
                @Appearance int systemBarsAppearance,
                @Appearance int topOpaqueSystemBarsAppearance,
                boolean ensureStatusBarContrastWhenTransparent,
                boolean ensureNavigationBarContrastWhenTransparent, int resizeMode, int minWidth,
                int minHeight, int colorBackgroundFloating) {
@@ -1965,6 +1972,7 @@ public class ActivityManager {
            mStatusBarColor = statusBarColor;
            mNavigationBarColor = navigationBarColor;
            mSystemBarsAppearance = systemBarsAppearance;
            mTopOpaqueSystemBarsAppearance = topOpaqueSystemBarsAppearance;
            mEnsureStatusBarContrastWhenTransparent = ensureStatusBarContrastWhenTransparent;
            mEnsureNavigationBarContrastWhenTransparent =
                    ensureNavigationBarContrastWhenTransparent;
@@ -1994,6 +2002,7 @@ public class ActivityManager {
            mStatusBarColor = other.mStatusBarColor;
            mNavigationBarColor = other.mNavigationBarColor;
            mSystemBarsAppearance = other.mSystemBarsAppearance;
            mTopOpaqueSystemBarsAppearance = other.mTopOpaqueSystemBarsAppearance;
            mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent;
            mEnsureNavigationBarContrastWhenTransparent =
                    other.mEnsureNavigationBarContrastWhenTransparent;
@@ -2026,6 +2035,9 @@ public class ActivityManager {
            if (other.mSystemBarsAppearance != 0) {
                mSystemBarsAppearance = other.mSystemBarsAppearance;
            }
            if (other.mTopOpaqueSystemBarsAppearance != 0) {
                mTopOpaqueSystemBarsAppearance = other.mTopOpaqueSystemBarsAppearance;
            }

            mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent;
            mEnsureNavigationBarContrastWhenTransparent =
@@ -2302,6 +2314,14 @@ public class ActivityManager {
            return mSystemBarsAppearance;
        }

        /**
         * @hide
         */
        @Appearance
        public int getTopOpaqueSystemBarsAppearance() {
            return mTopOpaqueSystemBarsAppearance;
        }

        /**
         * @hide
         */
@@ -2317,6 +2337,13 @@ public class ActivityManager {
            mSystemBarsAppearance = systemBarsAppearance;
        }

        /**
         * @hide
         */
        public void setTopOpaqueSystemBarsAppearance(int topOpaqueSystemBarsAppearance) {
            mTopOpaqueSystemBarsAppearance = topOpaqueSystemBarsAppearance;
        }

        /**
         * @hide
         */
@@ -2442,6 +2469,7 @@ public class ActivityManager {
            dest.writeInt(mStatusBarColor);
            dest.writeInt(mNavigationBarColor);
            dest.writeInt(mSystemBarsAppearance);
            dest.writeInt(mTopOpaqueSystemBarsAppearance);
            dest.writeBoolean(mEnsureStatusBarContrastWhenTransparent);
            dest.writeBoolean(mEnsureNavigationBarContrastWhenTransparent);
            dest.writeInt(mResizeMode);
@@ -2466,6 +2494,7 @@ public class ActivityManager {
            mStatusBarColor = source.readInt();
            mNavigationBarColor = source.readInt();
            mSystemBarsAppearance = source.readInt();
            mTopOpaqueSystemBarsAppearance = source.readInt();
            mEnsureStatusBarContrastWhenTransparent = source.readBoolean();
            mEnsureNavigationBarContrastWhenTransparent = source.readBoolean();
            mResizeMode = source.readInt();
@@ -2498,7 +2527,8 @@ public class ActivityManager {
                    + " resizeMode: " + ActivityInfo.resizeModeToString(mResizeMode)
                    + " minWidth: " + mMinWidth + " minHeight: " + mMinHeight
                    + " colorBackgrounFloating: " + mColorBackgroundFloating
                    + " systemBarsAppearance: " + mSystemBarsAppearance;
                    + " systemBarsAppearance: " + mSystemBarsAppearance
                    + " topOpaqueSystemBarsAppearance: " + mTopOpaqueSystemBarsAppearance;
        }

        @Override
@@ -2519,6 +2549,7 @@ public class ActivityManager {
            result = result * 31 + mStatusBarColor;
            result = result * 31 + mNavigationBarColor;
            result = result * 31 + mSystemBarsAppearance;
            result = result * 31 + mTopOpaqueSystemBarsAppearance;
            result = result * 31 + (mEnsureStatusBarContrastWhenTransparent ? 1 : 0);
            result = result * 31 + (mEnsureNavigationBarContrastWhenTransparent ? 1 : 0);
            result = result * 31 + mResizeMode;
@@ -2542,6 +2573,7 @@ public class ActivityManager {
                    && mStatusBarColor == other.mStatusBarColor
                    && mNavigationBarColor == other.mNavigationBarColor
                    && mSystemBarsAppearance == other.mSystemBarsAppearance
                    && mTopOpaqueSystemBarsAppearance == other.mTopOpaqueSystemBarsAppearance
                    && mEnsureStatusBarContrastWhenTransparent
                            == other.mEnsureStatusBarContrastWhenTransparent
                    && mEnsureNavigationBarContrastWhenTransparent
+12 −5
Original line number Diff line number Diff line
@@ -128,7 +128,8 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x222222,                // colorBackground
                0x333333,                // statusBarColor
                0x444444,                // navigationBarColor
                0,                       // statusBarAppearance
                0x555555,                // systemBarsAppeareance
                0x666666,                // topOpaqueSystemBarsAppeareance
                true,                    // ensureStatusBarContrastWhenTransparent
                true,                    // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_RESIZEABLE,  // resizeMode
@@ -153,7 +154,8 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x222222,                  // colorBackground
                0x333333,                  // statusBarColor
                0x444444,                  // navigationBarColor
                0,                         // statusBarAppearance
                0x555555,                  // systemBarsAppeareance
                0x666666,                  // topOpaqueSystemBarsAppeareance
                false,                     // ensureStatusBarContrastWhenTransparent
                false,                     // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_UNRESIZEABLE,  // resizeMode
@@ -169,7 +171,8 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x2222222,               // colorBackground
                0x3333332,               // statusBarColor
                0x4444442,               // navigationBarColor
                0,                       // statusBarAppearance
                0x5555552,               // systemBarsAppeareance
                0x6666662,               // topOpaqueSystemBarsAppeareance
                true,                    // ensureStatusBarContrastWhenTransparent
                true,                    // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_RESIZEABLE,  // resizeMode
@@ -200,7 +203,8 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x222222,                  // colorBackground
                0x333333,                  // statusBarColor
                0x444444,                  // navigationBarColor
                0,                         // statusBarAppearance
                0x555555,                  // systemBarsAppeareance
                0x666666,                  // topOpaqueSystemBarsAppeareance
                false,                     // ensureStatusBarContrastWhenTransparent
                false,                     // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_UNRESIZEABLE,  // resizeMode
@@ -223,7 +227,8 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x222222,                  // colorBackground
                0x333333,                  // statusBarColor
                0x444444,                  // navigationBarColor
                0,                         // statusBarAppearance
                0x555555,                  // systemBarsAppeareance
                0x666666,                  // topOpaqueSystemBarsAppeareance
                false,                     // ensureStatusBarContrastWhenTransparent
                false,                     // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_UNRESIZEABLE,  // resizeMode
@@ -256,6 +261,8 @@ public class ActivityManagerTest extends AndroidTestCase {
            assertEquals(td1.getStatusBarColor(), td2.getStatusBarColor());
            assertEquals(td1.getNavigationBarColor(), td2.getNavigationBarColor());
            assertEquals(td1.getSystemBarsAppearance(), td2.getSystemBarsAppearance());
            assertEquals(td1.getTopOpaqueSystemBarsAppearance(),
                    td2.getTopOpaqueSystemBarsAppearance());
            assertEquals(td1.getResizeMode(), td2.getResizeMode());
            assertEquals(td1.getMinWidth(), td2.getMinWidth());
            assertEquals(td1.getMinHeight(), td2.getMinHeight());
+2 −2
Original line number Diff line number Diff line
@@ -23,13 +23,13 @@ import android.view.WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BA

val TaskInfo.isTransparentCaptionBarAppearance: Boolean
    get() {
        val appearance = taskDescription?.systemBarsAppearance ?: 0
        val appearance = taskDescription?.topOpaqueSystemBarsAppearance ?: 0
        return (appearance and APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND) != 0
    }

val TaskInfo.isLightCaptionBarAppearance: Boolean
    get() {
        val appearance = taskDescription?.systemBarsAppearance ?: 0
        val appearance = taskDescription?.topOpaqueSystemBarsAppearance ?: 0
        return (appearance and APPEARANCE_LIGHT_CAPTION_BARS) != 0
    }

+2 −2
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    public void updateRelayoutParams_freeformAndTransparentAppearance_allowsInputFallthrough() {
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM);
        taskInfo.taskDescription.setSystemBarsAppearance(
        taskInfo.taskDescription.setTopOpaqueSystemBarsAppearance(
                APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND);
        final RelayoutParams relayoutParams = new RelayoutParams();

@@ -246,7 +246,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
    public void updateRelayoutParams_freeformButOpaqueAppearance_disallowsInputFallthrough() {
        final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(/* visible= */ true);
        taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM);
        taskInfo.taskDescription.setSystemBarsAppearance(0);
        taskInfo.taskDescription.setTopOpaqueSystemBarsAppearance(0);
        final RelayoutParams relayoutParams = new RelayoutParams();

        DesktopModeWindowDecoration.updateRelayoutParams(
+3 −0
Original line number Diff line number Diff line
@@ -1931,6 +1931,9 @@ class Task extends TaskFragment {
            if (td.getSystemBarsAppearance() == 0) {
                td.setSystemBarsAppearance(atd.getSystemBarsAppearance());
            }
            if (td.getTopOpaqueSystemBarsAppearance() == 0 && r.fillsParent()) {
                td.setTopOpaqueSystemBarsAppearance(atd.getSystemBarsAppearance());
            }
            if (td.getNavigationBarColor() == 0) {
                td.setNavigationBarColor(atd.getNavigationBarColor());
                td.setEnsureNavigationBarContrastWhenTransparent(