Merge "Make AppTransition animations sharable (3/n)" into sc-dev
This commit is contained in:
@@ -77,8 +77,11 @@ public final class TransitionInfo implements Parcelable {
|
||||
/** The container is the recipient of a transferred starting-window */
|
||||
public static final int FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT = 1 << 3;
|
||||
|
||||
/** The container has voice session. */
|
||||
public static final int FLAG_IS_VOICE_INTERACTION = 1 << 4;
|
||||
|
||||
/** The first unused bit. This can be used by remotes to attach custom flags to this change. */
|
||||
public static final int FLAG_FIRST_CUSTOM = 1 << 4;
|
||||
public static final int FLAG_FIRST_CUSTOM = 1 << 5;
|
||||
|
||||
/** @hide */
|
||||
@IntDef(prefix = { "FLAG_" }, value = {
|
||||
@@ -86,7 +89,9 @@ public final class TransitionInfo implements Parcelable {
|
||||
FLAG_SHOW_WALLPAPER,
|
||||
FLAG_IS_WALLPAPER,
|
||||
FLAG_TRANSLUCENT,
|
||||
FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT
|
||||
FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT,
|
||||
FLAG_IS_VOICE_INTERACTION,
|
||||
FLAG_FIRST_CUSTOM
|
||||
})
|
||||
public @interface ChangeFlags {}
|
||||
|
||||
@@ -249,6 +254,12 @@ public final class TransitionInfo implements Parcelable {
|
||||
if ((flags & FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "STARTING_WINDOW_TRANSFER");
|
||||
}
|
||||
if ((flags & FLAG_IS_VOICE_INTERACTION) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "IS_VOICE_INTERACTION");
|
||||
}
|
||||
if ((flags & FLAG_FIRST_CUSTOM) != 0) {
|
||||
sb.append((sb.length() == 0 ? "" : "|") + "FIRST_CUSTOM");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE
|
||||
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE;
|
||||
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
|
||||
import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN;
|
||||
import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER;
|
||||
import static android.view.WindowManager.TRANSIT_OLD_TRANSLUCENT_ACTIVITY_CLOSE;
|
||||
import static android.view.WindowManager.TRANSIT_OLD_TRANSLUCENT_ACTIVITY_OPEN;
|
||||
import static android.view.WindowManager.TRANSIT_OLD_WALLPAPER_INTRA_CLOSE;
|
||||
@@ -76,6 +75,8 @@ public class TransitionAnimation {
|
||||
/** Fraction of animation at which the recents thumbnail becomes completely transparent */
|
||||
private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.5f;
|
||||
|
||||
private static final String DEFAULT_PACKAGE = "android";
|
||||
|
||||
private final Context mContext;
|
||||
private final String mTag;
|
||||
|
||||
@@ -132,7 +133,8 @@ public class TransitionAnimation {
|
||||
windowStyle.recycle();
|
||||
}
|
||||
|
||||
public Animation loadKeyguardExitAnimation(int transit, int transitionFlags) {
|
||||
/** Loads keyguard animation by transition flags and check it is on wallpaper or not. */
|
||||
public Animation loadKeyguardExitAnimation(int transitionFlags, boolean onWallpaper) {
|
||||
if ((transitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) != 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -140,25 +142,24 @@ public class TransitionAnimation {
|
||||
(transitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE) != 0;
|
||||
final boolean subtle =
|
||||
(transitionFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION) != 0;
|
||||
return createHiddenByKeyguardExit(mContext, mInterpolator,
|
||||
transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER, toShade, subtle);
|
||||
return createHiddenByKeyguardExit(mContext, mInterpolator, onWallpaper, toShade, subtle);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Animation loadKeyguardUnoccludeAnimation(LayoutParams lp) {
|
||||
return loadAnimationRes(lp, com.android.internal.R.anim.wallpaper_open_exit);
|
||||
public Animation loadKeyguardUnoccludeAnimation() {
|
||||
return loadDefaultAnimationRes(com.android.internal.R.anim.wallpaper_open_exit);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Animation loadVoiceActivityOpenAnimation(LayoutParams lp, boolean enter) {
|
||||
return loadAnimationRes(lp, enter
|
||||
public Animation loadVoiceActivityOpenAnimation(boolean enter) {
|
||||
return loadDefaultAnimationRes(enter
|
||||
? com.android.internal.R.anim.voice_activity_open_enter
|
||||
: com.android.internal.R.anim.voice_activity_open_exit);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Animation loadVoiceActivityExitAnimation(LayoutParams lp, boolean enter) {
|
||||
return loadAnimationRes(lp, enter
|
||||
public Animation loadVoiceActivityExitAnimation(boolean enter) {
|
||||
return loadDefaultAnimationRes(enter
|
||||
? com.android.internal.R.anim.voice_activity_close_enter
|
||||
: com.android.internal.R.anim.voice_activity_close_exit);
|
||||
}
|
||||
@@ -170,33 +171,19 @@ public class TransitionAnimation {
|
||||
|
||||
@Nullable
|
||||
public Animation loadCrossProfileAppEnterAnimation() {
|
||||
return loadAnimationRes("android",
|
||||
return loadAnimationRes(DEFAULT_PACKAGE,
|
||||
com.android.internal.R.anim.task_open_enter_cross_profile_apps);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Animation loadCrossProfileAppThumbnailEnterAnimation() {
|
||||
return loadAnimationRes(
|
||||
"android", com.android.internal.R.anim.cross_profile_apps_thumbnail_enter);
|
||||
}
|
||||
|
||||
/** Load animation by resource Id from specific LayoutParams. */
|
||||
@Nullable
|
||||
private Animation loadAnimationRes(LayoutParams lp, int resId) {
|
||||
Context context = mContext;
|
||||
if (ResourceId.isValid(resId)) {
|
||||
AttributeCache.Entry ent = getCachedAnimations(lp);
|
||||
if (ent != null) {
|
||||
context = ent.context;
|
||||
}
|
||||
return loadAnimationSafely(context, resId, mTag);
|
||||
}
|
||||
return null;
|
||||
DEFAULT_PACKAGE, com.android.internal.R.anim.cross_profile_apps_thumbnail_enter);
|
||||
}
|
||||
|
||||
/** Load animation by resource Id from specific package. */
|
||||
@Nullable
|
||||
private Animation loadAnimationRes(String packageName, int resId) {
|
||||
public Animation loadAnimationRes(String packageName, int resId) {
|
||||
if (ResourceId.isValid(resId)) {
|
||||
AttributeCache.Entry ent = getCachedAnimations(packageName, resId);
|
||||
if (ent != null) {
|
||||
@@ -209,7 +196,7 @@ public class TransitionAnimation {
|
||||
/** Load animation by resource Id from android package. */
|
||||
@Nullable
|
||||
public Animation loadDefaultAnimationRes(int resId) {
|
||||
return loadAnimationRes("android", resId);
|
||||
return loadAnimationRes(DEFAULT_PACKAGE, resId);
|
||||
}
|
||||
|
||||
/** Load animation by attribute Id from specific LayoutParams */
|
||||
@@ -237,7 +224,7 @@ public class TransitionAnimation {
|
||||
int resId = Resources.ID_NULL;
|
||||
Context context = mContext;
|
||||
if (animAttr >= 0) {
|
||||
AttributeCache.Entry ent = getCachedAnimations("android",
|
||||
AttributeCache.Entry ent = getCachedAnimations(DEFAULT_PACKAGE,
|
||||
mDefaultWindowAnimationStyleResId);
|
||||
if (ent != null) {
|
||||
context = ent.context;
|
||||
@@ -261,10 +248,10 @@ public class TransitionAnimation {
|
||||
// If this is a system resource, don't try to load it from the
|
||||
// application resources. It is nice to avoid loading application
|
||||
// resources if we can.
|
||||
String packageName = lp.packageName != null ? lp.packageName : "android";
|
||||
String packageName = lp.packageName != null ? lp.packageName : DEFAULT_PACKAGE;
|
||||
int resId = getAnimationStyleResId(lp);
|
||||
if ((resId & 0xFF000000) == 0x01000000) {
|
||||
packageName = "android";
|
||||
packageName = DEFAULT_PACKAGE;
|
||||
}
|
||||
if (mDebug) {
|
||||
Slog.v(mTag, "Loading animations: picked package=" + packageName);
|
||||
@@ -283,7 +270,7 @@ public class TransitionAnimation {
|
||||
}
|
||||
if (packageName != null) {
|
||||
if ((resId & 0xFF000000) == 0x01000000) {
|
||||
packageName = "android";
|
||||
packageName = DEFAULT_PACKAGE;
|
||||
}
|
||||
if (mDebug) {
|
||||
Slog.v(mTag, "Loading animations: picked package="
|
||||
|
||||
@@ -18,9 +18,14 @@ package com.android.wm.shell.transition;
|
||||
|
||||
import static android.view.WindowManager.TRANSIT_CHANGE;
|
||||
import static android.view.WindowManager.TRANSIT_CLOSE;
|
||||
import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
|
||||
import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE;
|
||||
import static android.view.WindowManager.TRANSIT_OPEN;
|
||||
import static android.view.WindowManager.TRANSIT_RELAUNCH;
|
||||
import static android.view.WindowManager.TRANSIT_TO_BACK;
|
||||
import static android.view.WindowManager.TRANSIT_TO_FRONT;
|
||||
import static android.window.TransitionInfo.FLAG_IS_VOICE_INTERACTION;
|
||||
import static android.window.TransitionInfo.FLAG_SHOW_WALLPAPER;
|
||||
import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;
|
||||
import static android.window.TransitionInfo.FLAG_TRANSLUCENT;
|
||||
|
||||
@@ -64,6 +69,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
|
||||
/** Keeps track of the currently-running animations associated with each transition. */
|
||||
private final ArrayMap<IBinder, ArrayList<Animator>> mAnimations = new ArrayMap<>();
|
||||
|
||||
private final Rect mInsets = new Rect(0, 0, 0, 0);
|
||||
private float mTransitionAnimationScaleSetting = 1.0f;
|
||||
|
||||
DefaultTransitionHandler(@NonNull TransactionPool transactionPool, Context context,
|
||||
@@ -111,7 +117,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
|
||||
// Don't animate anything that isn't independent.
|
||||
if (!TransitionInfo.isIndependent(change, info)) continue;
|
||||
|
||||
Animation a = loadAnimation(info.getType(), change);
|
||||
Animation a = loadAnimation(info.getType(), info.getFlags(), change);
|
||||
if (a != null) {
|
||||
startAnimInternal(animations, a, change.getLeash(), onAnimFinish);
|
||||
}
|
||||
@@ -135,47 +141,69 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Animation loadAnimation(int type, TransitionInfo.Change change) {
|
||||
private Animation loadAnimation(int type, int flags, TransitionInfo.Change change) {
|
||||
// TODO(b/178678389): It should handle more type animation here
|
||||
Animation a = null;
|
||||
|
||||
final boolean isOpening = Transitions.isOpeningType(type);
|
||||
final int mode = change.getMode();
|
||||
final int flags = change.getFlags();
|
||||
final int changeMode = change.getMode();
|
||||
final int changeFlags = change.getFlags();
|
||||
|
||||
if (mode == TRANSIT_OPEN && isOpening) {
|
||||
if ((flags & FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT) != 0) {
|
||||
if (type == TRANSIT_RELAUNCH) {
|
||||
a = mTransitionAnimation.createRelaunchAnimation(
|
||||
change.getStartAbsBounds(), mInsets, change.getEndAbsBounds());
|
||||
} else if (type == TRANSIT_KEYGUARD_GOING_AWAY) {
|
||||
a = mTransitionAnimation.loadKeyguardExitAnimation(flags,
|
||||
(changeFlags & FLAG_SHOW_WALLPAPER) != 0);
|
||||
} else if (type == TRANSIT_KEYGUARD_UNOCCLUDE) {
|
||||
a = mTransitionAnimation.loadKeyguardUnoccludeAnimation();
|
||||
} else if (changeMode == TRANSIT_OPEN && isOpening) {
|
||||
if ((changeFlags & FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT) != 0) {
|
||||
// This received a transferred starting window, so don't animate
|
||||
return null;
|
||||
}
|
||||
|
||||
if (change.getTaskInfo() != null) {
|
||||
if ((changeFlags & FLAG_IS_VOICE_INTERACTION) != 0) {
|
||||
a = mTransitionAnimation.loadVoiceActivityOpenAnimation(true /** enter */);
|
||||
} else if (change.getTaskInfo() != null) {
|
||||
a = mTransitionAnimation.loadDefaultAnimationAttr(
|
||||
R.styleable.WindowAnimation_taskOpenEnterAnimation);
|
||||
} else {
|
||||
a = mTransitionAnimation.loadDefaultAnimationRes((flags & FLAG_TRANSLUCENT) == 0
|
||||
a = mTransitionAnimation.loadDefaultAnimationRes(
|
||||
(changeFlags & FLAG_TRANSLUCENT) == 0
|
||||
? R.anim.activity_open_enter : R.anim.activity_translucent_open_enter);
|
||||
}
|
||||
} else if (mode == TRANSIT_TO_FRONT && isOpening) {
|
||||
if ((flags & FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT) != 0) {
|
||||
} else if (changeMode == TRANSIT_TO_FRONT && isOpening) {
|
||||
if ((changeFlags & FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT) != 0) {
|
||||
// This received a transferred starting window, so don't animate
|
||||
return null;
|
||||
}
|
||||
|
||||
a = mTransitionAnimation.loadDefaultAnimationAttr(
|
||||
R.styleable.WindowAnimation_taskToFrontEnterAnimation);
|
||||
} else if (mode == TRANSIT_CLOSE && !isOpening) {
|
||||
if (change.getTaskInfo() != null) {
|
||||
if ((changeFlags & FLAG_IS_VOICE_INTERACTION) != 0) {
|
||||
a = mTransitionAnimation.loadVoiceActivityOpenAnimation(true /** enter */);
|
||||
} else {
|
||||
a = mTransitionAnimation.loadDefaultAnimationAttr(
|
||||
R.styleable.WindowAnimation_taskToFrontEnterAnimation);
|
||||
}
|
||||
} else if (changeMode == TRANSIT_CLOSE && !isOpening) {
|
||||
if ((changeFlags & FLAG_IS_VOICE_INTERACTION) != 0) {
|
||||
a = mTransitionAnimation.loadVoiceActivityExitAnimation(false /** enter */);
|
||||
} else if (change.getTaskInfo() != null) {
|
||||
a = mTransitionAnimation.loadDefaultAnimationAttr(
|
||||
R.styleable.WindowAnimation_taskCloseExitAnimation);
|
||||
} else {
|
||||
a = mTransitionAnimation.loadDefaultAnimationRes((flags & FLAG_TRANSLUCENT) == 0
|
||||
a = mTransitionAnimation.loadDefaultAnimationRes(
|
||||
(changeFlags & FLAG_TRANSLUCENT) == 0
|
||||
? R.anim.activity_close_exit : R.anim.activity_translucent_close_exit);
|
||||
}
|
||||
} else if (mode == TRANSIT_TO_BACK && !isOpening) {
|
||||
a = mTransitionAnimation.loadDefaultAnimationAttr(
|
||||
R.styleable.WindowAnimation_taskToBackExitAnimation);
|
||||
} else if (mode == TRANSIT_CHANGE) {
|
||||
} else if (changeMode == TRANSIT_TO_BACK && !isOpening) {
|
||||
if ((changeFlags & FLAG_IS_VOICE_INTERACTION) != 0) {
|
||||
a = mTransitionAnimation.loadVoiceActivityExitAnimation(false /** enter */);
|
||||
} else {
|
||||
a = mTransitionAnimation.loadDefaultAnimationAttr(
|
||||
R.styleable.WindowAnimation_taskToBackExitAnimation);
|
||||
}
|
||||
} else if (changeMode == TRANSIT_CHANGE) {
|
||||
// In the absence of a specific adapter, we just want to keep everything stationary.
|
||||
a = new AlphaAnimation(1.f, 1.f);
|
||||
a.setDuration(TransitionAnimation.DEFAULT_APP_TRANSITION_DURATION);
|
||||
|
||||
@@ -986,24 +986,25 @@ public class AppTransition implements Dump {
|
||||
|
||||
Animation a;
|
||||
if (isKeyguardGoingAwayTransitOld(transit) && enter) {
|
||||
a = mTransitionAnimation.loadKeyguardExitAnimation(transit, mNextAppTransitionFlags);
|
||||
a = mTransitionAnimation.loadKeyguardExitAnimation(mNextAppTransitionFlags,
|
||||
transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER);
|
||||
} else if (transit == TRANSIT_OLD_KEYGUARD_OCCLUDE) {
|
||||
a = null;
|
||||
} else if (transit == TRANSIT_OLD_KEYGUARD_UNOCCLUDE && !enter) {
|
||||
a = mTransitionAnimation.loadKeyguardUnoccludeAnimation(lp);
|
||||
a = mTransitionAnimation.loadKeyguardUnoccludeAnimation();
|
||||
} else if (transit == TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE) {
|
||||
a = null;
|
||||
} else if (isVoiceInteraction && (transit == TRANSIT_OLD_ACTIVITY_OPEN
|
||||
|| transit == TRANSIT_OLD_TASK_OPEN
|
||||
|| transit == TRANSIT_OLD_TASK_TO_FRONT)) {
|
||||
a = mTransitionAnimation.loadVoiceActivityOpenAnimation(lp, enter);
|
||||
a = mTransitionAnimation.loadVoiceActivityOpenAnimation(enter);
|
||||
ProtoLog.v(WM_DEBUG_APP_TRANSITIONS_ANIM,
|
||||
"applyAnimation voice: anim=%s transit=%s isEntrance=%b Callers=%s", a,
|
||||
appTransitionOldToString(transit), enter, Debug.getCallers(3));
|
||||
} else if (isVoiceInteraction && (transit == TRANSIT_OLD_ACTIVITY_CLOSE
|
||||
|| transit == TRANSIT_OLD_TASK_CLOSE
|
||||
|| transit == TRANSIT_OLD_TASK_TO_BACK)) {
|
||||
a = mTransitionAnimation.loadVoiceActivityExitAnimation(lp, enter);
|
||||
a = mTransitionAnimation.loadVoiceActivityExitAnimation(enter);
|
||||
ProtoLog.v(WM_DEBUG_APP_TRANSITIONS_ANIM,
|
||||
"applyAnimation voice: anim=%s transit=%s isEntrance=%b Callers=%s", a,
|
||||
appTransitionOldToString(transit), enter, Debug.getCallers(3));
|
||||
|
||||
@@ -32,6 +32,7 @@ import static android.view.WindowManager.TRANSIT_OPEN;
|
||||
import static android.view.WindowManager.TRANSIT_TO_BACK;
|
||||
import static android.view.WindowManager.TRANSIT_TO_FRONT;
|
||||
import static android.view.WindowManager.transitTypeToString;
|
||||
import static android.window.TransitionInfo.FLAG_IS_VOICE_INTERACTION;
|
||||
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;
|
||||
import static android.window.TransitionInfo.FLAG_SHOW_WALLPAPER;
|
||||
import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;
|
||||
@@ -876,8 +877,18 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
|
||||
// checks to use requested visibility.
|
||||
flags |= FLAG_TRANSLUCENT;
|
||||
}
|
||||
if (wc.asActivityRecord() != null && wc.asActivityRecord().mUseTransferredAnimation) {
|
||||
flags |= FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;
|
||||
final Task task = wc.asTask();
|
||||
if (task != null && task.voiceSession != null) {
|
||||
flags |= FLAG_IS_VOICE_INTERACTION;
|
||||
}
|
||||
final ActivityRecord record = wc.asActivityRecord();
|
||||
if (record != null) {
|
||||
if (record.mUseTransferredAnimation) {
|
||||
flags |= FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;
|
||||
}
|
||||
if (record.mVoiceInteraction) {
|
||||
flags |= FLAG_IS_VOICE_INTERACTION;
|
||||
}
|
||||
}
|
||||
if (isWallpaper(wc)) {
|
||||
flags |= FLAG_IS_WALLPAPER;
|
||||
|
||||
Reference in New Issue
Block a user