summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/Activity.java8
-rw-r--r--core/java/android/app/ActivityManager.java26
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java5
3 files changed, 38 insertions, 1 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index bb335fae887b..434c2721c4f0 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -972,6 +972,7 @@ public class Activity extends ContextThemeWrapper
private final ActivityManager.TaskDescription mTaskDescription =
new ActivityManager.TaskDescription();
+ private int mLastTaskDescriptionHashCode;
protected static final int[] FOCUSED_STATE_SET = {com.android.internal.R.attr.state_focused};
@@ -7613,6 +7614,13 @@ public class Activity extends ContextThemeWrapper
mTaskDescription.setIcon(Icon.createWithBitmap(icon));
}
}
+ if (mLastTaskDescriptionHashCode == mTaskDescription.hashCode()) {
+ // Early return if the hashCode is the same.
+ // Note that we do not use #equals() to perform the check because there are several
+ // places in this class that directly sets the value to mTaskDescription.
+ return;
+ }
+ mLastTaskDescriptionHashCode = mTaskDescription.hashCode();
ActivityClient.getInstance().setTaskDescription(mToken, mTaskDescription);
}
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 854e12177fb5..6b7f4880e2f0 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -2309,6 +2309,32 @@ public class ActivityManager {
}
@Override
+ public int hashCode() {
+ int result = 17;
+ if (mLabel != null) {
+ result = result * 31 + mLabel.hashCode();
+ }
+ if (mIcon != null) {
+ result = result * 31 + mIcon.hashCode();
+ }
+ if (mIconFilename != null) {
+ result = result * 31 + mIconFilename.hashCode();
+ }
+ result = result * 31 + mColorPrimary;
+ result = result * 31 + mColorBackground;
+ result = result * 31 + mColorBackgroundFloating;
+ result = result * 31 + mStatusBarColor;
+ result = result * 31 + mNavigationBarColor;
+ result = result * 31 + mStatusBarAppearance;
+ result = result * 31 + (mEnsureStatusBarContrastWhenTransparent ? 1 : 0);
+ result = result * 31 + (mEnsureNavigationBarContrastWhenTransparent ? 1 : 0);
+ result = result * 31 + mResizeMode;
+ result = result * 31 + mMinWidth;
+ result = result * 31 + mMinHeight;
+ return result;
+ }
+
+ @Override
public boolean equals(@Nullable Object obj) {
if (!(obj instanceof TaskDescription)) {
return false;
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
index 267bec9cccd2..c876663dd749 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskStackChangedListenerTest.java
@@ -40,6 +40,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.graphics.Color;
import android.graphics.PixelFormat;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
@@ -167,7 +168,7 @@ public class TaskStackChangedListenerTest {
@Presubmit
public void testTaskDescriptionChanged() throws Exception {
final Object[] params = new Object[2];
- final CountDownLatch latch = new CountDownLatch(1);
+ final CountDownLatch latch = new CountDownLatch(2);
registerTaskStackChangedListener(new TaskStackListener() {
int mTaskId = -1;
@@ -510,6 +511,8 @@ public class TaskStackChangedListenerTest {
protected void onPostResume() {
super.onPostResume();
setTaskDescription(new TaskDescription("Test Label"));
+ // Sets the color of the status-bar should update the TaskDescription again.
+ getWindow().setStatusBarColor(Color.RED);
synchronized (sLock) {
// Hold the lock to ensure no one is trying to access fields of this Activity in
// this test.