Loading core/java/android/app/IActivityTaskManager.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -434,6 +434,11 @@ interface IActivityTaskManager { void registerRemoteAnimationForNextActivityStart(in String packageName, in RemoteAnimationAdapter adapter); /** * Registers remote animations for a display. */ void registerRemoteAnimationsForDisplay(int displayId, in RemoteAnimationDefinition definition); /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */ void alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity); Loading core/java/android/view/RemoteAnimationAdapter.java +17 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.view; import android.annotation.UnsupportedAppUsage; import android.app.ActivityOptions; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; Loading Loading @@ -52,6 +51,7 @@ public class RemoteAnimationAdapter implements Parcelable { private final IRemoteAnimationRunner mRunner; private final long mDuration; private final long mStatusBarTransitionDelay; private final boolean mChangeNeedsSnapshot; /** @see #getCallingPid */ private int mCallingPid; Loading @@ -59,21 +59,31 @@ public class RemoteAnimationAdapter implements Parcelable { /** * @param runner The interface that gets notified when we actually need to start the animation. * @param duration The duration of the animation. * @param changeNeedsSnapshot For change transitions, whether this should create a snapshot by * screenshotting the task. * @param statusBarTransitionDelay The desired delay for all visual animations in the * status bar caused by this app animation in millis. */ @UnsupportedAppUsage public RemoteAnimationAdapter(IRemoteAnimationRunner runner, long duration, long statusBarTransitionDelay) { long statusBarTransitionDelay, boolean changeNeedsSnapshot) { mRunner = runner; mDuration = duration; mChangeNeedsSnapshot = changeNeedsSnapshot; mStatusBarTransitionDelay = statusBarTransitionDelay; } @UnsupportedAppUsage public RemoteAnimationAdapter(IRemoteAnimationRunner runner, long duration, long statusBarTransitionDelay) { this(runner, duration, statusBarTransitionDelay, false /* changeNeedsSnapshot */); } public RemoteAnimationAdapter(Parcel in) { mRunner = IRemoteAnimationRunner.Stub.asInterface(in.readStrongBinder()); mDuration = in.readLong(); mStatusBarTransitionDelay = in.readLong(); mChangeNeedsSnapshot = in.readBoolean(); } public IRemoteAnimationRunner getRunner() { Loading @@ -88,6 +98,10 @@ public class RemoteAnimationAdapter implements Parcelable { return mStatusBarTransitionDelay; } public boolean getChangeNeedsSnapshot() { return mChangeNeedsSnapshot; } /** * To be called by system_server to keep track which pid is running this animation. */ Loading @@ -112,6 +126,7 @@ public class RemoteAnimationAdapter implements Parcelable { dest.writeStrongInterface(mRunner); dest.writeLong(mDuration); dest.writeLong(mStatusBarTransitionDelay); dest.writeBoolean(mChangeNeedsSnapshot); } public static final Creator<RemoteAnimationAdapter> CREATOR Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +21 −0 Original line number Diff line number Diff line Loading @@ -4399,6 +4399,27 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } @Override public void registerRemoteAnimationsForDisplay(int displayId, RemoteAnimationDefinition definition) { mAmInternal.enforceCallingPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS, "registerRemoteAnimations"); definition.setCallingPid(Binder.getCallingPid()); synchronized (mGlobalLock) { final ActivityDisplay display = mRootActivityContainer.getActivityDisplay(displayId); if (display == null) { Slog.e(TAG, "Couldn't find display with id: " + displayId); return; } final long origId = Binder.clearCallingIdentity(); try { display.mDisplayContent.registerRemoteAnimations(definition); } finally { Binder.restoreCallingIdentity(origId); } } } /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */ @Override public void alwaysShowUnsupportedCompileSdkWarning(ComponentName activity) { Loading services/core/java/com/android/server/wm/AppTransitionController.java +22 −5 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class AppTransitionController { private final WindowManagerService mService; private final DisplayContent mDisplayContent; private final WallpaperController mWallpaperControllerLocked; private RemoteAnimationDefinition mRemoteAnimationDefinition = null; private final SparseIntArray mTempTransitionReasons = new SparseIntArray(); Loading @@ -85,6 +86,10 @@ public class AppTransitionController { mWallpaperControllerLocked = mDisplayContent.mWallpaperController; } void registerRemoteAnimations(RemoteAnimationDefinition definition) { mRemoteAnimationDefinition = definition; } /** * Handle application transition for given display. */ Loading Loading @@ -216,6 +221,21 @@ public class AppTransitionController { return mainWindow != null ? mainWindow.mAttrs : null; } RemoteAnimationAdapter getRemoteAnimationOverride(AppWindowToken animLpToken, int transit, ArraySet<Integer> activityTypes) { final RemoteAnimationDefinition definition = animLpToken.getRemoteAnimationDefinition(); if (definition != null) { final RemoteAnimationAdapter adapter = definition.getAdapter(transit, activityTypes); if (adapter != null) { return adapter; } } if (mRemoteAnimationDefinition == null) { return null; } return mRemoteAnimationDefinition.getAdapter(transit, activityTypes); } /** * Overrides the pending transition with the remote animation defined for the transition in the * set of defined remote animations in the app window token. Loading @@ -229,11 +249,8 @@ public class AppTransitionController { if (animLpToken == null) { return; } final RemoteAnimationDefinition definition = animLpToken.getRemoteAnimationDefinition(); if (definition == null) { return; } final RemoteAnimationAdapter adapter = definition.getAdapter(transit, activityTypes); final RemoteAnimationAdapter adapter = getRemoteAnimationOverride(animLpToken, transit, activityTypes); if (adapter != null) { animLpToken.getDisplayContent().mAppTransition.overridePendingAppTransitionRemote( adapter); Loading services/core/java/com/android/server/wm/AppWindowToken.java +25 −6 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ import android.util.proto.ProtoOutputStream; import android.view.DisplayInfo; import android.view.IApplicationToken; import android.view.InputApplicationHandle; import android.view.RemoteAnimationAdapter; import android.view.RemoteAnimationDefinition; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; Loading Loading @@ -1621,6 +1622,17 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree t.reparent(getSurfaceControl(), mTransitChangeLeash); onAnimationLeashCreated(t, mTransitChangeLeash); // Skip creating snapshot if this transition is controlled by a remote animator which // doesn't need it. ArraySet<Integer> activityTypes = new ArraySet<>(); activityTypes.add(getActivityType()); RemoteAnimationAdapter adapter = mDisplayContent.mAppTransitionController.getRemoteAnimationOverride( this, TRANSIT_TASK_CHANGE_WINDOWING_MODE, activityTypes); if (adapter != null && !adapter.getChangeNeedsSnapshot()) { return; } if (mThumbnail == null && getTask() != null) { final TaskSnapshotController snapshotCtrl = mWmService.mTaskSnapshotController; final ArraySet<Task> tasks = new ArraySet<>(); Loading @@ -1639,6 +1651,11 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree return mTransitChangeLeash != null || isChangeTransition(mTransit); } @VisibleForTesting AppWindowThumbnail getThumbnail() { return mThumbnail; } @Override void checkAppWindowsReadyToShow() { if (allDrawn == mLastAllDrawn) { Loading Loading @@ -2349,7 +2366,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree AnimationAdapter thumbnailAdapter = null; getAnimationBounds(mTmpPoint, mTmpRect); boolean isChanging = isChangeTransition(transit) && mThumbnail != null; boolean isChanging = isChangeTransition(transit) && enter; // Delaying animation start isn't compatible with remote animations at all. if (getDisplayContent().mAppTransition.getRemoteAnimationController() != null Loading @@ -2368,11 +2385,13 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree getDisplayContent().getDisplayInfo(), duration, true /* isAppAnimation */, false /* isThumbnail */), mWmService.mSurfaceAnimationRunner); if (mThumbnail != null) { thumbnailAdapter = new LocalAnimationAdapter( new WindowChangeAnimationSpec(mTransitStartRect, mTmpRect, getDisplayContent().getDisplayInfo(), duration, true /* isAppAnimation */, true /* isThumbnail */), mWmService.mSurfaceAnimationRunner); } mTransit = transit; mTransitFlags = getDisplayContent().mAppTransition.getTransitFlags(); } else { Loading Loading
core/java/android/app/IActivityTaskManager.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -434,6 +434,11 @@ interface IActivityTaskManager { void registerRemoteAnimationForNextActivityStart(in String packageName, in RemoteAnimationAdapter adapter); /** * Registers remote animations for a display. */ void registerRemoteAnimationsForDisplay(int displayId, in RemoteAnimationDefinition definition); /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */ void alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity); Loading
core/java/android/view/RemoteAnimationAdapter.java +17 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package android.view; import android.annotation.UnsupportedAppUsage; import android.app.ActivityOptions; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; Loading Loading @@ -52,6 +51,7 @@ public class RemoteAnimationAdapter implements Parcelable { private final IRemoteAnimationRunner mRunner; private final long mDuration; private final long mStatusBarTransitionDelay; private final boolean mChangeNeedsSnapshot; /** @see #getCallingPid */ private int mCallingPid; Loading @@ -59,21 +59,31 @@ public class RemoteAnimationAdapter implements Parcelable { /** * @param runner The interface that gets notified when we actually need to start the animation. * @param duration The duration of the animation. * @param changeNeedsSnapshot For change transitions, whether this should create a snapshot by * screenshotting the task. * @param statusBarTransitionDelay The desired delay for all visual animations in the * status bar caused by this app animation in millis. */ @UnsupportedAppUsage public RemoteAnimationAdapter(IRemoteAnimationRunner runner, long duration, long statusBarTransitionDelay) { long statusBarTransitionDelay, boolean changeNeedsSnapshot) { mRunner = runner; mDuration = duration; mChangeNeedsSnapshot = changeNeedsSnapshot; mStatusBarTransitionDelay = statusBarTransitionDelay; } @UnsupportedAppUsage public RemoteAnimationAdapter(IRemoteAnimationRunner runner, long duration, long statusBarTransitionDelay) { this(runner, duration, statusBarTransitionDelay, false /* changeNeedsSnapshot */); } public RemoteAnimationAdapter(Parcel in) { mRunner = IRemoteAnimationRunner.Stub.asInterface(in.readStrongBinder()); mDuration = in.readLong(); mStatusBarTransitionDelay = in.readLong(); mChangeNeedsSnapshot = in.readBoolean(); } public IRemoteAnimationRunner getRunner() { Loading @@ -88,6 +98,10 @@ public class RemoteAnimationAdapter implements Parcelable { return mStatusBarTransitionDelay; } public boolean getChangeNeedsSnapshot() { return mChangeNeedsSnapshot; } /** * To be called by system_server to keep track which pid is running this animation. */ Loading @@ -112,6 +126,7 @@ public class RemoteAnimationAdapter implements Parcelable { dest.writeStrongInterface(mRunner); dest.writeLong(mDuration); dest.writeLong(mStatusBarTransitionDelay); dest.writeBoolean(mChangeNeedsSnapshot); } public static final Creator<RemoteAnimationAdapter> CREATOR Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +21 −0 Original line number Diff line number Diff line Loading @@ -4399,6 +4399,27 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } @Override public void registerRemoteAnimationsForDisplay(int displayId, RemoteAnimationDefinition definition) { mAmInternal.enforceCallingPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS, "registerRemoteAnimations"); definition.setCallingPid(Binder.getCallingPid()); synchronized (mGlobalLock) { final ActivityDisplay display = mRootActivityContainer.getActivityDisplay(displayId); if (display == null) { Slog.e(TAG, "Couldn't find display with id: " + displayId); return; } final long origId = Binder.clearCallingIdentity(); try { display.mDisplayContent.registerRemoteAnimations(definition); } finally { Binder.restoreCallingIdentity(origId); } } } /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */ @Override public void alwaysShowUnsupportedCompileSdkWarning(ComponentName activity) { Loading
services/core/java/com/android/server/wm/AppTransitionController.java +22 −5 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ public class AppTransitionController { private final WindowManagerService mService; private final DisplayContent mDisplayContent; private final WallpaperController mWallpaperControllerLocked; private RemoteAnimationDefinition mRemoteAnimationDefinition = null; private final SparseIntArray mTempTransitionReasons = new SparseIntArray(); Loading @@ -85,6 +86,10 @@ public class AppTransitionController { mWallpaperControllerLocked = mDisplayContent.mWallpaperController; } void registerRemoteAnimations(RemoteAnimationDefinition definition) { mRemoteAnimationDefinition = definition; } /** * Handle application transition for given display. */ Loading Loading @@ -216,6 +221,21 @@ public class AppTransitionController { return mainWindow != null ? mainWindow.mAttrs : null; } RemoteAnimationAdapter getRemoteAnimationOverride(AppWindowToken animLpToken, int transit, ArraySet<Integer> activityTypes) { final RemoteAnimationDefinition definition = animLpToken.getRemoteAnimationDefinition(); if (definition != null) { final RemoteAnimationAdapter adapter = definition.getAdapter(transit, activityTypes); if (adapter != null) { return adapter; } } if (mRemoteAnimationDefinition == null) { return null; } return mRemoteAnimationDefinition.getAdapter(transit, activityTypes); } /** * Overrides the pending transition with the remote animation defined for the transition in the * set of defined remote animations in the app window token. Loading @@ -229,11 +249,8 @@ public class AppTransitionController { if (animLpToken == null) { return; } final RemoteAnimationDefinition definition = animLpToken.getRemoteAnimationDefinition(); if (definition == null) { return; } final RemoteAnimationAdapter adapter = definition.getAdapter(transit, activityTypes); final RemoteAnimationAdapter adapter = getRemoteAnimationOverride(animLpToken, transit, activityTypes); if (adapter != null) { animLpToken.getDisplayContent().mAppTransition.overridePendingAppTransitionRemote( adapter); Loading
services/core/java/com/android/server/wm/AppWindowToken.java +25 −6 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ import android.util.proto.ProtoOutputStream; import android.view.DisplayInfo; import android.view.IApplicationToken; import android.view.InputApplicationHandle; import android.view.RemoteAnimationAdapter; import android.view.RemoteAnimationDefinition; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; Loading Loading @@ -1621,6 +1622,17 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree t.reparent(getSurfaceControl(), mTransitChangeLeash); onAnimationLeashCreated(t, mTransitChangeLeash); // Skip creating snapshot if this transition is controlled by a remote animator which // doesn't need it. ArraySet<Integer> activityTypes = new ArraySet<>(); activityTypes.add(getActivityType()); RemoteAnimationAdapter adapter = mDisplayContent.mAppTransitionController.getRemoteAnimationOverride( this, TRANSIT_TASK_CHANGE_WINDOWING_MODE, activityTypes); if (adapter != null && !adapter.getChangeNeedsSnapshot()) { return; } if (mThumbnail == null && getTask() != null) { final TaskSnapshotController snapshotCtrl = mWmService.mTaskSnapshotController; final ArraySet<Task> tasks = new ArraySet<>(); Loading @@ -1639,6 +1651,11 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree return mTransitChangeLeash != null || isChangeTransition(mTransit); } @VisibleForTesting AppWindowThumbnail getThumbnail() { return mThumbnail; } @Override void checkAppWindowsReadyToShow() { if (allDrawn == mLastAllDrawn) { Loading Loading @@ -2349,7 +2366,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree AnimationAdapter thumbnailAdapter = null; getAnimationBounds(mTmpPoint, mTmpRect); boolean isChanging = isChangeTransition(transit) && mThumbnail != null; boolean isChanging = isChangeTransition(transit) && enter; // Delaying animation start isn't compatible with remote animations at all. if (getDisplayContent().mAppTransition.getRemoteAnimationController() != null Loading @@ -2368,11 +2385,13 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree getDisplayContent().getDisplayInfo(), duration, true /* isAppAnimation */, false /* isThumbnail */), mWmService.mSurfaceAnimationRunner); if (mThumbnail != null) { thumbnailAdapter = new LocalAnimationAdapter( new WindowChangeAnimationSpec(mTransitStartRect, mTmpRect, getDisplayContent().getDisplayInfo(), duration, true /* isAppAnimation */, true /* isThumbnail */), mWmService.mSurfaceAnimationRunner); } mTransit = transit; mTransitFlags = getDisplayContent().mAppTransition.getTransitFlags(); } else { Loading