summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pablo Gamito <pablogamito@google.com> 2021-09-28 04:57:52 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-09-28 04:57:52 +0000
commite1841dc5390e8b0bf1cc0e8d4350cfbcd2b74868 (patch)
treeaf830484ed6efd9e769f2af80a0bd0ebc4762534
parent16517d739ddd7b9cf4d9be9a916265f2795d62fb (diff)
parent66d4318c185fe759a9cda523c91eb298f513a076 (diff)
Merge changes Ibd9f22af,Id42f5276 into sc-qpr1-dev
* changes: Revert "Add API to specify background color for animations" Stop relying on background color attribute to set task transition background
-rw-r--r--core/java/android/view/animation/Animation.java21
-rw-r--r--core/res/res/values/attrs.xml7
-rw-r--r--services/core/java/com/android/server/wm/AnimationAdapter.java11
-rw-r--r--services/core/java/com/android/server/wm/LocalAnimationAdapter.java11
-rw-r--r--services/core/java/com/android/server/wm/WindowAnimationSpec.java7
-rw-r--r--services/core/java/com/android/server/wm/WindowContainer.java34
6 files changed, 35 insertions, 56 deletions
diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java
index b296d6f6a052..b1d618eff40a 100644
--- a/core/java/android/view/animation/Animation.java
+++ b/core/java/android/view/animation/Animation.java
@@ -19,7 +19,6 @@ 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;
@@ -259,6 +258,8 @@ 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(
@@ -270,15 +271,6 @@ 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);
}
@@ -640,15 +632,16 @@ public abstract class Animation implements Cloneable {
}
/**
- * Set background behind an animation.
+ * Set background behind animation.
*
- * @param bg The background color. If 0, no background.
+ * @param bg The background color. If 0, no background. Currently must
+ * be black, with any desired alpha level.
*
* @deprecated None of window animations are running with background color.
*/
@Deprecated
public void setBackgroundColor(@ColorInt int bg) {
- mBackgroundColor = bg;
+ // The background color is not needed any more, do nothing.
}
/**
@@ -810,7 +803,7 @@ public abstract class Animation implements Cloneable {
@Deprecated
@ColorInt
public int getBackgroundColor() {
- return mBackgroundColor;
+ return 0;
}
/**
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index e26984a0d992..a5f505176d5d 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -6822,8 +6822,9 @@
content for the duration of the animation. -->
<enum name="bottom" value="-1" />
</attr>
- <!-- Special background behind animation. Only for use with task animations.
- If 0, the default, there is no background. -->
+ <!-- Special background behind animation. Only for use with window
+ animations. Can only be a color, and only black. If 0, the
+ default, there is no background. -->
<attr name="background" />
<!-- Special option for window animations: if this window is on top
of a wallpaper, don't animate the wallpaper with it. -->
@@ -7736,7 +7737,7 @@
<!-- Name of a method on the Context used to inflate the menu that will be
called when the item is clicked.
- {@deprecated Menu actually traverses the Context hierarchy looking for the
+ {@deprecated Menu actually traverses the Context hierarchy looking for the
relevant method, which is fragile (an intermediate ContextWrapper adding a
same-named method would change behavior) and restricts bytecode optimizers
such as R8. Instead, use MenuItem.setOnMenuItemClickListener.} -->
diff --git a/services/core/java/com/android/server/wm/AnimationAdapter.java b/services/core/java/com/android/server/wm/AnimationAdapter.java
index 486328a758da..529c4f608743 100644
--- a/services/core/java/com/android/server/wm/AnimationAdapter.java
+++ b/services/core/java/com/android/server/wm/AnimationAdapter.java
@@ -16,7 +16,6 @@
package com.android.server.wm;
-import android.annotation.ColorInt;
import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
@@ -107,14 +106,4 @@ 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 8f161bf6ecc4..520bd8b2108e 100644
--- a/services/core/java/com/android/server/wm/LocalAnimationAdapter.java
+++ b/services/core/java/com/android/server/wm/LocalAnimationAdapter.java
@@ -19,7 +19,6 @@ 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;
@@ -73,12 +72,6 @@ class LocalAnimationAdapter implements AnimationAdapter {
}
@Override
- @ColorInt
- public int getBackgroundColor() {
- return mSpec.getBackgroundColor();
- }
-
- @Override
public void dump(PrintWriter pw, String prefix) {
mSpec.dump(pw, prefix);
}
@@ -156,9 +149,5 @@ 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 08758afcb0b2..073a508083f0 100644
--- a/services/core/java/com/android/server/wm/WindowAnimationSpec.java
+++ b/services/core/java/com/android/server/wm/WindowAnimationSpec.java
@@ -21,7 +21,6 @@ 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;
@@ -86,12 +85,6 @@ public class WindowAnimationSpec implements AnimationSpec {
}
@Override
- @ColorInt
- public int getBackgroundColor() {
- return mAnimation.getBackgroundColor();
- }
-
- @Override
public void apply(Transaction t, SurfaceControl leash, long currentPlayTime) {
final TmpValues tmp = mThreadLocalTmps.get();
tmp.transformation.clear();
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index d9a8883e299e..d99aed1b409a 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -30,6 +30,10 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.os.UserHandle.USER_NULL;
import static android.view.SurfaceControl.Transaction;
import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;
+import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
+import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
+import static android.view.WindowManager.TRANSIT_OLD_TASK_TO_BACK;
+import static android.view.WindowManager.TRANSIT_OLD_TASK_TO_FRONT;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
@@ -59,10 +63,13 @@ import static com.android.server.wm.WindowManagerService.logWithStack;
import static com.android.server.wm.WindowStateAnimator.ROOT_TASK_CLIP_AFTER_ANIM;
import android.annotation.CallSuper;
+import android.annotation.ColorInt;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.app.ActivityThread;
import android.app.WindowConfiguration;
+import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Point;
@@ -88,6 +95,7 @@ import android.view.animation.Animation;
import android.window.IWindowContainerToken;
import android.window.WindowContainerToken;
+import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ToBooleanFunction;
@@ -2732,24 +2740,23 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
}
TaskDisplayArea taskDisplayArea = getTaskDisplayArea();
- int backgroundColor = adapter.getBackgroundColor();
+ boolean isSettingBackgroundColor = taskDisplayArea != null
+ && isTransitionWithBackgroundColor(transit);
- boolean shouldSetBackgroundColor = taskDisplayArea != null && backgroundColor != 0;
+ if (isSettingBackgroundColor) {
+ Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext();
+ @ColorInt int backgroundColor = uiContext.getColor(R.color.overview_background);
- if (shouldSetBackgroundColor) {
taskDisplayArea.setBackgroundColor(backgroundColor);
}
- Runnable clearColorBackground = () -> {
- if (shouldSetBackgroundColor) {
- taskDisplayArea.clearBackgroundColor();
- }
- };
+ final Runnable cleanUpCallback = isSettingBackgroundColor
+ ? taskDisplayArea::clearBackgroundColor : () -> {};
startAnimation(getPendingTransaction(), adapter, !isVisible(),
ANIMATION_TYPE_APP_TRANSITION,
- (type, anim) -> clearColorBackground.run(),
- clearColorBackground);
+ (type, anim) -> cleanUpCallback.run(),
+ cleanUpCallback);
if (adapter.getShowWallpaper()) {
getDisplayContent().pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
@@ -2761,6 +2768,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
}
}
+ private boolean isTransitionWithBackgroundColor(@TransitionOldType int transit) {
+ return transit == TRANSIT_OLD_TASK_OPEN
+ || transit == TRANSIT_OLD_TASK_CLOSE
+ || transit == TRANSIT_OLD_TASK_TO_FRONT
+ || transit == TRANSIT_OLD_TASK_TO_BACK;
+ }
+
final SurfaceAnimationRunner getSurfaceAnimationRunner() {
return mWmService.mSurfaceAnimationRunner;
}