Merge "Add test APIs for makeCustomAnimation" into rvc-dev
This commit is contained in:
@@ -107,6 +107,7 @@ package android.app {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ActivityOptions {
|
public class ActivityOptions {
|
||||||
|
method @NonNull public static android.app.ActivityOptions makeCustomAnimation(@NonNull android.content.Context, int, int, @Nullable android.os.Handler, @Nullable android.app.ActivityOptions.OnAnimationStartedListener, @Nullable android.app.ActivityOptions.OnAnimationFinishedListener);
|
||||||
method public static void setExitTransitionTimeout(long);
|
method public static void setExitTransitionTimeout(long);
|
||||||
method public void setLaunchActivityType(int);
|
method public void setLaunchActivityType(int);
|
||||||
method public void setLaunchTaskId(int);
|
method public void setLaunchTaskId(int);
|
||||||
@@ -115,6 +116,14 @@ package android.app {
|
|||||||
method public void setTaskOverlay(boolean, boolean);
|
method public void setTaskOverlay(boolean, boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static interface ActivityOptions.OnAnimationFinishedListener {
|
||||||
|
method public void onAnimationFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static interface ActivityOptions.OnAnimationStartedListener {
|
||||||
|
method public void onAnimationStarted();
|
||||||
|
}
|
||||||
|
|
||||||
public class ActivityTaskManager {
|
public class ActivityTaskManager {
|
||||||
method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void clearLaunchParamsForPackages(java.util.List<java.lang.String>);
|
method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void clearLaunchParamsForPackages(java.util.List<java.lang.String>);
|
||||||
method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public String listAllStacks();
|
method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public String listAllStacks();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
|
|||||||
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
|
||||||
import static android.view.Display.INVALID_DISPLAY;
|
import static android.view.Display.INVALID_DISPLAY;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
import android.annotation.TestApi;
|
import android.annotation.TestApi;
|
||||||
@@ -379,7 +380,7 @@ public class ActivityOptions {
|
|||||||
*/
|
*/
|
||||||
public static ActivityOptions makeCustomAnimation(Context context,
|
public static ActivityOptions makeCustomAnimation(Context context,
|
||||||
int enterResId, int exitResId) {
|
int enterResId, int exitResId) {
|
||||||
return makeCustomAnimation(context, enterResId, exitResId, null, null);
|
return makeCustomAnimation(context, enterResId, exitResId, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -413,6 +414,38 @@ public class ActivityOptions {
|
|||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an ActivityOptions specifying a custom animation to run when
|
||||||
|
* the activity is displayed.
|
||||||
|
*
|
||||||
|
* @param context Who is defining this. This is the application that the
|
||||||
|
* animation resources will be loaded from.
|
||||||
|
* @param enterResId A resource ID of the animation resource to use for
|
||||||
|
* the incoming activity. Use 0 for no animation.
|
||||||
|
* @param exitResId A resource ID of the animation resource to use for
|
||||||
|
* the outgoing activity. Use 0 for no animation.
|
||||||
|
* @param handler If <var>listener</var> is non-null this must be a valid
|
||||||
|
* Handler on which to dispatch the callback; otherwise it should be null.
|
||||||
|
* @param startedListener Optional OnAnimationStartedListener to find out when the
|
||||||
|
* requested animation has started running. If for some reason the animation
|
||||||
|
* is not executed, the callback will happen immediately.
|
||||||
|
* @param finishedListener Optional OnAnimationFinishedListener when the animation
|
||||||
|
* has finished running.
|
||||||
|
* @return Returns a new ActivityOptions object that you can use to
|
||||||
|
* supply these options as the options Bundle when starting an activity.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@TestApi
|
||||||
|
public static @NonNull ActivityOptions makeCustomAnimation(@NonNull Context context,
|
||||||
|
int enterResId, int exitResId, @Nullable Handler handler,
|
||||||
|
@Nullable OnAnimationStartedListener startedListener,
|
||||||
|
@Nullable OnAnimationFinishedListener finishedListener) {
|
||||||
|
ActivityOptions opts = makeCustomAnimation(context, enterResId, exitResId, handler,
|
||||||
|
startedListener);
|
||||||
|
opts.setOnAnimationFinishedListener(handler, finishedListener);
|
||||||
|
return opts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an ActivityOptions specifying a custom animation to run in place on an existing
|
* Creates an ActivityOptions specifying a custom animation to run in place on an existing
|
||||||
* activity.
|
* activity.
|
||||||
@@ -458,6 +491,7 @@ public class ActivityOptions {
|
|||||||
* to find out when the given animation has started running.
|
* to find out when the given animation has started running.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@TestApi
|
||||||
public interface OnAnimationStartedListener {
|
public interface OnAnimationStartedListener {
|
||||||
void onAnimationStarted();
|
void onAnimationStarted();
|
||||||
}
|
}
|
||||||
@@ -484,6 +518,7 @@ public class ActivityOptions {
|
|||||||
* to find out when the given animation has drawn its last frame.
|
* to find out when the given animation has drawn its last frame.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@TestApi
|
||||||
public interface OnAnimationFinishedListener {
|
public interface OnAnimationFinishedListener {
|
||||||
void onAnimationFinished();
|
void onAnimationFinished();
|
||||||
}
|
}
|
||||||
@@ -1100,7 +1135,7 @@ public class ActivityOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public IRemoteCallback getOnAnimationStartListener() {
|
public IRemoteCallback getAnimationStartedListener() {
|
||||||
return mAnimationStartedListener;
|
return mAnimationStartedListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public abstract class ActivityOptionsCompat {
|
|||||||
callbackHandler.post(callback);
|
callbackHandler.post(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}, null /* finishedListener */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3769,7 +3769,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
pendingOptions.getPackageName(),
|
pendingOptions.getPackageName(),
|
||||||
pendingOptions.getCustomEnterResId(),
|
pendingOptions.getCustomEnterResId(),
|
||||||
pendingOptions.getCustomExitResId(),
|
pendingOptions.getCustomExitResId(),
|
||||||
pendingOptions.getOnAnimationStartListener());
|
pendingOptions.getAnimationStartedListener(),
|
||||||
|
pendingOptions.getAnimationFinishedListener());
|
||||||
break;
|
break;
|
||||||
case ANIM_CLIP_REVEAL:
|
case ANIM_CLIP_REVEAL:
|
||||||
displayContent.mAppTransition.overridePendingAppTransitionClipReveal(
|
displayContent.mAppTransition.overridePendingAppTransitionClipReveal(
|
||||||
@@ -3799,7 +3800,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
final GraphicBuffer buffer = pendingOptions.getThumbnail();
|
final GraphicBuffer buffer = pendingOptions.getThumbnail();
|
||||||
displayContent.mAppTransition.overridePendingAppTransitionThumb(buffer,
|
displayContent.mAppTransition.overridePendingAppTransitionThumb(buffer,
|
||||||
pendingOptions.getStartX(), pendingOptions.getStartY(),
|
pendingOptions.getStartX(), pendingOptions.getStartY(),
|
||||||
pendingOptions.getOnAnimationStartListener(),
|
pendingOptions.getAnimationStartedListener(),
|
||||||
scaleUp);
|
scaleUp);
|
||||||
if (intent.getSourceBounds() == null && buffer != null) {
|
if (intent.getSourceBounds() == null && buffer != null) {
|
||||||
intent.setSourceBounds(new Rect(pendingOptions.getStartX(),
|
intent.setSourceBounds(new Rect(pendingOptions.getStartX(),
|
||||||
@@ -3815,19 +3816,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
pendingOptions.getSpecsFuture();
|
pendingOptions.getSpecsFuture();
|
||||||
if (specsFuture != null) {
|
if (specsFuture != null) {
|
||||||
displayContent.mAppTransition.overridePendingAppTransitionMultiThumbFuture(
|
displayContent.mAppTransition.overridePendingAppTransitionMultiThumbFuture(
|
||||||
specsFuture, pendingOptions.getOnAnimationStartListener(),
|
specsFuture, pendingOptions.getAnimationStartedListener(),
|
||||||
animationType == ANIM_THUMBNAIL_ASPECT_SCALE_UP);
|
animationType == ANIM_THUMBNAIL_ASPECT_SCALE_UP);
|
||||||
} else if (animationType == ANIM_THUMBNAIL_ASPECT_SCALE_DOWN
|
} else if (animationType == ANIM_THUMBNAIL_ASPECT_SCALE_DOWN
|
||||||
&& specs != null) {
|
&& specs != null) {
|
||||||
displayContent.mAppTransition.overridePendingAppTransitionMultiThumb(
|
displayContent.mAppTransition.overridePendingAppTransitionMultiThumb(
|
||||||
specs, pendingOptions.getOnAnimationStartListener(),
|
specs, pendingOptions.getAnimationStartedListener(),
|
||||||
pendingOptions.getAnimationFinishedListener(), false);
|
pendingOptions.getAnimationFinishedListener(), false);
|
||||||
} else {
|
} else {
|
||||||
displayContent.mAppTransition.overridePendingAppTransitionAspectScaledThumb(
|
displayContent.mAppTransition.overridePendingAppTransitionAspectScaledThumb(
|
||||||
pendingOptions.getThumbnail(),
|
pendingOptions.getThumbnail(),
|
||||||
pendingOptions.getStartX(), pendingOptions.getStartY(),
|
pendingOptions.getStartX(), pendingOptions.getStartY(),
|
||||||
pendingOptions.getWidth(), pendingOptions.getHeight(),
|
pendingOptions.getWidth(), pendingOptions.getHeight(),
|
||||||
pendingOptions.getOnAnimationStartListener(),
|
pendingOptions.getAnimationStartedListener(),
|
||||||
(animationType == ANIM_THUMBNAIL_ASPECT_SCALE_UP));
|
(animationType == ANIM_THUMBNAIL_ASPECT_SCALE_UP));
|
||||||
if (intent.getSourceBounds() == null) {
|
if (intent.getSourceBounds() == null) {
|
||||||
intent.setSourceBounds(new Rect(pendingOptions.getStartX(),
|
intent.setSourceBounds(new Rect(pendingOptions.getStartX(),
|
||||||
|
|||||||
@@ -2003,7 +2003,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
if (self.isState(
|
if (self.isState(
|
||||||
ActivityStack.ActivityState.RESUMED, ActivityStack.ActivityState.PAUSING)) {
|
ActivityStack.ActivityState.RESUMED, ActivityStack.ActivityState.PAUSING)) {
|
||||||
self.getDisplay().mDisplayContent.mAppTransition.overridePendingAppTransition(
|
self.getDisplay().mDisplayContent.mAppTransition.overridePendingAppTransition(
|
||||||
packageName, enterAnim, exitAnim, null);
|
packageName, enterAnim, exitAnim, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Binder.restoreCallingIdentity(origId);
|
Binder.restoreCallingIdentity(origId);
|
||||||
|
|||||||
@@ -1417,23 +1417,7 @@ public class AppTransition implements Dump {
|
|||||||
: new TranslateAnimation(0, fromX, 0, fromY);
|
: new TranslateAnimation(0, fromX, 0, fromY);
|
||||||
set.addAnimation(scale);
|
set.addAnimation(scale);
|
||||||
set.addAnimation(translation);
|
set.addAnimation(translation);
|
||||||
|
setAppTransitionFinishedCallbackIfNeeded(set);
|
||||||
final IRemoteCallback callback = mAnimationFinishedCallback;
|
|
||||||
if (callback != null) {
|
|
||||||
set.setAnimationListener(new Animation.AnimationListener() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationStart(Animation animation) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animation animation) {
|
|
||||||
mHandler.sendMessage(PooledLambda.obtainMessage(
|
|
||||||
AppTransition::doAnimationCallback, callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationRepeat(Animation animation) { }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1671,6 +1655,7 @@ public class AppTransition implements Dump {
|
|||||||
"applyAnimation: anim=%s nextAppTransition=ANIM_CUSTOM transit=%s "
|
"applyAnimation: anim=%s nextAppTransition=ANIM_CUSTOM transit=%s "
|
||||||
+ "isEntrance=%b Callers=%s",
|
+ "isEntrance=%b Callers=%s",
|
||||||
a, appTransitionToString(transit), enter, Debug.getCallers(3));
|
a, appTransitionToString(transit), enter, Debug.getCallers(3));
|
||||||
|
setAppTransitionFinishedCallbackIfNeeded(a);
|
||||||
} else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) {
|
} else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) {
|
||||||
a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace);
|
a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace);
|
||||||
ProtoLog.v(WM_DEBUG_APP_TRANSITIONS_ANIM,
|
ProtoLog.v(WM_DEBUG_APP_TRANSITIONS_ANIM,
|
||||||
@@ -1835,7 +1820,7 @@ public class AppTransition implements Dump {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
|
void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
|
||||||
IRemoteCallback startedCallback) {
|
IRemoteCallback startedCallback, IRemoteCallback endedCallback) {
|
||||||
if (canOverridePendingAppTransition()) {
|
if (canOverridePendingAppTransition()) {
|
||||||
clear();
|
clear();
|
||||||
mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
|
mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
|
||||||
@@ -1844,6 +1829,7 @@ public class AppTransition implements Dump {
|
|||||||
mNextAppTransitionExit = exitAnim;
|
mNextAppTransitionExit = exitAnim;
|
||||||
postAnimationCallback();
|
postAnimationCallback();
|
||||||
mNextAppTransitionCallback = startedCallback;
|
mNextAppTransitionCallback = startedCallback;
|
||||||
|
mAnimationFinishedCallback = endedCallback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2331,6 +2317,25 @@ public class AppTransition implements Dump {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setAppTransitionFinishedCallbackIfNeeded(Animation anim) {
|
||||||
|
final IRemoteCallback callback = mAnimationFinishedCallback;
|
||||||
|
if (callback != null && anim != null) {
|
||||||
|
anim.setAnimationListener(new Animation.AnimationListener() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animation animation) { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
mHandler.sendMessage(PooledLambda.obtainMessage(
|
||||||
|
AppTransition::doAnimationCallback, callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animation animation) { }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void removeAppTransitionTimeoutCallbacks() {
|
void removeAppTransitionTimeoutCallbacks() {
|
||||||
mHandler.removeCallbacks(mHandleAppTransitionTimeoutRunnable);
|
mHandler.removeCallbacks(mHandleAppTransitionTimeoutRunnable);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user