From f4156ea642f945f2a816f86b23a18d2f9f41e16e Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Mon, 10 Apr 2017 18:39:04 -0700 Subject: [PATCH] Make sure theme attributes don't get lost When an app calls setTaskDescription it overrides the hidden attributes derived from the theme. Make sure to not override these if they aren't set in the new task description. Test: Open Maps, go home, rotate, open maps again, make sure navigation bar is black Bug: 36703868 Change-Id: If3f8948fe81af324411c2e828834f5d81e3eeddd --- core/java/android/app/Activity.java | 2 +- core/java/android/app/ActivityManager.java | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 2376a95526aad..53e5cc8940ef6 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -5866,7 +5866,7 @@ public class Activity extends ContextThemeWrapper */ public void setTaskDescription(ActivityManager.TaskDescription taskDescription) { if (mTaskDescription != taskDescription) { - mTaskDescription.copyFrom(taskDescription); + mTaskDescription.copyFromPreserveHiddenFields(taskDescription); // Scale the icon down to something reasonable if it is provided if (taskDescription.getIconFilename() == null && taskDescription.getIcon() != null) { final int size = ActivityManager.getLauncherLargeIconSizeInner(this); diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index aede1bb67f80d..e3c8e4402e741 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -1222,6 +1222,27 @@ public class ActivityManager { mNavigationBarColor = other.mNavigationBarColor; } + /** + * Copies this the values from another TaskDescription, but preserves the hidden fields + * if they weren't set on {@code other} + * @hide + */ + public void copyFromPreserveHiddenFields(TaskDescription other) { + mLabel = other.mLabel; + mIcon = other.mIcon; + mIconFilename = other.mIconFilename; + mColorPrimary = other.mColorPrimary; + if (other.mColorBackground != 0) { + mColorBackground = other.mColorBackground; + } + if (other.mStatusBarColor != 0) { + mStatusBarColor = other.mStatusBarColor; + } + if (other.mNavigationBarColor != 0) { + mNavigationBarColor = other.mNavigationBarColor; + } + } + private TaskDescription(Parcel source) { readFromParcel(source); }