diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java
index b1d618eff40a6..b296d6f6a052f 100644
--- a/core/java/android/view/animation/Animation.java
+++ b/core/java/android/view/animation/Animation.java
@@ -19,6 +19,7 @@ package android.view.animation;
import android.annotation.AnimRes;
import android.annotation.ColorInt;
import android.annotation.InterpolatorRes;
+import android.app.ActivityThread;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.TypedArray;
@@ -258,8 +259,6 @@ public abstract class Animation implements Cloneable {
setZAdjustment(a.getInt(com.android.internal.R.styleable.Animation_zAdjustment, ZORDER_NORMAL));
- setBackgroundColor(a.getInt(com.android.internal.R.styleable.Animation_background, 0));
-
setDetachWallpaper(
a.getBoolean(com.android.internal.R.styleable.Animation_detachWallpaper, false));
setShowWallpaper(
@@ -271,6 +270,15 @@ public abstract class Animation implements Cloneable {
a.recycle();
+ Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext();
+ TypedArray uiStyledAttrs = uiContext
+ .obtainStyledAttributes(attrs, com.android.internal.R.styleable.Animation);
+
+ setBackgroundColor(
+ uiStyledAttrs.getColor(com.android.internal.R.styleable.Animation_background, 0));
+
+ uiStyledAttrs.recycle();
+
if (resID > 0) {
setInterpolator(context, resID);
}
@@ -632,16 +640,15 @@ public abstract class Animation implements Cloneable {
}
/**
- * Set background behind animation.
+ * Set background behind an animation.
*
- * @param bg The background color. If 0, no background. Currently must
- * be black, with any desired alpha level.
+ * @param bg The background color. If 0, no background.
*
* @deprecated None of window animations are running with background color.
*/
@Deprecated
public void setBackgroundColor(@ColorInt int bg) {
- // The background color is not needed any more, do nothing.
+ mBackgroundColor = bg;
}
/**
@@ -803,7 +810,7 @@ public abstract class Animation implements Cloneable {
@Deprecated
@ColorInt
public int getBackgroundColor() {
- return 0;
+ return mBackgroundColor;
}
/**
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index a5f505176d5d1..e26984a0d9921 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -6822,9 +6822,8 @@
content for the duration of the animation. -->
-
+
@@ -7737,7 +7736,7 @@
diff --git a/services/core/java/com/android/server/wm/AnimationAdapter.java b/services/core/java/com/android/server/wm/AnimationAdapter.java
index 529c4f6087433..486328a758dab 100644
--- a/services/core/java/com/android/server/wm/AnimationAdapter.java
+++ b/services/core/java/com/android/server/wm/AnimationAdapter.java
@@ -16,6 +16,7 @@
package com.android.server.wm;
+import android.annotation.ColorInt;
import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
@@ -106,4 +107,14 @@ interface AnimationAdapter {
default boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) {
return false;
}
+
+ /**
+ * Gets the background color to show behind an animation.
+ *
+ * @return The background color to show behind an animation (0 for no background color).
+ */
+ @ColorInt
+ default int getBackgroundColor() {
+ return 0;
+ }
}
diff --git a/services/core/java/com/android/server/wm/LocalAnimationAdapter.java b/services/core/java/com/android/server/wm/LocalAnimationAdapter.java
index 520bd8b2108e2..8f161bf6ecc40 100644
--- a/services/core/java/com/android/server/wm/LocalAnimationAdapter.java
+++ b/services/core/java/com/android/server/wm/LocalAnimationAdapter.java
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static com.android.server.wm.AnimationAdapterProto.LOCAL;
import static com.android.server.wm.LocalAnimationAdapterProto.ANIMATION_SPEC;
+import android.annotation.ColorInt;
import android.os.SystemClock;
import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
@@ -71,6 +72,12 @@ class LocalAnimationAdapter implements AnimationAdapter {
return mSpec.calculateStatusBarTransitionStartTime();
}
+ @Override
+ @ColorInt
+ public int getBackgroundColor() {
+ return mSpec.getBackgroundColor();
+ }
+
@Override
public void dump(PrintWriter pw, String prefix) {
mSpec.dump(pw, prefix);
@@ -149,5 +156,9 @@ class LocalAnimationAdapter implements AnimationAdapter {
}
void dumpDebugInner(ProtoOutputStream proto);
+
+ default int getBackgroundColor() {
+ return 0;
+ }
}
}
diff --git a/services/core/java/com/android/server/wm/WindowAnimationSpec.java b/services/core/java/com/android/server/wm/WindowAnimationSpec.java
index ec4eb5dc85de3..70822eebba82a 100644
--- a/services/core/java/com/android/server/wm/WindowAnimationSpec.java
+++ b/services/core/java/com/android/server/wm/WindowAnimationSpec.java
@@ -21,6 +21,7 @@ import static com.android.server.wm.AnimationSpecProto.WINDOW;
import static com.android.server.wm.WindowAnimationSpecProto.ANIMATION;
import static com.android.server.wm.WindowStateAnimator.ROOT_TASK_CLIP_NONE;
+import android.annotation.ColorInt;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.SystemClock;
@@ -84,6 +85,12 @@ public class WindowAnimationSpec implements AnimationSpec {
return mAnimation.computeDurationHint();
}
+ @Override
+ @ColorInt
+ public int getBackgroundColor() {
+ return mAnimation.getBackgroundColor();
+ }
+
@Override
public void apply(Transaction t, SurfaceControl leash, long currentPlayTime) {
final TmpValues tmp = mThreadLocalTmps.get();