Loading core/java/android/app/Activity.java +10 −0 Original line number Diff line number Diff line Loading @@ -1083,6 +1083,16 @@ public class Activity extends ContextThemeWrapper setTaskDescription(mTaskDescription); } /** * Update the forced status bar appearance. * @hide */ @Override public void updateStatusBarAppearance(int appearance) { mTaskDescription.setStatusBarAppearance(appearance); setTaskDescription(mTaskDescription); } /** * Update the forced navigation bar color. * @hide Loading core/java/android/app/ActivityManager.java +36 −9 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ import android.util.ArrayMap; import android.util.DisplayMetrics; import android.util.Singleton; import android.util.Size; import android.view.WindowInsetsController.Appearance; import android.window.TaskSnapshot; import com.android.internal.app.LocalePicker; Loading Loading @@ -1553,6 +1554,8 @@ public class ActivityManager { private int mColorBackgroundFloating; private int mStatusBarColor; private int mNavigationBarColor; @Appearance private int mStatusBarAppearance; private boolean mEnsureStatusBarContrastWhenTransparent; private boolean mEnsureNavigationBarContrastWhenTransparent; private int mResizeMode; Loading Loading @@ -1653,8 +1656,8 @@ 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, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); mStatusBarColor, mNavigationBarColor, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } } Loading @@ -1672,7 +1675,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, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); colorPrimary, 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"); } Loading @@ -1690,7 +1693,7 @@ public class ActivityManager { @Deprecated public TaskDescription(String label, @DrawableRes int iconRes) { this(label, Icon.createWithResource(ActivityThread.currentPackageName(), iconRes), 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } /** Loading @@ -1702,7 +1705,7 @@ public class ActivityManager { */ @Deprecated public TaskDescription(String label) { this(label, null, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); this(label, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } /** Loading @@ -1712,7 +1715,7 @@ public class ActivityManager { */ @Deprecated public TaskDescription() { this(null, null, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); this(null, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } /** Loading @@ -1728,7 +1731,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, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 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"); } Loading @@ -1744,14 +1747,15 @@ public class ActivityManager { */ @Deprecated public TaskDescription(String label, Bitmap icon) { this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } /** @hide */ public TaskDescription(@Nullable String label, @Nullable Icon icon, int colorPrimary, int colorBackground, int statusBarColor, int navigationBarColor, @Appearance int statusBarAppearance, boolean ensureStatusBarContrastWhenTransparent, boolean ensureNavigationBarContrastWhenTransparent, int resizeMode, int minWidth, int minHeight, int colorBackgroundFloating) { Loading @@ -1761,6 +1765,7 @@ public class ActivityManager { mColorBackground = colorBackground; mStatusBarColor = statusBarColor; mNavigationBarColor = navigationBarColor; mStatusBarAppearance = statusBarAppearance; mEnsureStatusBarContrastWhenTransparent = ensureStatusBarContrastWhenTransparent; mEnsureNavigationBarContrastWhenTransparent = ensureNavigationBarContrastWhenTransparent; Loading Loading @@ -1789,6 +1794,7 @@ public class ActivityManager { mColorBackground = other.mColorBackground; mStatusBarColor = other.mStatusBarColor; mNavigationBarColor = other.mNavigationBarColor; mStatusBarAppearance = other.mStatusBarAppearance; mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent; mEnsureNavigationBarContrastWhenTransparent = other.mEnsureNavigationBarContrastWhenTransparent; Loading Loading @@ -1818,6 +1824,9 @@ public class ActivityManager { if (other.mNavigationBarColor != 0) { mNavigationBarColor = other.mNavigationBarColor; } if (other.mStatusBarAppearance != 0) { mStatusBarAppearance = other.mStatusBarAppearance; } mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent; mEnsureNavigationBarContrastWhenTransparent = Loading Loading @@ -2086,6 +2095,14 @@ public class ActivityManager { return mEnsureStatusBarContrastWhenTransparent; } /** * @hide */ @Appearance public int getStatusBarAppearance() { return mStatusBarAppearance; } /** * @hide */ Loading @@ -2094,6 +2111,13 @@ public class ActivityManager { mEnsureStatusBarContrastWhenTransparent = ensureStatusBarContrastWhenTransparent; } /** * @hide */ public void setStatusBarAppearance(@Appearance int statusBarAppearance) { mStatusBarAppearance = statusBarAppearance; } /** * @hide */ Loading Loading @@ -2218,6 +2242,7 @@ public class ActivityManager { dest.writeInt(mColorBackground); dest.writeInt(mStatusBarColor); dest.writeInt(mNavigationBarColor); dest.writeInt(mStatusBarAppearance); dest.writeBoolean(mEnsureStatusBarContrastWhenTransparent); dest.writeBoolean(mEnsureNavigationBarContrastWhenTransparent); dest.writeInt(mResizeMode); Loading @@ -2241,6 +2266,7 @@ public class ActivityManager { mColorBackground = source.readInt(); mStatusBarColor = source.readInt(); mNavigationBarColor = source.readInt(); mStatusBarAppearance = source.readInt(); mEnsureStatusBarContrastWhenTransparent = source.readBoolean(); mEnsureNavigationBarContrastWhenTransparent = source.readBoolean(); mResizeMode = source.readInt(); Loading Loading @@ -2289,6 +2315,7 @@ public class ActivityManager { && mColorBackground == other.mColorBackground && mStatusBarColor == other.mStatusBarColor && mNavigationBarColor == other.mNavigationBarColor && mStatusBarAppearance == other.mStatusBarAppearance && mEnsureStatusBarContrastWhenTransparent == other.mEnsureStatusBarContrastWhenTransparent && mEnsureNavigationBarContrastWhenTransparent Loading core/java/android/view/Window.java +9 −0 Original line number Diff line number Diff line Loading @@ -657,6 +657,12 @@ public abstract class Window { */ void updateStatusBarColor(int color); /** * Update the status bar appearance. */ void updateStatusBarAppearance(int appearance); /** * Update the navigation bar color to a forced one. */ Loading Loading @@ -1039,6 +1045,9 @@ public abstract class Window { if (mDecorCallback != null) { mDecorCallback.onSystemBarAppearanceChanged(appearance); } if (mWindowControllerCallback != null) { mWindowControllerCallback.updateStatusBarAppearance(appearance); } } /** @hide */ Loading core/tests/coretests/src/android/app/activity/ActivityManagerTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x222222, // colorBackground 0x333333, // statusBarColor 0x444444, // navigationBarColor 0, // statusBarAppearance true, // ensureStatusBarContrastWhenTransparent true, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_RESIZEABLE, // resizeMode Loading @@ -152,6 +153,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x222222, // colorBackground 0x333333, // statusBarColor 0x444444, // navigationBarColor 0, // statusBarAppearance false, // ensureStatusBarContrastWhenTransparent false, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_UNRESIZEABLE, // resizeMode Loading @@ -167,6 +169,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x2222222, // colorBackground 0x3333332, // statusBarColor 0x4444442, // navigationBarColor 0, // statusBarAppearance true, // ensureStatusBarContrastWhenTransparent true, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_RESIZEABLE, // resizeMode Loading Loading @@ -197,6 +200,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x222222, // colorBackground 0x333333, // statusBarColor 0x444444, // navigationBarColor 0, // statusBarAppearance false, // ensureStatusBarContrastWhenTransparent false, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_UNRESIZEABLE, // resizeMode Loading @@ -219,6 +223,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x222222, // colorBackground 0x333333, // statusBarColor 0x444444, // navigationBarColor 0, // statusBarAppearance false, // ensureStatusBarContrastWhenTransparent false, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_UNRESIZEABLE, // resizeMode Loading Loading @@ -250,6 +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.getResizeMode(), td2.getResizeMode()); assertEquals(td1.getMinWidth(), td2.getMinWidth()); assertEquals(td1.getMinHeight(), td2.getMinHeight()); Loading services/core/java/com/android/server/wm/Task.java +3 −0 Original line number Diff line number Diff line Loading @@ -1847,6 +1847,9 @@ class Task extends TaskFragment { td.setEnsureStatusBarContrastWhenTransparent( atd.getEnsureStatusBarContrastWhenTransparent()); } if (td.getStatusBarAppearance() == 0) { td.setStatusBarAppearance(atd.getStatusBarAppearance()); } if (td.getNavigationBarColor() == 0) { td.setNavigationBarColor(atd.getNavigationBarColor()); td.setEnsureNavigationBarContrastWhenTransparent( Loading Loading
core/java/android/app/Activity.java +10 −0 Original line number Diff line number Diff line Loading @@ -1083,6 +1083,16 @@ public class Activity extends ContextThemeWrapper setTaskDescription(mTaskDescription); } /** * Update the forced status bar appearance. * @hide */ @Override public void updateStatusBarAppearance(int appearance) { mTaskDescription.setStatusBarAppearance(appearance); setTaskDescription(mTaskDescription); } /** * Update the forced navigation bar color. * @hide Loading
core/java/android/app/ActivityManager.java +36 −9 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ import android.util.ArrayMap; import android.util.DisplayMetrics; import android.util.Singleton; import android.util.Size; import android.view.WindowInsetsController.Appearance; import android.window.TaskSnapshot; import com.android.internal.app.LocalePicker; Loading Loading @@ -1553,6 +1554,8 @@ public class ActivityManager { private int mColorBackgroundFloating; private int mStatusBarColor; private int mNavigationBarColor; @Appearance private int mStatusBarAppearance; private boolean mEnsureStatusBarContrastWhenTransparent; private boolean mEnsureNavigationBarContrastWhenTransparent; private int mResizeMode; Loading Loading @@ -1653,8 +1656,8 @@ 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, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); mStatusBarColor, mNavigationBarColor, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } } Loading @@ -1672,7 +1675,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, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); colorPrimary, 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"); } Loading @@ -1690,7 +1693,7 @@ public class ActivityManager { @Deprecated public TaskDescription(String label, @DrawableRes int iconRes) { this(label, Icon.createWithResource(ActivityThread.currentPackageName(), iconRes), 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } /** Loading @@ -1702,7 +1705,7 @@ public class ActivityManager { */ @Deprecated public TaskDescription(String label) { this(label, null, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); this(label, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } /** Loading @@ -1712,7 +1715,7 @@ public class ActivityManager { */ @Deprecated public TaskDescription() { this(null, null, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); this(null, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } /** Loading @@ -1728,7 +1731,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, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 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"); } Loading @@ -1744,14 +1747,15 @@ public class ActivityManager { */ @Deprecated public TaskDescription(String label, Bitmap icon) { this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0); } /** @hide */ public TaskDescription(@Nullable String label, @Nullable Icon icon, int colorPrimary, int colorBackground, int statusBarColor, int navigationBarColor, @Appearance int statusBarAppearance, boolean ensureStatusBarContrastWhenTransparent, boolean ensureNavigationBarContrastWhenTransparent, int resizeMode, int minWidth, int minHeight, int colorBackgroundFloating) { Loading @@ -1761,6 +1765,7 @@ public class ActivityManager { mColorBackground = colorBackground; mStatusBarColor = statusBarColor; mNavigationBarColor = navigationBarColor; mStatusBarAppearance = statusBarAppearance; mEnsureStatusBarContrastWhenTransparent = ensureStatusBarContrastWhenTransparent; mEnsureNavigationBarContrastWhenTransparent = ensureNavigationBarContrastWhenTransparent; Loading Loading @@ -1789,6 +1794,7 @@ public class ActivityManager { mColorBackground = other.mColorBackground; mStatusBarColor = other.mStatusBarColor; mNavigationBarColor = other.mNavigationBarColor; mStatusBarAppearance = other.mStatusBarAppearance; mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent; mEnsureNavigationBarContrastWhenTransparent = other.mEnsureNavigationBarContrastWhenTransparent; Loading Loading @@ -1818,6 +1824,9 @@ public class ActivityManager { if (other.mNavigationBarColor != 0) { mNavigationBarColor = other.mNavigationBarColor; } if (other.mStatusBarAppearance != 0) { mStatusBarAppearance = other.mStatusBarAppearance; } mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent; mEnsureNavigationBarContrastWhenTransparent = Loading Loading @@ -2086,6 +2095,14 @@ public class ActivityManager { return mEnsureStatusBarContrastWhenTransparent; } /** * @hide */ @Appearance public int getStatusBarAppearance() { return mStatusBarAppearance; } /** * @hide */ Loading @@ -2094,6 +2111,13 @@ public class ActivityManager { mEnsureStatusBarContrastWhenTransparent = ensureStatusBarContrastWhenTransparent; } /** * @hide */ public void setStatusBarAppearance(@Appearance int statusBarAppearance) { mStatusBarAppearance = statusBarAppearance; } /** * @hide */ Loading Loading @@ -2218,6 +2242,7 @@ public class ActivityManager { dest.writeInt(mColorBackground); dest.writeInt(mStatusBarColor); dest.writeInt(mNavigationBarColor); dest.writeInt(mStatusBarAppearance); dest.writeBoolean(mEnsureStatusBarContrastWhenTransparent); dest.writeBoolean(mEnsureNavigationBarContrastWhenTransparent); dest.writeInt(mResizeMode); Loading @@ -2241,6 +2266,7 @@ public class ActivityManager { mColorBackground = source.readInt(); mStatusBarColor = source.readInt(); mNavigationBarColor = source.readInt(); mStatusBarAppearance = source.readInt(); mEnsureStatusBarContrastWhenTransparent = source.readBoolean(); mEnsureNavigationBarContrastWhenTransparent = source.readBoolean(); mResizeMode = source.readInt(); Loading Loading @@ -2289,6 +2315,7 @@ public class ActivityManager { && mColorBackground == other.mColorBackground && mStatusBarColor == other.mStatusBarColor && mNavigationBarColor == other.mNavigationBarColor && mStatusBarAppearance == other.mStatusBarAppearance && mEnsureStatusBarContrastWhenTransparent == other.mEnsureStatusBarContrastWhenTransparent && mEnsureNavigationBarContrastWhenTransparent Loading
core/java/android/view/Window.java +9 −0 Original line number Diff line number Diff line Loading @@ -657,6 +657,12 @@ public abstract class Window { */ void updateStatusBarColor(int color); /** * Update the status bar appearance. */ void updateStatusBarAppearance(int appearance); /** * Update the navigation bar color to a forced one. */ Loading Loading @@ -1039,6 +1045,9 @@ public abstract class Window { if (mDecorCallback != null) { mDecorCallback.onSystemBarAppearanceChanged(appearance); } if (mWindowControllerCallback != null) { mWindowControllerCallback.updateStatusBarAppearance(appearance); } } /** @hide */ Loading
core/tests/coretests/src/android/app/activity/ActivityManagerTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x222222, // colorBackground 0x333333, // statusBarColor 0x444444, // navigationBarColor 0, // statusBarAppearance true, // ensureStatusBarContrastWhenTransparent true, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_RESIZEABLE, // resizeMode Loading @@ -152,6 +153,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x222222, // colorBackground 0x333333, // statusBarColor 0x444444, // navigationBarColor 0, // statusBarAppearance false, // ensureStatusBarContrastWhenTransparent false, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_UNRESIZEABLE, // resizeMode Loading @@ -167,6 +169,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x2222222, // colorBackground 0x3333332, // statusBarColor 0x4444442, // navigationBarColor 0, // statusBarAppearance true, // ensureStatusBarContrastWhenTransparent true, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_RESIZEABLE, // resizeMode Loading Loading @@ -197,6 +200,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x222222, // colorBackground 0x333333, // statusBarColor 0x444444, // navigationBarColor 0, // statusBarAppearance false, // ensureStatusBarContrastWhenTransparent false, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_UNRESIZEABLE, // resizeMode Loading @@ -219,6 +223,7 @@ public class ActivityManagerTest extends AndroidTestCase { 0x222222, // colorBackground 0x333333, // statusBarColor 0x444444, // navigationBarColor 0, // statusBarAppearance false, // ensureStatusBarContrastWhenTransparent false, // ensureNavigationBarContrastWhenTransparent RESIZE_MODE_UNRESIZEABLE, // resizeMode Loading Loading @@ -250,6 +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.getResizeMode(), td2.getResizeMode()); assertEquals(td1.getMinWidth(), td2.getMinWidth()); assertEquals(td1.getMinHeight(), td2.getMinHeight()); Loading
services/core/java/com/android/server/wm/Task.java +3 −0 Original line number Diff line number Diff line Loading @@ -1847,6 +1847,9 @@ class Task extends TaskFragment { td.setEnsureStatusBarContrastWhenTransparent( atd.getEnsureStatusBarContrastWhenTransparent()); } if (td.getStatusBarAppearance() == 0) { td.setStatusBarAppearance(atd.getStatusBarAppearance()); } if (td.getNavigationBarColor() == 0) { td.setNavigationBarColor(atd.getNavigationBarColor()); td.setEnsureNavigationBarContrastWhenTransparent( Loading