diff options
| author | 2025-02-11 17:18:36 -0800 | |
|---|---|---|
| committer | 2025-02-11 17:18:36 -0800 | |
| commit | 7c56658a97c03f86452c2ccbab16b44256e3f1d2 (patch) | |
| tree | b9de762029652ff7a31647b0ea4f27d9987a8580 | |
| parent | 124ec274f221c3e14cbf78f556a6060c92938dfa (diff) | |
| parent | a1812cc3ff8cf4a74b03b58ac2b1502fcb18e370 (diff) | |
Merge "Remove RemoteAnimationController" into main
10 files changed, 2 insertions, 1957 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index cf9c57aa634a..fba9d58f612f 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -333,7 +333,6 @@ import android.view.IAppTransitionAnimationSpecsFuture; import android.view.InputApplicationHandle; import android.view.RemoteAnimationAdapter; import android.view.RemoteAnimationDefinition; -import android.view.RemoteAnimationTarget; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; import android.view.WindowInsets; @@ -380,7 +379,6 @@ import com.android.server.uri.UriPermissionOwner; import com.android.server.wm.ActivityMetricsLogger.TransitionInfoSnapshot; import com.android.server.wm.SurfaceAnimator.AnimationType; import com.android.server.wm.WindowManagerService.H; -import com.android.server.wm.utils.InsetUtils; import com.android.window.flags.Flags; import dalvik.annotation.optimization.NeverCompile; @@ -9834,31 +9832,6 @@ final class ActivityRecord extends WindowToken { } @Override - RemoteAnimationTarget createRemoteAnimationTarget( - RemoteAnimationController.RemoteAnimationRecord record) { - final WindowState mainWindow = findMainWindow(); - if (task == null || mainWindow == null) { - return null; - } - final Rect insets = mainWindow.getInsetsStateWithVisibilityOverride().calculateInsets( - task.getBounds(), Type.systemBars(), false /* ignoreVisibility */).toRect(); - InsetUtils.addInsets(insets, getLetterboxInsets()); - - final RemoteAnimationTarget target = new RemoteAnimationTarget(task.mTaskId, - record.getMode(), record.mAdapter.mCapturedLeash, !fillsParent(), - new Rect(), insets, - getPrefixOrderIndex(), record.mAdapter.mPosition, record.mAdapter.mLocalBounds, - record.mAdapter.mEndBounds, task.getWindowConfiguration(), - false /*isNotInRecents*/, - record.mThumbnailAdapter != null ? record.mThumbnailAdapter.mCapturedLeash : null, - record.mStartBounds, task.getTaskInfo(), checkEnterPictureInPictureAppOpsState()); - target.setShowBackdrop(record.mShowBackdrop); - target.setWillShowImeOnTarget(mStartingData != null && mStartingData.hasImeSurface()); - target.hasAnimatingParent = record.hasAnimatingParent(); - return target; - } - - @Override boolean canCreateRemoteAnimationTarget() { return true; } diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java index 9c4b722feb47..d98ad8bb9e05 100644 --- a/services/core/java/com/android/server/wm/AppTransition.java +++ b/services/core/java/com/android/server/wm/AppTransition.java @@ -231,8 +231,6 @@ public class AppTransition implements Dump { private final int mDefaultWindowAnimationStyleResId; private boolean mOverrideTaskTransition; - private RemoteAnimationController mRemoteAnimationController; - final Handler mHandler; final Runnable mHandleAppTransitionTimeoutRunnable = () -> handleAppTransitionTimeout(); @@ -398,9 +396,7 @@ public class AppTransition implements Dump { : SystemClock.uptimeMillis(), AnimationAdapter.STATUS_BAR_TRANSITION_DURATION); - if (mRemoteAnimationController != null) { - mRemoteAnimationController.goodToGo(transit); - } else if ((isTaskOpenTransitOld(transit) || transit == TRANSIT_OLD_WALLPAPER_CLOSE) + if ((isTaskOpenTransitOld(transit) || transit == TRANSIT_OLD_WALLPAPER_CLOSE) && topOpeningAnim != null) { if (mDisplayContent.getDisplayPolicy().shouldAttachNavBarToAppDuringTransition()) { final NavBarFadeAnimationController controller = @@ -424,7 +420,6 @@ public class AppTransition implements Dump { mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE; mNextAppTransitionOverrideRequested = false; mNextAppTransitionAnimationsSpecs.clear(); - mRemoteAnimationController = null; mNextAppTransitionAnimationsSpecsFuture = null; mDefaultNextAppTransitionAnimationSpec = null; mAnimationFinishedCallback = null; @@ -442,13 +437,6 @@ public class AppTransition implements Dump { final boolean keyguardGoingAwayCancelled = mNextAppTransitionRequests.contains( TRANSIT_KEYGUARD_GOING_AWAY); - // The RemoteAnimationControl didn't register AppTransitionListener and - // only initialized the finish and timeout callback when goodToGo(). - // So cancel the remote animation here to prevent the animation can't do - // finish after transition state cleared. - if (mRemoteAnimationController != null) { - mRemoteAnimationController.cancelAnimation("freeze"); - } mNextAppTransitionRequests.clear(); clear(); setReady(); @@ -719,10 +707,6 @@ public class AppTransition implements Dump { && !mNextAppTransitionRequests.contains(TRANSIT_KEYGUARD_GOING_AWAY); } - RemoteAnimationController getRemoteAnimationController() { - return mRemoteAnimationController; - } - /** * * @param frame These are the bounds of the window when it finishes the animation. This is where @@ -1082,17 +1066,6 @@ public class AppTransition implements Dump { void overridePendingAppTransitionRemote(RemoteAnimationAdapter remoteAnimationAdapter, boolean sync, boolean isActivityEmbedding) { - ProtoLog.i(WM_DEBUG_APP_TRANSITIONS, "Override pending remote transitionSet=%b adapter=%s", - isTransitionSet(), remoteAnimationAdapter); - if (isTransitionSet() && !mNextAppTransitionIsSync) { - // ActivityEmbedding animation will run by the app process for which we want to respect - // the app override for whether or not to show background color. - clear(!isActivityEmbedding /* clearAppOverride */); - mNextAppTransitionType = NEXT_TRANSIT_TYPE_REMOTE; - mRemoteAnimationController = new RemoteAnimationController(mService, mDisplayContent, - remoteAnimationAdapter, mHandler, isActivityEmbedding); - mNextAppTransitionIsSync = sync; - } } void overrideInPlaceAppTransition(String packageName, int anim) { diff --git a/services/core/java/com/android/server/wm/NonAppWindowAnimationAdapter.java b/services/core/java/com/android/server/wm/NonAppWindowAnimationAdapter.java deleted file mode 100644 index 91598c5cc27a..000000000000 --- a/services/core/java/com/android/server/wm/NonAppWindowAnimationAdapter.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.server.wm; - -import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY; -import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER; -import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN; -import static android.view.WindowManager.TRANSIT_OLD_TASK_TO_FRONT; -import static android.view.WindowManager.TRANSIT_OLD_WALLPAPER_CLOSE; - -import static com.android.internal.protolog.WmProtoLogGroups.WM_DEBUG_REMOTE_ANIMATIONS; -import static com.android.server.wm.AnimationAdapterProto.REMOTE; -import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET; -import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION; - -import android.annotation.NonNull; -import android.graphics.Rect; -import android.os.SystemClock; -import android.util.proto.ProtoOutputStream; -import android.view.RemoteAnimationTarget; -import android.view.SurfaceControl; -import android.view.WindowManager; - -import com.android.internal.protolog.ProtoLog; -import com.android.server.policy.WindowManagerPolicy; - -import java.io.PrintWriter; -import java.util.ArrayList; - -class NonAppWindowAnimationAdapter implements AnimationAdapter { - - private final WindowContainer mWindowContainer; - private RemoteAnimationTarget mTarget; - private SurfaceControl mCapturedLeash; - private SurfaceAnimator.OnAnimationFinishedCallback mCapturedLeashFinishCallback; - private @SurfaceAnimator.AnimationType int mLastAnimationType; - - private long mDurationHint; - private long mStatusBarTransitionDelay; - - @Override - public boolean getShowWallpaper() { - return false; - } - - NonAppWindowAnimationAdapter(WindowContainer w, long durationHint, - long statusBarTransitionDelay) { - mWindowContainer = w; - mDurationHint = durationHint; - mStatusBarTransitionDelay = statusBarTransitionDelay; - } - - static RemoteAnimationTarget[] startNonAppWindowAnimations(WindowManagerService service, - DisplayContent displayContent, @WindowManager.TransitionOldType int transit, - long durationHint, long statusBarTransitionDelay, - ArrayList<NonAppWindowAnimationAdapter> adaptersOut) { - final ArrayList<RemoteAnimationTarget> targets = new ArrayList<>(); - if (shouldStartNonAppWindowAnimationsForKeyguardExit(transit)) { - startNonAppWindowAnimationsForKeyguardExit( - service, durationHint, statusBarTransitionDelay, targets, adaptersOut); - } else if (shouldAttachNavBarToApp(service, displayContent, transit)) { - startNavigationBarWindowAnimation( - displayContent, durationHint, statusBarTransitionDelay, targets, - adaptersOut); - } - return targets.toArray(new RemoteAnimationTarget[targets.size()]); - } - - static boolean shouldStartNonAppWindowAnimationsForKeyguardExit( - @WindowManager.TransitionOldType int transit) { - return transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY - || transit == TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER; - } - - static boolean shouldAttachNavBarToApp(WindowManagerService service, - DisplayContent displayContent, @WindowManager.TransitionOldType int transit) { - return (transit == TRANSIT_OLD_TASK_OPEN || transit == TRANSIT_OLD_TASK_TO_FRONT - || transit == TRANSIT_OLD_WALLPAPER_CLOSE) - && displayContent.getDisplayPolicy().shouldAttachNavBarToAppDuringTransition() - && displayContent.getAsyncRotationController() == null; - } - - /** - * Creates and starts remote animations for all the visible non app windows. - * - * @return RemoteAnimationTarget[] targets for all the visible non app windows - */ - private static void startNonAppWindowAnimationsForKeyguardExit(WindowManagerService service, - long durationHint, long statusBarTransitionDelay, - ArrayList<RemoteAnimationTarget> targets, - ArrayList<NonAppWindowAnimationAdapter> adaptersOut) { - - final WindowManagerPolicy policy = service.mPolicy; - service.mRoot.forAllWindows(nonAppWindow -> { - // Animation on the IME window is controlled via Insets. - if (nonAppWindow.mActivityRecord == null && nonAppWindow.canBeHiddenByKeyguard() - && nonAppWindow.wouldBeVisibleIfPolicyIgnored() && !nonAppWindow.isVisible() - && nonAppWindow != service.mRoot.getCurrentInputMethodWindow()) { - final NonAppWindowAnimationAdapter nonAppAdapter = new NonAppWindowAnimationAdapter( - nonAppWindow, durationHint, statusBarTransitionDelay); - adaptersOut.add(nonAppAdapter); - nonAppWindow.startAnimation(nonAppWindow.getPendingTransaction(), - nonAppAdapter, false /* hidden */, ANIMATION_TYPE_WINDOW_ANIMATION); - targets.add(nonAppAdapter.createRemoteAnimationTarget()); - } - }, true /* traverseTopToBottom */); - } - - /** - * Creates and starts remote animation for the navigation bar windows. - * - * @return RemoteAnimationTarget[] targets for all the visible non app windows - */ - private static void startNavigationBarWindowAnimation(DisplayContent displayContent, - long durationHint, long statusBarTransitionDelay, - ArrayList<RemoteAnimationTarget> targets, - ArrayList<NonAppWindowAnimationAdapter> adaptersOut) { - final WindowState navWindow = displayContent.getDisplayPolicy().getNavigationBar(); - final NonAppWindowAnimationAdapter nonAppAdapter = new NonAppWindowAnimationAdapter( - navWindow.mToken, durationHint, statusBarTransitionDelay); - adaptersOut.add(nonAppAdapter); - navWindow.mToken.startAnimation(navWindow.mToken.getPendingTransaction(), - nonAppAdapter, false /* hidden */, ANIMATION_TYPE_WINDOW_ANIMATION); - targets.add(nonAppAdapter.createRemoteAnimationTarget()); - } - - /** - * Create a remote animation target for this animation adapter. - */ - RemoteAnimationTarget createRemoteAnimationTarget() { - mTarget = new RemoteAnimationTarget(-1, -1, getLeash(), false, - new Rect(), null, mWindowContainer.getPrefixOrderIndex(), - mWindowContainer.getLastSurfacePosition(), mWindowContainer.getBounds(), null, - mWindowContainer.getWindowConfiguration(), true, null, null, null, false, - mWindowContainer.getWindowType()); - return mTarget; - } - - @Override - public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t, - int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "startAnimation"); - mCapturedLeash = animationLeash; - mCapturedLeashFinishCallback = finishCallback; - mLastAnimationType = type; - } - - /** - * @return the callback to call to clean up when the animation has finished. - */ - SurfaceAnimator.OnAnimationFinishedCallback getLeashFinishedCallback() { - return mCapturedLeashFinishCallback; - } - - /** - * @return the type of animation. - */ - @SurfaceAnimator.AnimationType - int getLastAnimationType() { - return mLastAnimationType; - } - - WindowContainer getWindowContainer() { - return mWindowContainer; - } - - @Override - public long getDurationHint() { - return mDurationHint; - } - - @Override - public long getStatusBarTransitionsStartTime() { - return SystemClock.uptimeMillis() + mStatusBarTransitionDelay; - } - - /** - * @return the leash for this animation (only valid after the non app window surface animation - * has started). - */ - SurfaceControl getLeash() { - return mCapturedLeash; - } - - @Override - public void onAnimationCancelled(SurfaceControl animationLeash) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "onAnimationCancelled"); - } - - @Override - public void dump(PrintWriter pw, String prefix) { - pw.print(prefix); - pw.print("windowContainer="); - pw.println(mWindowContainer); - if (mTarget != null) { - pw.print(prefix); - pw.println("Target:"); - mTarget.dump(pw, prefix + " "); - } else { - pw.print(prefix); - pw.println("Target: null"); - } - } - - @Override - public void dumpDebug(ProtoOutputStream proto) { - final long token = proto.start(REMOTE); - if (mTarget != null) { - mTarget.dumpDebug(proto, TARGET); - } - proto.end(token); - } -} diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java deleted file mode 100644 index b3b2c57550e4..000000000000 --- a/services/core/java/com/android/server/wm/RemoteAnimationController.java +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.server.wm; - -import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_UNOCCLUDE; - -import static com.android.internal.protolog.WmProtoLogGroups.WM_DEBUG_REMOTE_ANIMATIONS; -import static com.android.server.wm.AnimationAdapterProto.REMOTE; -import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET; -import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; -import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; - -import android.annotation.ColorInt; -import android.annotation.NonNull; -import android.annotation.Nullable; -import android.graphics.Point; -import android.graphics.Rect; -import android.os.Binder; -import android.os.Handler; -import android.os.IBinder.DeathRecipient; -import android.os.RemoteException; -import android.os.SystemClock; -import android.util.Slog; -import android.util.proto.ProtoOutputStream; -import android.view.IRemoteAnimationFinishedCallback; -import android.view.RemoteAnimationAdapter; -import android.view.RemoteAnimationTarget; -import android.view.SurfaceControl; -import android.view.SurfaceControl.Transaction; -import android.view.WindowManager; - -import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.protolog.ProtoLog; -import com.android.internal.protolog.common.LogLevel; -import com.android.internal.util.FastPrintWriter; -import com.android.server.wm.SurfaceAnimator.AnimationType; -import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.function.Consumer; - -/** - * Helper class to run app animations in a remote process. - */ -class RemoteAnimationController implements DeathRecipient { - private static final String TAG = TAG_WITH_CLASS_NAME - ? "RemoteAnimationController" : TAG_WM; - private static final long TIMEOUT_MS = 10000; - - private final WindowManagerService mService; - private final DisplayContent mDisplayContent; - private final RemoteAnimationAdapter mRemoteAnimationAdapter; - private final ArrayList<RemoteAnimationRecord> mPendingAnimations = new ArrayList<>(); - private final ArrayList<WallpaperAnimationAdapter> mPendingWallpaperAnimations = - new ArrayList<>(); - @VisibleForTesting - final ArrayList<NonAppWindowAnimationAdapter> mPendingNonAppAnimations = new ArrayList<>(); - private final Handler mHandler; - private final Runnable mTimeoutRunnable = () -> cancelAnimation("timeoutRunnable"); - private boolean mIsFinishing; - - private FinishedCallback mFinishedCallback; - private final boolean mIsActivityEmbedding; - private boolean mCanceled; - private boolean mLinkedToDeathOfRunner; - @Nullable - private Runnable mOnRemoteAnimationReady; - - RemoteAnimationController(WindowManagerService service, DisplayContent displayContent, - RemoteAnimationAdapter remoteAnimationAdapter, Handler handler, - boolean isActivityEmbedding) { - mService = service; - mDisplayContent = displayContent; - mRemoteAnimationAdapter = remoteAnimationAdapter; - mHandler = handler; - mIsActivityEmbedding = isActivityEmbedding; - } - - /** - * Creates an animation record for each individual {@link WindowContainer}. - * - * @param windowContainer The windows to animate. - * @param position The position app bounds relative to its parent. - * @param localBounds The bounds of the app relative to its parent. - * @param endBounds The end bounds after the transition, in screen coordinates. - * @param startBounds The start bounds before the transition, in screen coordinates. - * @param showBackdrop To show background behind a window during animation. - * @return The record representing animation(s) to run on the app. - */ - RemoteAnimationRecord createRemoteAnimationRecord(WindowContainer windowContainer, - Point position, Rect localBounds, Rect endBounds, Rect startBounds, - boolean showBackdrop) { - return createRemoteAnimationRecord(windowContainer, position, localBounds, endBounds, - startBounds, showBackdrop, startBounds != null /* shouldCreateSnapshot */); - } - - /** - * Creates an animation record for each individual {@link WindowContainer}. - * - * @param windowContainer The windows to animate. - * @param position The position app bounds relative to its parent. - * @param localBounds The bounds of the app relative to its parent. - * @param endBounds The end bounds after the transition, in screen coordinates. - * @param startBounds The start bounds before the transition, in screen coordinates. - * @param showBackdrop To show background behind a window during animation. - * @param shouldCreateSnapshot Whether this target should create a snapshot animation. - * @return The record representing animation(s) to run on the app. - */ - RemoteAnimationRecord createRemoteAnimationRecord(WindowContainer windowContainer, - Point position, Rect localBounds, Rect endBounds, Rect startBounds, - boolean showBackdrop, boolean shouldCreateSnapshot) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "createAnimationAdapter(): container=%s", - windowContainer); - final RemoteAnimationRecord adapters = new RemoteAnimationRecord(windowContainer, position, - localBounds, endBounds, startBounds, showBackdrop, shouldCreateSnapshot); - mPendingAnimations.add(adapters); - return adapters; - } - - /** Sets callback to run before starting remote animation. */ - void setOnRemoteAnimationReady(@Nullable Runnable onRemoteAnimationReady) { - mOnRemoteAnimationReady = onRemoteAnimationReady; - } - - /** - * We use isFromActivityEmbedding() in the server process to tell if we're running an - * Activity Embedding type remote animation, where animations are driven by the client. - * This is currently supporting features like showBackdrop where we need to load App XML. - */ - public boolean isFromActivityEmbedding() { - return mIsActivityEmbedding; - } - - /** - * Called when the transition is ready to be started, and all leashes have been set up. - */ - void goodToGo(@WindowManager.TransitionOldType int transit) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "goodToGo()"); - if (mCanceled) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, - "goodToGo(): Animation canceled already"); - onAnimationFinished(); - invokeAnimationCancelled("already_cancelled"); - return; - } - - // Scale the timeout with the animator scale the controlling app is using. - mHandler.postDelayed(mTimeoutRunnable, - (long) (TIMEOUT_MS * mService.getCurrentAnimatorScale())); - mFinishedCallback = new FinishedCallback(this); - - // Create the app targets - final RemoteAnimationTarget[] appTargets = createAppAnimations(); - if (appTargets.length == 0 && !AppTransition.isKeyguardOccludeTransitOld(transit)) { - // Keyguard occlude transition can be executed before the occluding activity becomes - // visible. Even in this case, KeyguardService expects to receive binder call, so we - // don't cancel remote animation. - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, - "goodToGo(): No apps to animate, mPendingAnimations=%d", - mPendingAnimations.size()); - onAnimationFinished(); - invokeAnimationCancelled("no_app_targets"); - return; - } - - if (mOnRemoteAnimationReady != null) { - mOnRemoteAnimationReady.run(); - mOnRemoteAnimationReady = null; - } - - // Create the remote wallpaper animation targets (if any) - final RemoteAnimationTarget[] wallpaperTargets = createWallpaperAnimations(); - - // Create the remote non app animation targets (if any) - final RemoteAnimationTarget[] nonAppTargets = createNonAppWindowAnimations(transit); - - mService.mAnimator.addAfterPrepareSurfacesRunnable(() -> { - try { - linkToDeathOfRunner(); - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "goodToGo(): onAnimationStart," - + " transit=%s, apps=%d, wallpapers=%d, nonApps=%d", - AppTransition.appTransitionOldToString(transit), appTargets.length, - wallpaperTargets.length, nonAppTargets.length); - if (AppTransition.isKeyguardOccludeTransitOld(transit)) { - EventLogTags.writeWmSetKeyguardOccluded( - transit == TRANSIT_OLD_KEYGUARD_UNOCCLUDE ? 0 : 1, - 1 /* animate */, - transit, - "onAnimationStart"); - } - mRemoteAnimationAdapter.getRunner().onAnimationStart(transit, appTargets, - wallpaperTargets, nonAppTargets, mFinishedCallback); - } catch (RemoteException e) { - Slog.e(TAG, "Failed to start remote animation", e); - onAnimationFinished(); - } - if (ProtoLog.isEnabled(WM_DEBUG_REMOTE_ANIMATIONS, LogLevel.DEBUG)) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "startAnimation(): Notify animation start:"); - writeStartDebugStatement(); - } - }); - setRunningRemoteAnimation(true); - } - - void cancelAnimation(String reason) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "cancelAnimation(): reason=%s", reason); - synchronized (mService.getWindowManagerLock()) { - if (mCanceled) { - return; - } - mCanceled = true; - } - onAnimationFinished(); - invokeAnimationCancelled(reason); - } - - private void writeStartDebugStatement() { - ProtoLog.i(WM_DEBUG_REMOTE_ANIMATIONS, "Starting remote animation"); - final StringWriter sw = new StringWriter(); - final FastPrintWriter pw = new FastPrintWriter(sw); - for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { - mPendingAnimations.get(i).mAdapter.dump(pw, ""); - } - pw.close(); - ProtoLog.i(WM_DEBUG_REMOTE_ANIMATIONS, "%s", sw.toString()); - } - - private RemoteAnimationTarget[] createAppAnimations() { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "createAppAnimations()"); - final ArrayList<RemoteAnimationTarget> targets = new ArrayList<>(); - for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { - final RemoteAnimationRecord wrappers = mPendingAnimations.get(i); - final RemoteAnimationTarget target = wrappers.createRemoteAnimationTarget(); - if (target != null) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "\tAdd container=%s", - wrappers.mWindowContainer); - targets.add(target); - } else { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "\tRemove container=%s", - wrappers.mWindowContainer); - - // We can't really start an animation but we still need to make sure to finish the - // pending animation that was started by SurfaceAnimator - if (wrappers.mAdapter != null - && wrappers.mAdapter.mCapturedFinishCallback != null) { - wrappers.mAdapter.mCapturedFinishCallback - .onAnimationFinished(wrappers.mAdapter.mAnimationType, - wrappers.mAdapter); - } - if (wrappers.mThumbnailAdapter != null - && wrappers.mThumbnailAdapter.mCapturedFinishCallback != null) { - wrappers.mThumbnailAdapter.mCapturedFinishCallback - .onAnimationFinished(wrappers.mThumbnailAdapter.mAnimationType, - wrappers.mThumbnailAdapter); - } - mPendingAnimations.remove(i); - } - } - return targets.toArray(new RemoteAnimationTarget[targets.size()]); - } - - private RemoteAnimationTarget[] createWallpaperAnimations() { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "createWallpaperAnimations()"); - return WallpaperAnimationAdapter.startWallpaperAnimations(mDisplayContent, - mRemoteAnimationAdapter.getDuration(), - mRemoteAnimationAdapter.getStatusBarTransitionDelay(), - adapter -> { - synchronized (mService.mGlobalLock) { - // If the wallpaper animation is canceled, continue with the app animation - mPendingWallpaperAnimations.remove(adapter); - } - }, mPendingWallpaperAnimations); - } - - private RemoteAnimationTarget[] createNonAppWindowAnimations( - @WindowManager.TransitionOldType int transit) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "createNonAppWindowAnimations()"); - return NonAppWindowAnimationAdapter.startNonAppWindowAnimations(mService, - mDisplayContent, - transit, - mRemoteAnimationAdapter.getDuration(), - mRemoteAnimationAdapter.getStatusBarTransitionDelay(), - mPendingNonAppAnimations); - } - - private void onAnimationFinished() { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "onAnimationFinished(): mPendingAnimations=%d", - mPendingAnimations.size()); - mHandler.removeCallbacks(mTimeoutRunnable); - synchronized (mService.mGlobalLock) { - mIsFinishing = true; - unlinkToDeathOfRunner(); - releaseFinishedCallback(); - try { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, - "onAnimationFinished(): Notify animation finished:"); - for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { - final RemoteAnimationRecord adapters = mPendingAnimations.get(i); - if (adapters.mAdapter != null) { - adapters.mAdapter.mCapturedFinishCallback - .onAnimationFinished(adapters.mAdapter.mAnimationType, - adapters.mAdapter); - } - if (adapters.mThumbnailAdapter != null) { - adapters.mThumbnailAdapter.mCapturedFinishCallback - .onAnimationFinished(adapters.mThumbnailAdapter.mAnimationType, - adapters.mThumbnailAdapter); - } - mPendingAnimations.remove(i); - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "\tcontainer=%s", - adapters.mWindowContainer); - } - - for (int i = mPendingWallpaperAnimations.size() - 1; i >= 0; i--) { - final WallpaperAnimationAdapter adapter = mPendingWallpaperAnimations.get(i); - adapter.getLeashFinishedCallback().onAnimationFinished( - adapter.getLastAnimationType(), adapter); - mPendingWallpaperAnimations.remove(i); - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "\twallpaper=%s", adapter.getToken()); - } - - for (int i = mPendingNonAppAnimations.size() - 1; i >= 0; i--) { - final NonAppWindowAnimationAdapter adapter = mPendingNonAppAnimations.get(i); - adapter.getLeashFinishedCallback().onAnimationFinished( - adapter.getLastAnimationType(), adapter); - mPendingNonAppAnimations.remove(i); - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "\tnonApp=%s", - adapter.getWindowContainer()); - } - } catch (Exception e) { - Slog.e(TAG, "Failed to finish remote animation", e); - throw e; - } finally { - mIsFinishing = false; - } - // Reset input for all activities when the remote animation is finished. - final Consumer<ActivityRecord> updateActivities = - activity -> activity.setDropInputForAnimation(false); - mDisplayContent.forAllActivities(updateActivities); - } - setRunningRemoteAnimation(false); - ProtoLog.i(WM_DEBUG_REMOTE_ANIMATIONS, "Finishing remote animation"); - } - - private void invokeAnimationCancelled(String reason) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "cancelAnimation(): reason=%s", reason); - try { - mRemoteAnimationAdapter.getRunner().onAnimationCancelled(); - } catch (RemoteException e) { - Slog.e(TAG, "Failed to notify cancel", e); - } - mOnRemoteAnimationReady = null; - } - - private void releaseFinishedCallback() { - if (mFinishedCallback != null) { - mFinishedCallback.release(); - mFinishedCallback = null; - } - } - - private void setRunningRemoteAnimation(boolean running) { - final int pid = mRemoteAnimationAdapter.getCallingPid(); - final int uid = mRemoteAnimationAdapter.getCallingUid(); - - if (pid == 0) { - throw new RuntimeException("Calling pid of remote animation was null"); - } - final WindowProcessController wpc = mService.mAtmService.getProcessController(pid, uid); - if (wpc == null) { - Slog.w(TAG, "Unable to find process with pid=" + pid + " uid=" + uid); - return; - } - wpc.setRunningRemoteAnimation(running); - } - - private void linkToDeathOfRunner() throws RemoteException { - if (!mLinkedToDeathOfRunner) { - mRemoteAnimationAdapter.getRunner().asBinder().linkToDeath(this, 0); - mLinkedToDeathOfRunner = true; - } - } - - private void unlinkToDeathOfRunner() { - if (mLinkedToDeathOfRunner) { - mRemoteAnimationAdapter.getRunner().asBinder().unlinkToDeath(this, 0); - mLinkedToDeathOfRunner = false; - } - } - - @Override - public void binderDied() { - cancelAnimation("binderDied"); - } - - private static final class FinishedCallback extends IRemoteAnimationFinishedCallback.Stub { - - RemoteAnimationController mOuter; - - FinishedCallback(RemoteAnimationController outer) { - mOuter = outer; - } - - @Override - public void onAnimationFinished() throws RemoteException { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "app-onAnimationFinished(): mOuter=%s", mOuter); - final long token = Binder.clearCallingIdentity(); - try { - if (mOuter != null) { - mOuter.onAnimationFinished(); - - // In case the client holds on to the finish callback, make sure we don't leak - // RemoteAnimationController which in turn would leak the runner on the client. - mOuter = null; - } - } finally { - Binder.restoreCallingIdentity(token); - } - } - - /** - * Marks this callback as not be used anymore by releasing the reference to the outer class - * to prevent memory leak. - */ - void release() { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "app-release(): mOuter=%s", mOuter); - mOuter = null; - } - }; - - /** - * Contains information about a remote-animation for one WindowContainer. This keeps track of, - * potentially, multiple animating surfaces (AdapterWrappers) associated with one - * Window/Transition. For example, a change transition has an adapter controller for the - * main window and an adapter controlling the start-state snapshot. - * <p> - * This can be thought of as a bridge between the information that the remote animator sees (via - * {@link RemoteAnimationTarget}) and what the server sees (the - * {@link RemoteAnimationAdapterWrapper}(s) interfacing with the moving surfaces). - */ - public class RemoteAnimationRecord { - RemoteAnimationAdapterWrapper mAdapter; - RemoteAnimationAdapterWrapper mThumbnailAdapter = null; - RemoteAnimationTarget mTarget; - final WindowContainer mWindowContainer; - final Rect mStartBounds; - final boolean mShowBackdrop; - @ColorInt int mBackdropColor = 0; - private @RemoteAnimationTarget.Mode int mMode = RemoteAnimationTarget.MODE_CHANGING; - - RemoteAnimationRecord(WindowContainer windowContainer, Point endPos, Rect localBounds, - Rect endBounds, @Nullable Rect startBounds, boolean showBackdrop, - boolean shouldCreateSnapshot) { - mWindowContainer = windowContainer; - mShowBackdrop = showBackdrop; - if (startBounds != null) { - mStartBounds = new Rect(startBounds); - mAdapter = new RemoteAnimationAdapterWrapper(this, endPos, localBounds, endBounds, - mStartBounds, mShowBackdrop); - if (shouldCreateSnapshot && mRemoteAnimationAdapter.getChangeNeedsSnapshot()) { - final Rect thumbnailLocalBounds = new Rect(startBounds); - thumbnailLocalBounds.offsetTo(0, 0); - // Snapshot is located at (0,0) of the animation leash. It doesn't have size - // change, so the startBounds is its end bounds, and no start bounds for it. - mThumbnailAdapter = new RemoteAnimationAdapterWrapper(this, new Point(0, 0), - thumbnailLocalBounds, startBounds, new Rect(), mShowBackdrop); - } - } else { - mAdapter = new RemoteAnimationAdapterWrapper(this, endPos, localBounds, endBounds, - new Rect(), mShowBackdrop); - mStartBounds = null; - } - } - - void setBackDropColor(@ColorInt int backdropColor) { - mBackdropColor = backdropColor; - } - - RemoteAnimationTarget createRemoteAnimationTarget() { - if (mAdapter == null - || mAdapter.mCapturedFinishCallback == null - || mAdapter.mCapturedLeash == null) { - return null; - } - mTarget = mWindowContainer.createRemoteAnimationTarget(this); - return mTarget; - } - - void setMode(@RemoteAnimationTarget.Mode int mode) { - mMode = mode; - } - - int getMode() { - return mMode; - } - - /** Whether its parent is also an animation target in the same transition. */ - boolean hasAnimatingParent() { - // mOpeningApps and mClosingApps are only activities, so only need to check - // mChangingContainers. - for (int i = mDisplayContent.mChangingContainers.size() - 1; i >= 0; i--) { - if (mWindowContainer.isDescendantOf( - mDisplayContent.mChangingContainers.valueAt(i))) { - return true; - } - } - return false; - } - } - - class RemoteAnimationAdapterWrapper implements AnimationAdapter { - private final RemoteAnimationRecord mRecord; - SurfaceControl mCapturedLeash; - private OnAnimationFinishedCallback mCapturedFinishCallback; - private @AnimationType int mAnimationType; - final Point mPosition = new Point(); - final Rect mLocalBounds; - final Rect mEndBounds = new Rect(); - final Rect mStartBounds = new Rect(); - final boolean mShowBackdrop; - - RemoteAnimationAdapterWrapper(RemoteAnimationRecord record, Point position, - Rect localBounds, Rect endBounds, Rect startBounds, boolean showBackdrop) { - mRecord = record; - mPosition.set(position.x, position.y); - mLocalBounds = localBounds; - mEndBounds.set(endBounds); - mStartBounds.set(startBounds); - mShowBackdrop = showBackdrop; - } - - @Override - @ColorInt - public int getBackgroundColor() { - return mRecord.mBackdropColor; - } - - @Override - public boolean getShowBackground() { - return mShowBackdrop; - } - - @Override - public boolean getShowWallpaper() { - return false; - } - - @Override - public void startAnimation(SurfaceControl animationLeash, Transaction t, - @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "startAnimation"); - - if (mStartBounds.isEmpty()) { - // Restore position and stack crop until client has a chance to modify it. - t.setPosition(animationLeash, mPosition.x, mPosition.y); - t.setWindowCrop(animationLeash, mEndBounds.width(), mEndBounds.height()); - } else { - // Offset the change animation leash to the relative start position in parent. - // (mPosition) is the relative end position in parent container. - // (mStartBounds - mEndBounds) is the position difference between start and end. - // (mPosition + mStartBounds - mEndBounds) will be the relative start position. - t.setPosition(animationLeash, mPosition.x + mStartBounds.left - mEndBounds.left, - mPosition.y + mStartBounds.top - mEndBounds.top); - t.setWindowCrop(animationLeash, mStartBounds.width(), mStartBounds.height()); - } - mCapturedLeash = animationLeash; - mCapturedFinishCallback = finishCallback; - mAnimationType = type; - } - - @Override - public void onAnimationCancelled(SurfaceControl animationLeash) { - if (mIsFinishing) { - return; - } - if (mRecord.mAdapter == this) { - mRecord.mAdapter = null; - } else { - mRecord.mThumbnailAdapter = null; - } - if (mRecord.mAdapter == null && mRecord.mThumbnailAdapter == null) { - mPendingAnimations.remove(mRecord); - } - if (mPendingAnimations.isEmpty()) { - cancelAnimation("allAppAnimationsCanceled"); - } - } - - @Override - public long getDurationHint() { - return mRemoteAnimationAdapter.getDuration(); - } - - @Override - public long getStatusBarTransitionsStartTime() { - return SystemClock.uptimeMillis() - + mRemoteAnimationAdapter.getStatusBarTransitionDelay(); - } - - @Override - public void dump(PrintWriter pw, String prefix) { - pw.print(prefix); pw.print("container="); pw.println(mRecord.mWindowContainer); - if (mRecord.mTarget != null) { - pw.print(prefix); pw.println("Target:"); - mRecord.mTarget.dump(pw, prefix + " "); - } else { - pw.print(prefix); pw.println("Target: null"); - } - } - - @Override - public void dumpDebug(ProtoOutputStream proto) { - final long token = proto.start(REMOTE); - if (mRecord.mTarget != null) { - mRecord.mTarget.dumpDebug(proto, TARGET); - } - proto.end(token); - } - } -} diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java index ae3a015a690d..1966ecf57c73 100644 --- a/services/core/java/com/android/server/wm/TaskDisplayArea.java +++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java @@ -50,7 +50,6 @@ import android.graphics.Color; import android.os.UserHandle; import android.util.IntArray; import android.util.Slog; -import android.view.RemoteAnimationTarget; import android.view.SurfaceControl; import android.view.WindowManager; @@ -776,13 +775,6 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { return needsZBoost[0]; } - @Override - RemoteAnimationTarget createRemoteAnimationTarget( - RemoteAnimationController.RemoteAnimationRecord record) { - final ActivityRecord activity = getTopMostActivity(); - return activity != null ? activity.createRemoteAnimationTarget(record) : null; - } - void setBackgroundColor(@ColorInt int colorInt) { setBackgroundColor(colorInt, false /* restore */); } diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 97a1a34336e9..74059c1cc9b1 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -99,7 +99,6 @@ import android.util.DisplayMetrics; import android.util.Slog; import android.util.proto.ProtoOutputStream; import android.view.DisplayInfo; -import android.view.RemoteAnimationTarget; import android.view.SurfaceControl; import android.window.ITaskFragmentOrganizer; import android.window.TaskFragmentAnimationParams; @@ -2306,18 +2305,6 @@ class TaskFragment extends WindowContainer<WindowContainer> { } @Override - RemoteAnimationTarget createRemoteAnimationTarget( - RemoteAnimationController.RemoteAnimationRecord record) { - final ActivityRecord activity = record.getMode() == RemoteAnimationTarget.MODE_OPENING - // There may be a launching (e.g. trampoline or embedded) activity without a window - // on top of the existing task which is moving to front. Exclude finishing activity - // so the window of next activity can be chosen to create the animation target. - ? getActivity(r -> !r.finishing && r.hasChild()) - : getTopMostActivity(); - return activity != null ? activity.createRemoteAnimationTarget(record) : null; - } - - @Override boolean canCreateRemoteAnimationTarget() { return true; } diff --git a/services/core/java/com/android/server/wm/WallpaperAnimationAdapter.java b/services/core/java/com/android/server/wm/WallpaperAnimationAdapter.java deleted file mode 100644 index c3e85b1f8662..000000000000 --- a/services/core/java/com/android/server/wm/WallpaperAnimationAdapter.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.server.wm; - -import static com.android.internal.protolog.WmProtoLogGroups.WM_DEBUG_REMOTE_ANIMATIONS; -import static com.android.server.wm.AnimationAdapterProto.REMOTE; -import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET; -import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION; - -import android.annotation.NonNull; -import android.graphics.Point; -import android.os.SystemClock; -import android.util.proto.ProtoOutputStream; -import android.view.RemoteAnimationTarget; -import android.view.SurfaceControl; - -import com.android.internal.protolog.ProtoLog; -import com.android.server.wm.SurfaceAnimator.AnimationType; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.function.Consumer; - -/** - * An animation adapter for wallpaper windows. - */ -class WallpaperAnimationAdapter implements AnimationAdapter { - private static final String TAG = "WallpaperAnimationAdapter"; - - private final WallpaperWindowToken mWallpaperToken; - private SurfaceControl mCapturedLeash; - private SurfaceAnimator.OnAnimationFinishedCallback mCapturedLeashFinishCallback; - private @AnimationType int mLastAnimationType; - - private long mDurationHint; - private long mStatusBarTransitionDelay; - - private Consumer<WallpaperAnimationAdapter> mAnimationCanceledRunnable; - private RemoteAnimationTarget mTarget; - - WallpaperAnimationAdapter(WallpaperWindowToken wallpaperToken, - long durationHint, long statusBarTransitionDelay, - Consumer<WallpaperAnimationAdapter> animationCanceledRunnable) { - mWallpaperToken = wallpaperToken; - mDurationHint = durationHint; - mStatusBarTransitionDelay = statusBarTransitionDelay; - mAnimationCanceledRunnable = animationCanceledRunnable; - } - - /** - * Creates and starts remote animations for all the visible wallpaper windows. - * - * @return RemoteAnimationTarget[] targets for all the visible wallpaper windows - */ - public static RemoteAnimationTarget[] startWallpaperAnimations(DisplayContent displayContent, - long durationHint, long statusBarTransitionDelay, - Consumer<WallpaperAnimationAdapter> animationCanceledRunnable, - ArrayList<WallpaperAnimationAdapter> adaptersOut) { - if (!shouldStartWallpaperAnimation(displayContent)) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, - "\tWallpaper of display=%s is not visible", displayContent); - return new RemoteAnimationTarget[0]; - } - final ArrayList<RemoteAnimationTarget> targets = new ArrayList<>(); - displayContent.forAllWallpaperWindows(wallpaperWindow -> { - final WallpaperAnimationAdapter wallpaperAdapter = new WallpaperAnimationAdapter( - wallpaperWindow, durationHint, statusBarTransitionDelay, - animationCanceledRunnable); - wallpaperWindow.startAnimation(wallpaperWindow.getPendingTransaction(), - wallpaperAdapter, false /* hidden */, ANIMATION_TYPE_WINDOW_ANIMATION); - targets.add(wallpaperAdapter.createRemoteAnimationTarget()); - adaptersOut.add(wallpaperAdapter); - }); - return targets.toArray(new RemoteAnimationTarget[targets.size()]); - } - - static boolean shouldStartWallpaperAnimation(DisplayContent displayContent) { - return displayContent.mWallpaperController.isWallpaperVisible(); - } - - /** - * Create a remote animation target for this animation adapter. - */ - RemoteAnimationTarget createRemoteAnimationTarget() { - mTarget = new RemoteAnimationTarget(-1, -1, getLeash(), false, null, null, - mWallpaperToken.getPrefixOrderIndex(), new Point(), null, null, - mWallpaperToken.getWindowConfiguration(), true, null, null, null, false); - return mTarget; - } - - /** - * @return the leash for this animation (only valid after the wallpaper window surface animation - * has started). - */ - SurfaceControl getLeash() { - return mCapturedLeash; - } - - /** - * @return the callback to call to clean up when the animation has finished. - */ - SurfaceAnimator.OnAnimationFinishedCallback getLeashFinishedCallback() { - return mCapturedLeashFinishCallback; - } - - /** - * @return the type of animation. - */ - @AnimationType int getLastAnimationType() { - return mLastAnimationType; - } - - /** - * @return the wallpaper window - */ - WallpaperWindowToken getToken() { - return mWallpaperToken; - } - - @Override - public boolean getShowWallpaper() { - // Not used - return false; - } - - @Override - public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t, - @AnimationType int type, - @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "startAnimation"); - - // Restore z-layering until client has a chance to modify it. - t.setLayer(animationLeash, mWallpaperToken.getPrefixOrderIndex()); - mCapturedLeash = animationLeash; - mCapturedLeashFinishCallback = finishCallback; - mLastAnimationType = type; - } - - @Override - public void onAnimationCancelled(SurfaceControl animationLeash) { - ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "onAnimationCancelled"); - mAnimationCanceledRunnable.accept(this); - } - - @Override - public long getDurationHint() { - return mDurationHint; - } - - @Override - public long getStatusBarTransitionsStartTime() { - return SystemClock.uptimeMillis() + mStatusBarTransitionDelay; - } - - @Override - public void dump(PrintWriter pw, String prefix) { - pw.print(prefix); - pw.print("token="); - pw.println(mWallpaperToken); - if (mTarget != null) { - pw.print(prefix); - pw.println("Target:"); - mTarget.dump(pw, prefix + " "); - } else { - pw.print(prefix); - pw.println("Target: null"); - } - } - - @Override - public void dumpDebug(ProtoOutputStream proto) { - final long token = proto.start(REMOTE); - if (mTarget != null) { - mTarget.dumpDebug(proto, TARGET); - } - proto.end(token); - } -} diff --git a/services/core/java/com/android/server/wm/WallpaperWindowToken.java b/services/core/java/com/android/server/wm/WallpaperWindowToken.java index 3b79c54f1c73..7c88abcec7ec 100644 --- a/services/core/java/com/android/server/wm/WallpaperWindowToken.java +++ b/services/core/java/com/android/server/wm/WallpaperWindowToken.java @@ -34,7 +34,6 @@ import android.util.SparseArray; import com.android.internal.protolog.ProtoLog; import java.io.PrintWriter; -import java.util.function.Consumer; /** * A token that represents a set of wallpaper windows. @@ -250,11 +249,6 @@ class WallpaperWindowToken extends WindowToken { } @Override - void forAllWallpaperWindows(Consumer<WallpaperWindowToken> callback) { - callback.accept(this); - } - - @Override boolean fillsParent() { return true; } diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 7af542f10127..e6308b6a215a 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -97,7 +97,6 @@ import android.view.InsetsSource; import android.view.InsetsState; import android.view.MagnificationSpec; import android.view.RemoteAnimationDefinition; -import android.view.RemoteAnimationTarget; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceControl.Builder; @@ -2097,12 +2096,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< return getActivity((r) -> !r.finishing && !r.isTaskOverlay()); } - void forAllWallpaperWindows(Consumer<WallpaperWindowToken> callback) { - for (int i = mChildren.size() - 1; i >= 0; --i) { - mChildren.get(i).forAllWallpaperWindows(callback); - } - } - /** * Calls the given {@param callback} for all tasks in depth-first top-down z-order at or below * this container. @@ -3174,61 +3167,10 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< getAnimationPosition(mTmpPoint); mTmpRect.offsetTo(0, 0); - final AppTransition appTransition = getDisplayContent().mAppTransition; - final RemoteAnimationController controller = appTransition.getRemoteAnimationController(); final boolean isChanging = AppTransition.isChangeTransitOld(transit) && enter && isChangingAppTransition(); - if (controller != null) { - // Here we load App XML in order to read com.android.R.styleable#Animation_showBackdrop. - boolean showBackdrop = false; - // Optionally set backdrop color if App explicitly provides it through - // {@link Activity#overridePendingTransition(int, int, int)}. - @ColorInt int backdropColor = 0; - if (controller.isFromActivityEmbedding()) { - if (isChanging) { - // When there are more than one changing containers, it may leave part of the - // screen empty. Show background color to cover that. - showBackdrop = getDisplayContent().mChangingContainers.size() > 1; - backdropColor = appTransition.getNextAppTransitionBackgroundColor(); - } else { - // Check whether the app has requested to show backdrop for open/close - // transition. - final Animation a = appTransition.getNextAppRequestedAnimation(enter); - if (a != null) { - showBackdrop = a.getShowBackdrop(); - backdropColor = a.getBackdropColor(); - } - } - } - final Rect localBounds = new Rect(mTmpRect); - localBounds.offsetTo(mTmpPoint.x, mTmpPoint.y); - final RemoteAnimationController.RemoteAnimationRecord adapters; - if (!isChanging && !enter && isClosingWhenResizing()) { - // Container that is closing while resizing. Pass in the closing start bounds, so - // the animation can start with the correct bounds, there won't be a snapshot. - // Cleanup the mClosingChangingContainers so that when the animation is finished, it - // will reset the surface. - final Rect closingStartBounds = getDisplayContent().mClosingChangingContainers - .remove(this); - adapters = controller.createRemoteAnimationRecord( - this, mTmpPoint, localBounds, screenBounds, closingStartBounds, - showBackdrop, false /* shouldCreateSnapshot */); - } else { - final Rect startBounds = null; - adapters = controller.createRemoteAnimationRecord( - this, mTmpPoint, localBounds, screenBounds, startBounds, showBackdrop); - } - if (backdropColor != 0) { - adapters.setBackDropColor(backdropColor); - } - if (!isChanging) { - adapters.setMode(enter - ? RemoteAnimationTarget.MODE_OPENING - : RemoteAnimationTarget.MODE_CLOSING); - } - resultAdapters = new Pair<>(adapters.mAdapter, adapters.mThumbnailAdapter); - } else if (isChanging) { + if (isChanging) { final float durationScale = mWmService.getTransitionAnimationScaleLocked(); final DisplayInfo displayInfo = getDisplayContent().getDisplayInfo(); mTmpRect.offsetTo(mTmpPoint.x, mTmpPoint.y); @@ -3417,11 +3359,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< return a; } - RemoteAnimationTarget createRemoteAnimationTarget( - RemoteAnimationController.RemoteAnimationRecord record) { - return null; - } - boolean canCreateRemoteAnimationTarget() { return false; } diff --git a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java deleted file mode 100644 index 20381ba21758..000000000000 --- a/services/tests/wmtests/src/com/android/server/wm/RemoteAnimationControllerTest.java +++ /dev/null @@ -1,757 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.server.wm; - -import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; -import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; -import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; -import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_OPEN; -import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY; -import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER; -import static android.view.WindowManager.TRANSIT_OLD_NONE; -import static android.view.WindowManager.TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE; -import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN; - -import static com.android.dx.mockito.inline.extended.ExtendedMockito.atLeast; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.never; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyNoMoreInteractions; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.when; -import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION; -import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION; - -import static junit.framework.Assert.fail; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; - -import android.graphics.Point; -import android.graphics.Rect; -import android.os.Binder; -import android.os.IBinder; -import android.os.IInterface; -import android.os.RemoteException; -import android.platform.test.annotations.Presubmit; -import android.view.IRemoteAnimationFinishedCallback; -import android.view.IRemoteAnimationRunner; -import android.view.RemoteAnimationAdapter; -import android.view.RemoteAnimationTarget; -import android.view.SurfaceControl; -import android.view.SurfaceControl.Transaction; - -import androidx.test.filters.SmallTest; - -import com.android.server.testutils.OffsettableClock; -import com.android.server.testutils.TestHandler; -import com.android.server.wm.RemoteAnimationController.RemoteAnimationRecord; -import com.android.server.wm.SurfaceAnimator.OnAnimationFinishedCallback; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * Build/Install/Run: - * atest WmTests:RemoteAnimationControllerTest - */ -@SmallTest -@Presubmit -@RunWith(WindowTestRunner.class) -public class RemoteAnimationControllerTest extends WindowTestsBase { - - @Mock - SurfaceControl mMockLeash; - @Mock - SurfaceControl mMockThumbnailLeash; - @Mock - Transaction mMockTransaction; - @Mock - OnAnimationFinishedCallback mFinishedCallback; - @Mock - OnAnimationFinishedCallback mThumbnailFinishedCallback; - @Mock - IRemoteAnimationRunner mMockRunner; - private RemoteAnimationAdapter mAdapter; - private RemoteAnimationController mController; - private final OffsettableClock mClock = new OffsettableClock.Stopped(); - private TestHandler mHandler; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - when(mMockRunner.asBinder()).thenReturn(new Binder()); - mAdapter = new RemoteAnimationAdapter(mMockRunner, 100, 50, true /* changeNeedsSnapshot */); - mAdapter.setCallingPidUid(123, 456); - runWithScissors(mWm.mH, () -> mHandler = new TestHandler(null, mClock), 0); - mController = new RemoteAnimationController(mWm, mDisplayContent, mAdapter, - mHandler, false /*isActivityEmbedding*/); - mWm.mAnimator.ready(); - } - - private WindowState createAppOverlayWindow() { - final WindowState win = newWindowBuilder("testOverlayWindow", - TYPE_APPLICATION_OVERLAY).build(); - win.mActivityRecord = null; - win.mHasSurface = true; - return win; - } - - @Test - public void testForwardsShowBackdrop() throws Exception { - final WindowState win = createTestWindow(); - mDisplayContent.mOpeningApps.add(win.mActivityRecord); - final WindowState overlayWin = createAppOverlayWindow(); - try { - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, - true /* showBackdrop */).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_ACTIVITY_OPEN), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAppsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, appsCaptor.getValue().length); - final RemoteAnimationTarget app = appsCaptor.getValue()[0]; - assertTrue(app.showBackdrop); - } finally { - mDisplayContent.mOpeningApps.clear(); - } - } - - @Test - public void testRun() throws Exception { - final WindowState win = createTestWindow(); - mDisplayContent.mOpeningApps.add(win.mActivityRecord); - final WindowState overlayWin = createAppOverlayWindow(); - try { - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_ACTIVITY_OPEN), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAppsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, appsCaptor.getValue().length); - final RemoteAnimationTarget app = appsCaptor.getValue()[0]; - assertEquals(new Point(50, 100), app.position); - assertEquals(new Rect(50, 100, 150, 150), app.sourceContainerBounds); - assertEquals(win.mActivityRecord.getPrefixOrderIndex(), app.prefixOrderIndex); - assertEquals(win.mActivityRecord.getTask().mTaskId, app.taskId); - assertEquals(mMockLeash, app.leash); - assertEquals(false, app.isTranslucent); - verify(mMockTransaction).setPosition(mMockLeash, app.position.x, app.position.y); - verify(mMockTransaction).setWindowCrop(mMockLeash, 100, 50); - - finishedCaptor.getValue().onAnimationFinished(); - verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), - eq(adapter)); - assertEquals(0, nonAppsCaptor.getValue().length); - } finally { - mDisplayContent.mOpeningApps.clear(); - } - } - - @Test - public void testCancel() throws Exception { - final WindowState win = createTestWindow(); - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - - adapter.onAnimationCancelled(mMockLeash); - verify(mMockRunner).onAnimationCancelled(); - } - - @Test - public void testTimeout() throws Exception { - final WindowState win = createTestWindow(); - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - - mClock.fastForward(10500); - mHandler.timeAdvance(); - - verify(mMockRunner).onAnimationCancelled(); - verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), - eq(adapter)); - } - - @Test - public void testTimeout_scaled() throws Exception { - try { - mWm.setAnimationScale(2, 5.0f); - final WindowState win = createTestWindow(); - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, new Point(50, 100), null, new Rect(50, 100, 150, 150), - null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - - mClock.fastForward(10500); - mHandler.timeAdvance(); - - verify(mMockRunner, never()).onAnimationCancelled(); - - mClock.fastForward(52500); - mHandler.timeAdvance(); - - verify(mMockRunner).onAnimationCancelled(); - verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), - eq(adapter)); - } finally { - mWm.setAnimationScale(2, 1.0f); - } - } - - @Test - public void testZeroAnimations() throws Exception { - mController.goodToGo(TRANSIT_OLD_NONE); - verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any()); - verify(mMockRunner).onAnimationCancelled(); - } - - @Test - public void testNotReallyStarted() throws Exception { - final WindowState win = createTestWindow(); - mController.createRemoteAnimationRecord(win.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any()); - verify(mMockRunner).onAnimationCancelled(); - } - - @Test - public void testOneNotStarted() throws Exception { - final WindowState win1 = newWindowBuilder("testWin1", TYPE_BASE_APPLICATION).build(); - final WindowState win2 = newWindowBuilder("testWin2", TYPE_BASE_APPLICATION).build(); - mController.createRemoteAnimationRecord(win1.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false); - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win2.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_ACTIVITY_OPEN), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAppsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, appsCaptor.getValue().length); - assertEquals(mMockLeash, appsCaptor.getValue()[0].leash); - } - - @Test - public void testRemovedBeforeStarted() throws Exception { - final WindowState win = createTestWindow(); - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - win.mActivityRecord.removeImmediately(); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - verify(mMockRunner, never()).onAnimationStart(anyInt(), any(), any(), any(), any()); - verify(mMockRunner).onAnimationCancelled(); - verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), - eq(adapter)); - } - - @Test - public void testOpeningTaskWithTopFinishingActivity() { - final WindowState win = createTestWindow(); - final Task task = win.getTask(); - final ActivityRecord topFinishing = new ActivityBuilder(mAtm).setTask(task).build(); - // Now the task contains: - // - Activity[1] (top, finishing, no window) - // - Activity[0] (has window) - topFinishing.finishing = true; - spyOn(mDisplayContent.mAppTransition); - doReturn(mController).when(mDisplayContent.mAppTransition).getRemoteAnimationController(); - task.applyAnimationUnchecked(null /* lp */, true /* enter */, TRANSIT_OLD_TASK_OPEN, - false /* isVoiceInteraction */, null /* sources */); - mController.goodToGo(TRANSIT_OLD_TASK_OPEN); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - try { - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_TASK_OPEN), - appsCaptor.capture(), any(), any(), any()); - } catch (RemoteException ignored) { - } - assertEquals(1, appsCaptor.getValue().length); - assertEquals(RemoteAnimationTarget.MODE_OPENING, appsCaptor.getValue()[0].mode); - } - - @Test - public void testChangeToSmallerSize() throws Exception { - final WindowState win = createTestWindow(); - mDisplayContent.mChangingContainers.add(win.mActivityRecord); - try { - final RemoteAnimationRecord record = mController.createRemoteAnimationRecord( - win.mActivityRecord, new Point(50, 100), null, new Rect(50, 100, 150, 150), - new Rect(0, 0, 200, 200), false); - assertNotNull(record.mThumbnailAdapter); - ((AnimationAdapter) record.mAdapter) - .startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_WINDOW_ANIMATION, - mFinishedCallback); - ((AnimationAdapter) record.mThumbnailAdapter).startAnimation(mMockThumbnailLeash, - mMockTransaction, ANIMATION_TYPE_WINDOW_ANIMATION, mThumbnailFinishedCallback); - mController.goodToGo(TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAppsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, appsCaptor.getValue().length); - final RemoteAnimationTarget app = appsCaptor.getValue()[0]; - assertEquals(RemoteAnimationTarget.MODE_CHANGING, app.mode); - assertEquals(new Point(50, 100), app.position); - assertEquals(new Rect(50, 100, 150, 150), app.sourceContainerBounds); - assertEquals(new Rect(0, 0, 200, 200), app.startBounds); - assertEquals(mMockLeash, app.leash); - assertEquals(mMockThumbnailLeash, app.startLeash); - assertEquals(false, app.isTranslucent); - verify(mMockTransaction).setPosition( - mMockLeash, app.startBounds.left, app.startBounds.top); - verify(mMockTransaction).setWindowCrop( - mMockLeash, app.startBounds.width(), app.startBounds.height()); - verify(mMockTransaction).setPosition(mMockThumbnailLeash, 0, 0); - verify(mMockTransaction).setWindowCrop(mMockThumbnailLeash, app.startBounds.width(), - app.startBounds.height()); - - finishedCaptor.getValue().onAnimationFinished(); - verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_WINDOW_ANIMATION), - eq(record.mAdapter)); - verify(mThumbnailFinishedCallback).onAnimationFinished( - eq(ANIMATION_TYPE_WINDOW_ANIMATION), eq(record.mThumbnailAdapter)); - } finally { - mDisplayContent.mChangingContainers.clear(); - } - } - - @Test - public void testChangeTolargerSize() throws Exception { - final WindowState win = createTestWindow(); - mDisplayContent.mChangingContainers.add(win.mActivityRecord); - try { - final RemoteAnimationRecord record = mController.createRemoteAnimationRecord( - win.mActivityRecord, new Point(0, 0), null, new Rect(0, 0, 200, 200), - new Rect(50, 100, 150, 150), false); - assertNotNull(record.mThumbnailAdapter); - ((AnimationAdapter) record.mAdapter) - .startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_WINDOW_ANIMATION, - mFinishedCallback); - ((AnimationAdapter) record.mThumbnailAdapter).startAnimation(mMockThumbnailLeash, - mMockTransaction, ANIMATION_TYPE_WINDOW_ANIMATION, mThumbnailFinishedCallback); - mController.goodToGo(TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAppsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, appsCaptor.getValue().length); - final RemoteAnimationTarget app = appsCaptor.getValue()[0]; - assertEquals(RemoteAnimationTarget.MODE_CHANGING, app.mode); - assertEquals(new Point(0, 0), app.position); - assertEquals(new Rect(0, 0, 200, 200), app.sourceContainerBounds); - assertEquals(new Rect(50, 100, 150, 150), app.startBounds); - assertEquals(mMockLeash, app.leash); - assertEquals(mMockThumbnailLeash, app.startLeash); - assertEquals(false, app.isTranslucent); - verify(mMockTransaction).setPosition( - mMockLeash, app.startBounds.left, app.startBounds.top); - verify(mMockTransaction).setWindowCrop( - mMockLeash, app.startBounds.width(), app.startBounds.height()); - verify(mMockTransaction).setPosition(mMockThumbnailLeash, 0, 0); - verify(mMockTransaction).setWindowCrop(mMockThumbnailLeash, app.startBounds.width(), - app.startBounds.height()); - - finishedCaptor.getValue().onAnimationFinished(); - verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_WINDOW_ANIMATION), - eq(record.mAdapter)); - verify(mThumbnailFinishedCallback).onAnimationFinished( - eq(ANIMATION_TYPE_WINDOW_ANIMATION), eq(record.mThumbnailAdapter)); - } finally { - mDisplayContent.mChangingContainers.clear(); - } - } - - @Test - public void testChangeToDifferentPosition() throws Exception { - final WindowState win = createTestWindow(); - mDisplayContent.mChangingContainers.add(win.mActivityRecord); - try { - final RemoteAnimationRecord record = mController.createRemoteAnimationRecord( - win.mActivityRecord, new Point(100, 100), null, new Rect(150, 150, 400, 400), - new Rect(50, 100, 150, 150), false); - assertNotNull(record.mThumbnailAdapter); - ((AnimationAdapter) record.mAdapter) - .startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_WINDOW_ANIMATION, - mFinishedCallback); - ((AnimationAdapter) record.mThumbnailAdapter).startAnimation(mMockThumbnailLeash, - mMockTransaction, ANIMATION_TYPE_WINDOW_ANIMATION, mThumbnailFinishedCallback); - mController.goodToGo(TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAppsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, appsCaptor.getValue().length); - final RemoteAnimationTarget app = appsCaptor.getValue()[0]; - assertEquals(RemoteAnimationTarget.MODE_CHANGING, app.mode); - assertEquals(new Point(100, 100), app.position); - assertEquals(new Rect(150, 150, 400, 400), app.sourceContainerBounds); - assertEquals(new Rect(50, 100, 150, 150), app.startBounds); - assertEquals(mMockLeash, app.leash); - assertEquals(mMockThumbnailLeash, app.startLeash); - assertEquals(false, app.isTranslucent); - verify(mMockTransaction).setPosition( - mMockLeash, app.position.x + app.startBounds.left - app.screenSpaceBounds.left, - app.position.y + app.startBounds.top - app.screenSpaceBounds.top); - verify(mMockTransaction).setWindowCrop( - mMockLeash, app.startBounds.width(), app.startBounds.height()); - verify(mMockTransaction).setPosition(mMockThumbnailLeash, 0, 0); - verify(mMockTransaction).setWindowCrop(mMockThumbnailLeash, app.startBounds.width(), - app.startBounds.height()); - - finishedCaptor.getValue().onAnimationFinished(); - verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_WINDOW_ANIMATION), - eq(record.mAdapter)); - verify(mThumbnailFinishedCallback).onAnimationFinished( - eq(ANIMATION_TYPE_WINDOW_ANIMATION), eq(record.mThumbnailAdapter)); - } finally { - mDisplayContent.mChangingContainers.clear(); - } - } - - @Test - public void testWallpaperIncluded_expectTarget() throws Exception { - final WindowToken wallpaperWindowToken = new WallpaperWindowToken(mWm, mock(IBinder.class), - true, mDisplayContent, true /* ownerCanManageAppTokens */); - spyOn(mDisplayContent.mWallpaperController); - doReturn(true).when(mDisplayContent.mWallpaperController).isWallpaperVisible(); - final WindowState win = createTestWindow(); - mDisplayContent.mOpeningApps.add(win.mActivityRecord); - try { - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_ACTIVITY_OPEN), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAppsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, wallpapersCaptor.getValue().length); - } finally { - mDisplayContent.mOpeningApps.clear(); - } - } - - @Test - public void testWallpaperAnimatorCanceled_expectAnimationKeepsRunning() throws Exception { - final WindowToken wallpaperWindowToken = new WallpaperWindowToken(mWm, mock(IBinder.class), - true, mDisplayContent, true /* ownerCanManageAppTokens */); - spyOn(mDisplayContent.mWallpaperController); - doReturn(true).when(mDisplayContent.mWallpaperController).isWallpaperVisible(); - final WindowState win = createTestWindow(); - mDisplayContent.mOpeningApps.add(win.mActivityRecord); - try { - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, - new Point(50, 100), null, new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_ACTIVITY_OPEN); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAPpsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_ACTIVITY_OPEN), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAPpsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, wallpapersCaptor.getValue().length); - - // Cancel the wallpaper window animator and ensure the runner is not canceled - wallpaperWindowToken.cancelAnimation(); - verify(mMockRunner, never()).onAnimationCancelled(); - } finally { - mDisplayContent.mOpeningApps.clear(); - } - } - - @Test - public void testNonAppIncluded_keygaurdGoingAway() throws Exception { - final WindowState win = createTestWindow(); - mDisplayContent.mOpeningApps.add(win.mActivityRecord); - // Add overlay window hidden by the keyguard. - final WindowState overlayWin = createAppOverlayWindow(); - overlayWin.hide(false /* doAnimation */, false /* requestAnim */); - try { - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, new Point(50, 100), null, - new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_KEYGUARD_GOING_AWAY); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_KEYGUARD_GOING_AWAY), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAppsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, appsCaptor.getValue().length); - final RemoteAnimationTarget app = appsCaptor.getValue()[0]; - assertEquals(new Point(50, 100), app.position); - assertEquals(new Rect(50, 100, 150, 150), app.sourceContainerBounds); - assertEquals(win.mActivityRecord.getPrefixOrderIndex(), app.prefixOrderIndex); - assertEquals(win.mActivityRecord.getTask().mTaskId, app.taskId); - assertEquals(mMockLeash, app.leash); - assertEquals(false, app.isTranslucent); - verify(mMockTransaction).setPosition(mMockLeash, app.position.x, app.position.y); - verify(mMockTransaction).setWindowCrop(mMockLeash, 100, 50); - - finishedCaptor.getValue().onAnimationFinished(); - verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), - eq(adapter)); - assertEquals(1, nonAppsCaptor.getValue().length); - } finally { - mDisplayContent.mOpeningApps.clear(); - } - } - - @Test - public void testNonAppIncluded_keygaurdGoingAwayToWallpaper() throws Exception { - final WindowToken wallpaperWindowToken = new WallpaperWindowToken(mWm, mock(IBinder.class), - true, mDisplayContent, true /* ownerCanManageAppTokens */); - spyOn(mDisplayContent.mWallpaperController); - doReturn(true).when(mDisplayContent.mWallpaperController).isWallpaperVisible(); - final WindowState win = createTestWindow(); - mDisplayContent.mOpeningApps.add(win.mActivityRecord); - // Add overlay window hidden by the keyguard. - final WindowState overlayWin = createAppOverlayWindow(); - overlayWin.hide(false /* doAnimation */, false /* requestAnim */); - try { - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, new Point(50, 100), null, - new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER); - waitUntilWindowAnimatorIdle(); - final ArgumentCaptor<RemoteAnimationTarget[]> appsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> wallpapersCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER), - appsCaptor.capture(), wallpapersCaptor.capture(), nonAppsCaptor.capture(), - finishedCaptor.capture()); - assertEquals(1, wallpapersCaptor.getValue().length); - assertEquals(1, nonAppsCaptor.getValue().length); - } finally { - mDisplayContent.mOpeningApps.clear(); - } - } - - @Test - public void testNonAppTarget_sendNavBar() throws Exception { - final int transit = TRANSIT_OLD_TASK_OPEN; - final AnimationAdapter adapter = setupForNonAppTargetNavBar(transit, true); - - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - final ArgumentCaptor<IRemoteAnimationFinishedCallback> finishedCaptor = - ArgumentCaptor.forClass(IRemoteAnimationFinishedCallback.class); - verify(mMockRunner).onAnimationStart(eq(transit), any(), any(), - nonAppsCaptor.capture(), finishedCaptor.capture()); - boolean containNavTarget = false; - for (int i = 0; i < nonAppsCaptor.getValue().length; i++) { - if (nonAppsCaptor.getValue()[0].windowType == TYPE_NAVIGATION_BAR) { - containNavTarget = true; - break; - } - } - assertTrue(containNavTarget); - assertEquals(1, mController.mPendingNonAppAnimations.size()); - final NonAppWindowAnimationAdapter nonAppAdapter = - mController.mPendingNonAppAnimations.get(0); - spyOn(nonAppAdapter.getLeashFinishedCallback()); - - finishedCaptor.getValue().onAnimationFinished(); - verify(mFinishedCallback).onAnimationFinished(eq(ANIMATION_TYPE_APP_TRANSITION), - eq(adapter)); - verify(nonAppAdapter.getLeashFinishedCallback()) - .onAnimationFinished(nonAppAdapter.getLastAnimationType(), nonAppAdapter); - } - - @Test - public void testNonAppTarget_notSendNavBar_notAttachToApp() throws Exception { - final int transit = TRANSIT_OLD_TASK_OPEN; - setupForNonAppTargetNavBar(transit, false); - - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - verify(mMockRunner).onAnimationStart(eq(transit), - any(), any(), nonAppsCaptor.capture(), any()); - for (int i = 0; i < nonAppsCaptor.getValue().length; i++) { - if (nonAppsCaptor.getValue()[0].windowType == TYPE_NAVIGATION_BAR) { - fail("Non-app animation target must not contain navbar"); - } - } - } - - @Test - public void testNonAppTarget_notSendNavBar_controlledByFadeRotation() throws Exception { - final AsyncRotationController mockController = - mock(AsyncRotationController.class); - doReturn(mockController).when(mDisplayContent).getAsyncRotationController(); - final int transit = TRANSIT_OLD_TASK_OPEN; - setupForNonAppTargetNavBar(transit, true); - - final ArgumentCaptor<RemoteAnimationTarget[]> nonAppsCaptor = - ArgumentCaptor.forClass(RemoteAnimationTarget[].class); - verify(mMockRunner).onAnimationStart(eq(transit), - any(), any(), nonAppsCaptor.capture(), any()); - for (int i = 0; i < nonAppsCaptor.getValue().length; i++) { - if (nonAppsCaptor.getValue()[0].windowType == TYPE_NAVIGATION_BAR) { - fail("Non-app animation target must not contain navbar"); - } - } - } - - private AnimationAdapter setupForNonAppTargetNavBar(int transit, boolean shouldAttachNavBar) { - final WindowState win = createTestWindow(); - mDisplayContent.mOpeningApps.add(win.mActivityRecord); - final WindowState navBar = newWindowBuilder("NavigationBar", TYPE_NAVIGATION_BAR).build(); - mDisplayContent.getDisplayPolicy().addWindowLw(navBar, navBar.mAttrs); - final DisplayPolicy policy = mDisplayContent.getDisplayPolicy(); - spyOn(policy); - doReturn(shouldAttachNavBar).when(policy).shouldAttachNavBarToAppDuringTransition(); - - final AnimationAdapter adapter = mController.createRemoteAnimationRecord( - win.mActivityRecord, new Point(50, 100), null, - new Rect(50, 100, 150, 150), null, false).mAdapter; - adapter.startAnimation(mMockLeash, mMockTransaction, ANIMATION_TYPE_APP_TRANSITION, - mFinishedCallback); - mController.goodToGo(transit); - waitUntilWindowAnimatorIdle(); - return adapter; - } - - private static void verifyNoMoreInteractionsExceptAsBinder(IInterface binder) { - verify(binder, atLeast(0)).asBinder(); - verifyNoMoreInteractions(binder); - } - - private WindowState createTestWindow() { - return newWindowBuilder("testWin", TYPE_BASE_APPLICATION).build(); - } -} |