Backport showBackground animation API support
Support was only added to shell, adding support in the the legacy transition system Test: atest CtsWindowManagerDeviceTestCases:AnimationBackgroundTests Bug: 218686362 Change-Id: I91cd4d22b7058374a7cc96264797d64597f43e84
This commit is contained in:
@@ -1088,7 +1088,7 @@ class ActivityClientController extends IActivityClientController.Stub {
|
||||
final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
|
||||
if (r != null && r.isState(RESUMED, PAUSING)) {
|
||||
r.mDisplayContent.mAppTransition.overridePendingAppTransition(
|
||||
packageName, enterAnim, exitAnim, null, null,
|
||||
packageName, enterAnim, exitAnim, backgroundColor, null, null,
|
||||
r.mOverrideTaskTransition);
|
||||
r.mTransitionController.setOverrideAnimation(
|
||||
TransitionInfo.AnimationOptions.makeCustomAnimOptions(packageName,
|
||||
|
||||
@@ -4485,6 +4485,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
pendingOptions.getPackageName(),
|
||||
pendingOptions.getCustomEnterResId(),
|
||||
pendingOptions.getCustomExitResId(),
|
||||
pendingOptions.getCustomBackgroundColor(),
|
||||
pendingOptions.getAnimationStartedListener(),
|
||||
pendingOptions.getAnimationFinishedListener(),
|
||||
pendingOptions.getOverrideTaskTransition());
|
||||
|
||||
@@ -41,6 +41,22 @@ interface AnimationAdapter {
|
||||
*/
|
||||
boolean getShowWallpaper();
|
||||
|
||||
/**
|
||||
* @return Whether we should show a background behind the animating windows.
|
||||
* @see Animation#getShowBackground()
|
||||
*/
|
||||
default boolean getShowBackground() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The background color to use during an animation if getShowBackground returns true.
|
||||
* @see Animation#getBackgroundColor()
|
||||
*/
|
||||
default int getBackgroundColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests to start the animation.
|
||||
*
|
||||
|
||||
@@ -93,6 +93,7 @@ import static com.android.server.wm.WindowManagerInternal.KeyguardExitAnimationS
|
||||
import static com.android.server.wm.WindowStateAnimator.ROOT_TASK_CLIP_AFTER_ANIM;
|
||||
import static com.android.server.wm.WindowStateAnimator.ROOT_TASK_CLIP_NONE;
|
||||
|
||||
import android.annotation.ColorInt;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.ComponentName;
|
||||
@@ -198,6 +199,7 @@ public class AppTransition implements Dump {
|
||||
private IRemoteCallback mAnimationFinishedCallback;
|
||||
private int mNextAppTransitionEnter;
|
||||
private int mNextAppTransitionExit;
|
||||
private @ColorInt int mNextAppTransitionBackgroundColor;
|
||||
private int mNextAppTransitionInPlace;
|
||||
private boolean mNextAppTransitionIsSync;
|
||||
|
||||
@@ -829,6 +831,7 @@ public class AppTransition implements Dump {
|
||||
break;
|
||||
}
|
||||
a = animAttr != 0 ? loadAnimationAttr(lp, animAttr, transit) : null;
|
||||
|
||||
ProtoLog.v(WM_DEBUG_APP_TRANSITIONS_ANIM,
|
||||
"applyAnimation: anim=%s animAttr=0x%x transit=%s isEntrance=%b "
|
||||
+ "Callers=%s",
|
||||
@@ -836,6 +839,11 @@ public class AppTransition implements Dump {
|
||||
Debug.getCallers(3));
|
||||
}
|
||||
setAppTransitionFinishedCallbackIfNeeded(a);
|
||||
|
||||
if (mNextAppTransitionBackgroundColor != 0) {
|
||||
a.setBackgroundColor(mNextAppTransitionBackgroundColor);
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -861,14 +869,15 @@ public class AppTransition implements Dump {
|
||||
}
|
||||
|
||||
void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
|
||||
IRemoteCallback startedCallback, IRemoteCallback endedCallback,
|
||||
boolean overrideTaskTransaction) {
|
||||
@ColorInt int backgroundColor, IRemoteCallback startedCallback,
|
||||
IRemoteCallback endedCallback, boolean overrideTaskTransaction) {
|
||||
if (canOverridePendingAppTransition()) {
|
||||
clear();
|
||||
mNextAppTransitionOverrideRequested = true;
|
||||
mNextAppTransitionPackage = packageName;
|
||||
mNextAppTransitionEnter = enterAnim;
|
||||
mNextAppTransitionExit = exitAnim;
|
||||
mNextAppTransitionBackgroundColor = backgroundColor;
|
||||
postAnimationCallback();
|
||||
mNextAppTransitionCallback = startedCallback;
|
||||
mAnimationFinishedCallback = endedCallback;
|
||||
|
||||
@@ -50,6 +50,16 @@ class LocalAnimationAdapter implements AnimationAdapter {
|
||||
return mSpec.getShowWallpaper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShowBackground() {
|
||||
return mSpec.getShowBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBackgroundColor() {
|
||||
return mSpec.getBackgroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAnimation(SurfaceControl animationLeash, Transaction t,
|
||||
@AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback) {
|
||||
@@ -96,6 +106,20 @@ class LocalAnimationAdapter implements AnimationAdapter {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AnimationAdapter#getShowBackground
|
||||
*/
|
||||
default boolean getShowBackground() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AnimationAdapter#getBackgroundColor
|
||||
*/
|
||||
default int getBackgroundColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AnimationAdapter#getStatusBarTransitionsStartTime
|
||||
*/
|
||||
|
||||
@@ -79,6 +79,16 @@ public class WindowAnimationSpec implements AnimationSpec {
|
||||
return mAnimation.getShowWallpaper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShowBackground() {
|
||||
return mAnimation.getShowBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBackgroundColor() {
|
||||
return mAnimation.getBackgroundColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDuration() {
|
||||
return mAnimation.computeDurationHint();
|
||||
|
||||
@@ -39,6 +39,7 @@ import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
|
||||
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_SYNC_ENGINE;
|
||||
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
|
||||
import static com.android.server.wm.AppTransition.MAX_APP_TRANSITION_DURATION;
|
||||
import static com.android.server.wm.AppTransition.isActivityTransitOld;
|
||||
import static com.android.server.wm.AppTransition.isTaskTransitOld;
|
||||
import static com.android.server.wm.DisplayContent.IME_TARGET_LAYERING;
|
||||
import static com.android.server.wm.IdentifierProto.HASH_CODE;
|
||||
@@ -81,7 +82,6 @@ import android.util.Pools;
|
||||
import android.util.Slog;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
import android.view.DisplayInfo;
|
||||
import android.view.InsetsState;
|
||||
import android.view.MagnificationSpec;
|
||||
import android.view.RemoteAnimationDefinition;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
@@ -98,6 +98,7 @@ import android.window.WindowContainerToken;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.graphics.ColorUtils;
|
||||
import com.android.internal.protolog.common.ProtoLog;
|
||||
import com.android.internal.util.ToBooleanFunction;
|
||||
import com.android.server.wm.SurfaceAnimator.Animatable;
|
||||
@@ -2816,6 +2817,25 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
||||
}
|
||||
}
|
||||
|
||||
final ActivityRecord activityRecord = asActivityRecord();
|
||||
if (activityRecord != null && isActivityTransitOld(transit)
|
||||
&& adapter.getShowBackground()) {
|
||||
final @ColorInt int backgroundColorForTransition;
|
||||
if (adapter.getBackgroundColor() != 0) {
|
||||
// If available use the background color provided through getBackgroundColor
|
||||
// which if set originates from a call to overridePendingAppTransition.
|
||||
backgroundColorForTransition = adapter.getBackgroundColor();
|
||||
} else {
|
||||
// Otherwise default to the window's background color if provided through
|
||||
// the theme as the background color for the animation - the top most window
|
||||
// with a valid background color and showBackground set takes precedence.
|
||||
final Task arTask = activityRecord.getTask();
|
||||
backgroundColorForTransition = ColorUtils.setAlphaComponent(
|
||||
arTask.getTaskDescription().getBackgroundColor(), 255);
|
||||
}
|
||||
animationRunnerBuilder.setTaskBackgroundColor(backgroundColorForTransition);
|
||||
}
|
||||
|
||||
animationRunnerBuilder.build()
|
||||
.startAnimation(getPendingTransaction(), adapter, !isVisible(),
|
||||
ANIMATION_TYPE_APP_TRANSITION, thumbnailAdapter);
|
||||
|
||||
Reference in New Issue
Block a user