summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java1
-rw-r--r--services/core/java/com/android/server/wm/AppTransitionController.java12
-rw-r--r--services/core/java/com/android/server/wm/SurfaceAnimator.java28
-rw-r--r--services/core/java/com/android/server/wm/SurfaceFreezer.java303
-rw-r--r--services/core/java/com/android/server/wm/Task.java30
-rw-r--r--services/core/java/com/android/server/wm/TaskFragment.java16
-rw-r--r--services/core/java/com/android/server/wm/WindowContainer.java102
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppChangeTransitionTests.java175
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java40
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java166
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java17
12 files changed, 20 insertions, 872 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index f4870d5548cf..dba2d36718ab 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -5607,7 +5607,6 @@ final class ActivityRecord extends WindowToken {
}
mAtmService.mBackNavigationController.onAppVisibilityChanged(this, visible);
- onChildVisibilityRequested(visible);
final DisplayContent displayContent = getDisplayContent();
displayContent.mOpeningApps.remove(this);
diff --git a/services/core/java/com/android/server/wm/AppTransitionController.java b/services/core/java/com/android/server/wm/AppTransitionController.java
index 0a2f6852f6e6..d5fe056a2ba4 100644
--- a/services/core/java/com/android/server/wm/AppTransitionController.java
+++ b/services/core/java/com/android/server/wm/AppTransitionController.java
@@ -80,7 +80,6 @@ import android.os.Trace;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Pair;
-import android.view.Display;
import android.view.RemoteAnimationAdapter;
import android.view.RemoteAnimationDefinition;
import android.view.WindowManager;
@@ -252,7 +251,6 @@ public class AppTransitionController {
// Check if there is any override
if (!overrideWithTaskFragmentRemoteAnimation(transit, activityTypes)) {
// Unfreeze the windows that were previously frozen for TaskFragment animation.
- unfreezeEmbeddedChangingWindows();
overrideWithRemoteAnimationIfSet(animLpActivity, transit, activityTypes);
}
@@ -545,16 +543,6 @@ public class AppTransitionController {
: null;
}
- private void unfreezeEmbeddedChangingWindows() {
- final ArraySet<WindowContainer> changingContainers = mDisplayContent.mChangingContainers;
- for (int i = changingContainers.size() - 1; i >= 0; i--) {
- final WindowContainer wc = changingContainers.valueAt(i);
- if (wc.isEmbedded()) {
- wc.mSurfaceFreezer.unfreeze(wc.getSyncTransaction());
- }
- }
- }
-
private boolean transitionMayContainNonAppWindows(@TransitionOldType int transit) {
// We don't want to have the client to animate any non-app windows.
// Having {@code transit} of those types doesn't mean it will contain non-app windows, but
diff --git a/services/core/java/com/android/server/wm/SurfaceAnimator.java b/services/core/java/com/android/server/wm/SurfaceAnimator.java
index d7b6d96c781d..3dfff39e9b68 100644
--- a/services/core/java/com/android/server/wm/SurfaceAnimator.java
+++ b/services/core/java/com/android/server/wm/SurfaceAnimator.java
@@ -60,8 +60,6 @@ public class SurfaceAnimator {
@VisibleForTesting
SurfaceControl mLeash;
@VisibleForTesting
- SurfaceFreezer.Snapshot mSnapshot;
- @VisibleForTesting
final Animatable mAnimatable;
@VisibleForTesting
final OnAnimationFinishedCallback mInnerAnimationFinishedCallback;
@@ -165,7 +163,7 @@ public class SurfaceAnimator {
@AnimationType int type,
@Nullable OnAnimationFinishedCallback animationFinishedCallback,
@Nullable Runnable animationCancelledCallback,
- @Nullable AnimationAdapter snapshotAnim, @Nullable SurfaceFreezer freezer) {
+ @Nullable AnimationAdapter snapshotAnim) {
cancelAnimation(t, true /* restarting */, true /* forwardCancel */);
mAnimation = anim;
mAnimationType = type;
@@ -177,7 +175,6 @@ public class SurfaceAnimator {
cancelAnimation();
return;
}
- mLeash = freezer != null ? freezer.takeLeashForAnimation() : null;
if (mLeash == null) {
mLeash = createAnimationLeash(mAnimatable, surface, t, type,
mAnimatable.getSurfaceWidth(), mAnimatable.getSurfaceHeight(), 0 /* x */,
@@ -192,21 +189,13 @@ public class SurfaceAnimator {
mAnimation.dump(pw, "");
ProtoLog.d(WM_DEBUG_ANIM, "Animation start for %s, anim=%s", mAnimatable, sw);
}
- if (snapshotAnim != null) {
- mSnapshot = freezer.takeSnapshotForAnimation();
- if (mSnapshot == null) {
- Slog.e(TAG, "No snapshot target to start animation on for " + mAnimatable);
- return;
- }
- mSnapshot.startAnimation(t, snapshotAnim, type);
- }
setAnimatorPendingState(t);
}
void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden,
@AnimationType int type) {
startAnimation(t, anim, hidden, type, null /* animationFinishedCallback */,
- null /* animationCancelledCallback */, null /* snapshotAnim */, null /* freezer */);
+ null /* animationCancelledCallback */, null /* snapshotAnim */);
}
/** Indicates that there are surface operations in the pending transaction. */
@@ -317,7 +306,6 @@ public class SurfaceAnimator {
final OnAnimationFinishedCallback animationFinishedCallback =
mSurfaceAnimationFinishedCallback;
final Runnable animationCancelledCallback = mAnimationCancelledCallback;
- final SurfaceFreezer.Snapshot snapshot = mSnapshot;
reset(t, false);
if (animation != null) {
if (forwardCancel) {
@@ -337,9 +325,6 @@ public class SurfaceAnimator {
}
if (forwardCancel) {
- if (snapshot != null) {
- snapshot.cancelAnimation(t, false /* restarting */);
- }
if (leash != null) {
t.remove(leash);
mService.scheduleAnimationLocked();
@@ -352,12 +337,6 @@ public class SurfaceAnimator {
mAnimation = null;
mSurfaceAnimationFinishedCallback = null;
mAnimationType = ANIMATION_TYPE_NONE;
- final SurfaceFreezer.Snapshot snapshot = mSnapshot;
- mSnapshot = null;
- if (snapshot != null) {
- // Reset the mSnapshot reference before calling the callback to prevent circular reset.
- snapshot.cancelAnimation(t, !destroyLeash);
- }
if (mLeash == null) {
return;
}
@@ -597,8 +576,7 @@ public class SurfaceAnimator {
void commitPendingTransaction();
/**
- * Called when the animation leash is created. Note that this is also called by
- * {@link SurfaceFreezer}, so this doesn't mean we're about to start animating.
+ * Called when the animation leash is created.
*
* @param t The transaction to use to apply any necessary changes.
* @param leash The leash that was created.
diff --git a/services/core/java/com/android/server/wm/SurfaceFreezer.java b/services/core/java/com/android/server/wm/SurfaceFreezer.java
deleted file mode 100644
index e126ed65d508..000000000000
--- a/services/core/java/com/android/server/wm/SurfaceFreezer.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright (C) 2020 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_SHOW_TRANSACTIONS;
-import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_SCREEN_ROTATION;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.graphics.GraphicBuffer;
-import android.graphics.PixelFormat;
-import android.graphics.Point;
-import android.graphics.Rect;
-import android.hardware.HardwareBuffer;
-import android.util.Slog;
-import android.view.SurfaceControl;
-import android.window.ScreenCapture;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.protolog.ProtoLog;
-
-/**
- * This class handles "freezing" of an Animatable. The Animatable in question should implement
- * Freezable.
- *
- * The point of this is to enable WindowContainers to each be capable of freezing themselves.
- * Freezing means taking a snapshot and placing it above everything in the sub-hierarchy.
- * The "placing above" requires that a parent surface be inserted above the target surface so that
- * the target surface and the snapshot are siblings.
- *
- * The overall flow for a transition using this would be:
- * 1. Set transition and record animatable in mChangingApps
- * 2. Call {@link #freeze} to set-up the leashes and cover with a snapshot.
- * 3. When transition participants are ready, start SurfaceAnimator with this as a parameter
- * 4. SurfaceAnimator will then {@link #takeLeashForAnimation} instead of creating another leash.
- * 5. The animation system should eventually clean this up via {@link #unfreeze}.
- */
-class SurfaceFreezer {
-
- private static final String TAG = "SurfaceFreezer";
-
- private final @NonNull Freezable mAnimatable;
- private final @NonNull WindowManagerService mWmService;
- @VisibleForTesting
- SurfaceControl mLeash;
- Snapshot mSnapshot = null;
- final Rect mFreezeBounds = new Rect();
-
- /**
- * @param animatable The object to animate.
- */
- SurfaceFreezer(@NonNull Freezable animatable, @NonNull WindowManagerService service) {
- mAnimatable = animatable;
- mWmService = service;
- }
-
- /**
- * Freeze the target surface. This is done by creating a leash (inserting a parent surface
- * above the target surface) and then taking a snapshot and placing it over the target surface.
- *
- * @param startBounds The original bounds (on screen) of the surface we are snapshotting.
- * @param relativePosition The related position of the snapshot surface to its parent.
- * @param freezeTarget The surface to take snapshot from. If {@code null}, we will take a
- * snapshot from the {@link #mAnimatable} surface.
- */
- void freeze(SurfaceControl.Transaction t, Rect startBounds, Point relativePosition,
- @Nullable SurfaceControl freezeTarget) {
- reset(t);
- mFreezeBounds.set(startBounds);
-
- mLeash = SurfaceAnimator.createAnimationLeash(mAnimatable, mAnimatable.getSurfaceControl(),
- t, ANIMATION_TYPE_SCREEN_ROTATION, startBounds.width(), startBounds.height(),
- relativePosition.x, relativePosition.y, false /* hidden */,
- mWmService.mTransactionFactory);
- mAnimatable.onAnimationLeashCreated(t, mLeash);
-
- freezeTarget = freezeTarget != null ? freezeTarget : mAnimatable.getFreezeSnapshotTarget();
- if (freezeTarget != null) {
- ScreenCapture.ScreenshotHardwareBuffer screenshotBuffer = createSnapshotBufferInner(
- freezeTarget, startBounds);
- final HardwareBuffer buffer = screenshotBuffer == null ? null
- : screenshotBuffer.getHardwareBuffer();
- if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) {
- // This can happen when display is not ready.
- Slog.w(TAG, "Failed to capture screenshot for " + mAnimatable);
- unfreeze(t);
- return;
- }
- mSnapshot = new Snapshot(t, screenshotBuffer, mLeash);
- }
- }
-
- /**
- * Used by {@link SurfaceAnimator}. This "transfers" the leash to be used for animation.
- * By transferring the leash, this will no longer try to clean-up the leash when finished.
- */
- SurfaceControl takeLeashForAnimation() {
- SurfaceControl out = mLeash;
- mLeash = null;
- return out;
- }
-
- /**
- * Used by {@link SurfaceAnimator}. This "transfers" the snapshot leash to be used for
- * animation. By transferring the leash, this will no longer try to clean-up the leash when
- * finished.
- */
- @Nullable
- Snapshot takeSnapshotForAnimation() {
- final Snapshot out = mSnapshot;
- mSnapshot = null;
- return out;
- }
-
- /**
- * Clean-up the snapshot and remove leash. If the leash was taken, this just cleans-up the
- * snapshot.
- */
- void unfreeze(SurfaceControl.Transaction t) {
- unfreezeInner(t);
- mAnimatable.onUnfrozen();
- }
-
- private void unfreezeInner(SurfaceControl.Transaction t) {
- if (mSnapshot != null) {
- mSnapshot.cancelAnimation(t, false /* restarting */);
- mSnapshot = null;
- }
- if (mLeash == null) {
- return;
- }
- SurfaceControl leash = mLeash;
- mLeash = null;
- final boolean scheduleAnim = SurfaceAnimator.removeLeash(t, mAnimatable, leash,
- true /* destroy */);
- if (scheduleAnim) {
- mWmService.scheduleAnimationLocked();
- }
- }
-
- /** Resets the snapshot before taking another one if the animation hasn't been started yet. */
- private void reset(SurfaceControl.Transaction t) {
- // Those would have been taken by the SurfaceAnimator if the animation has been started, so
- // we can remove the leash directly.
- // No need to reset the mAnimatable leash, as this is called before a new animation leash is
- // created, so another #onAnimationLeashCreated will be called.
- if (mSnapshot != null) {
- mSnapshot.destroy(t);
- mSnapshot = null;
- }
- if (mLeash != null) {
- t.remove(mLeash);
- mLeash = null;
- }
- }
-
- void setLayer(SurfaceControl.Transaction t, int layer) {
- if (mLeash != null) {
- t.setLayer(mLeash, layer);
- }
- }
-
- void setRelativeLayer(SurfaceControl.Transaction t, SurfaceControl relativeTo, int layer) {
- if (mLeash != null) {
- t.setRelativeLayer(mLeash, relativeTo, layer);
- }
- }
-
- boolean hasLeash() {
- return mLeash != null;
- }
-
- private static ScreenCapture.ScreenshotHardwareBuffer createSnapshotBuffer(
- @NonNull SurfaceControl target, @Nullable Rect bounds) {
- Rect cropBounds = null;
- if (bounds != null) {
- cropBounds = new Rect(bounds);
- cropBounds.offsetTo(0, 0);
- }
- ScreenCapture.LayerCaptureArgs captureArgs =
- new ScreenCapture.LayerCaptureArgs.Builder(target)
- .setSourceCrop(cropBounds)
- .setCaptureSecureLayers(true)
- .setAllowProtected(true)
- .build();
- return ScreenCapture.captureLayers(captureArgs);
- }
-
- @VisibleForTesting
- ScreenCapture.ScreenshotHardwareBuffer createSnapshotBufferInner(
- SurfaceControl target, Rect bounds) {
- return createSnapshotBuffer(target, bounds);
- }
-
- @VisibleForTesting
- GraphicBuffer createFromHardwareBufferInner(
- ScreenCapture.ScreenshotHardwareBuffer screenshotBuffer) {
- return GraphicBuffer.createFromHardwareBuffer(screenshotBuffer.getHardwareBuffer());
- }
-
- class Snapshot {
- private SurfaceControl mSurfaceControl;
- private AnimationAdapter mAnimation;
-
- /**
- * @param t Transaction to create the thumbnail in.
- * @param screenshotBuffer A thumbnail or placeholder for thumbnail to initialize with.
- */
- Snapshot(SurfaceControl.Transaction t,
- ScreenCapture.ScreenshotHardwareBuffer screenshotBuffer, SurfaceControl parent) {
- GraphicBuffer graphicBuffer = createFromHardwareBufferInner(screenshotBuffer);
-
- mSurfaceControl = mAnimatable.makeAnimationLeash()
- .setName("snapshot anim: " + mAnimatable.toString())
- .setFormat(PixelFormat.TRANSLUCENT)
- .setParent(parent)
- .setSecure(screenshotBuffer.containsSecureLayers())
- .setCallsite("SurfaceFreezer.Snapshot")
- .setBLASTLayer()
- .build();
-
- ProtoLog.i(WM_SHOW_TRANSACTIONS, " THUMBNAIL %s: CREATE", mSurfaceControl);
-
- t.setBuffer(mSurfaceControl, graphicBuffer);
- t.setColorSpace(mSurfaceControl, screenshotBuffer.getColorSpace());
- t.show(mSurfaceControl);
-
- // We parent the thumbnail to the container, and just place it on top of anything else
- // in the container.
- t.setLayer(mSurfaceControl, Integer.MAX_VALUE);
- }
-
- void destroy(SurfaceControl.Transaction t) {
- if (mSurfaceControl == null) {
- return;
- }
- t.remove(mSurfaceControl);
- mSurfaceControl = null;
- }
-
- /**
- * Starts an animation.
- *
- * @param anim The object that bridges the controller, {@link SurfaceAnimator}, with the
- * component responsible for running the animation. It runs the animation with
- * {@link AnimationAdapter#startAnimation} once the hierarchy with
- * the Leash has been set up.
- */
- void startAnimation(SurfaceControl.Transaction t, AnimationAdapter anim, int type) {
- cancelAnimation(t, true /* restarting */);
- mAnimation = anim;
- if (mSurfaceControl == null) {
- cancelAnimation(t, false /* restarting */);
- return;
- }
- mAnimation.startAnimation(mSurfaceControl, t, type, (typ, ani) -> { });
- }
-
- /**
- * Cancels the animation, and resets the leash.
- *
- * @param t The transaction to use for all cancelling surface operations.
- * @param restarting Whether we are restarting the animation.
- */
- void cancelAnimation(SurfaceControl.Transaction t, boolean restarting) {
- final SurfaceControl leash = mSurfaceControl;
- final AnimationAdapter animation = mAnimation;
- mAnimation = null;
- if (animation != null) {
- animation.onAnimationCancelled(leash);
- }
- if (!restarting) {
- destroy(t);
- }
- }
- }
-
- /** freezable */
- public interface Freezable extends SurfaceAnimator.Animatable {
- /**
- * @return The surface to take a snapshot of. If this returns {@code null}, no snapshot
- * will be generated (but the rest of the freezing logic will still happen).
- */
- @Nullable SurfaceControl getFreezeSnapshotTarget();
-
- /** Called when the {@link #unfreeze(SurfaceControl.Transaction)} is called. */
- void onUnfrozen();
- }
-}
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index c6136f316c3e..f2f926ac952c 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -52,11 +52,9 @@ import static android.view.SurfaceControl.METADATA_TASK_ID;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES;
-import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_APP_CRASHED;
import static android.view.WindowManager.TRANSIT_NONE;
-import static android.view.WindowManager.TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
@@ -75,7 +73,6 @@ import static com.android.server.wm.ActivityRecord.TRANSFER_SPLASH_SCREEN_COPYIN
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_RECENTS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_SWITCH;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_TRANSITION;
-import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_USER_LEAVING;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_CLEANUP;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_RECENTS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_SWITCH;
@@ -161,13 +158,11 @@ import android.os.Trace;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.voice.IVoiceInteractionSession;
-import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.view.DisplayInfo;
import android.view.InsetsState;
-import android.view.RemoteAnimationAdapter;
import android.view.SurfaceControl;
import android.view.WindowInsets;
import android.view.WindowManager;
@@ -2345,31 +2340,8 @@ class Task extends TaskFragment {
}
@VisibleForTesting
- Point getLastSurfaceSize() {
- return mLastSurfaceSize;
- }
-
- @VisibleForTesting
boolean isInChangeTransition() {
- return mSurfaceFreezer.hasLeash() || AppTransition.isChangeTransitOld(mTransit);
- }
-
- @Override
- public SurfaceControl getFreezeSnapshotTarget() {
- if (!mDisplayContent.mAppTransition.containsTransitRequest(TRANSIT_CHANGE)) {
- return null;
- }
- // Skip creating snapshot if this transition is controlled by a remote animator which
- // doesn't need it.
- final ArraySet<Integer> activityTypes = new ArraySet<>();
- activityTypes.add(getActivityType());
- final RemoteAnimationAdapter adapter =
- mDisplayContent.mAppTransitionController.getRemoteAnimationOverride(
- this, TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE, activityTypes);
- if (adapter != null && !adapter.getChangeNeedsSnapshot()) {
- return null;
- }
- return getSurfaceControl();
+ return AppTransition.isChangeTransitOld(mTransit);
}
@Override
diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java
index fc7437b95e03..148704ca737a 100644
--- a/services/core/java/com/android/server/wm/TaskFragment.java
+++ b/services/core/java/com/android/server/wm/TaskFragment.java
@@ -2758,7 +2758,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
// We only want to update for organized TaskFragment. Task will handle itself.
return;
}
- if (mSurfaceControl == null || mSurfaceAnimator.hasLeash() || mSurfaceFreezer.hasLeash()) {
+ if (mSurfaceControl == null || mSurfaceAnimator.hasLeash()) {
return;
}
@@ -2900,20 +2900,6 @@ class TaskFragment extends WindowContainer<WindowContainer> {
return task != null && !task.isDragResizing() && super.canStartChangeTransition();
}
- /**
- * Returns {@code true} if the starting bounds of the closing organized TaskFragment is
- * recorded. Otherwise, return {@code false}.
- */
- boolean setClosingChangingStartBoundsIfNeeded() {
- if (isOrganizedTaskFragment() && mDisplayContent != null
- && mDisplayContent.mChangingContainers.remove(this)) {
- mDisplayContent.mClosingChangingContainers.put(
- this, new Rect(mSurfaceFreezer.mFreezeBounds));
- return true;
- }
- return false;
- }
-
@Override
boolean isSyncFinished(BLASTSyncEngine.SyncGroup group) {
return super.isSyncFinished(group) && isReadyToTransit();
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index e761e024b3ca..f9db64168316 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -138,7 +138,7 @@ import java.util.function.Predicate;
* changes are made to this class.
*/
class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<E>
- implements Comparable<WindowContainer>, Animatable, SurfaceFreezer.Freezable,
+ implements Comparable<WindowContainer>, Animatable,
InsetsControlTarget {
private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowContainer" : TAG_WM;
@@ -226,7 +226,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
@Nullable
private SurfaceControl mAnimationLeash;
- final SurfaceFreezer mSurfaceFreezer;
protected final WindowManagerService mWmService;
final TransitionController mTransitionController;
@@ -361,7 +360,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
mTransitionController = mWmService.mAtmService.getTransitionController();
mSyncTransaction = wms.mTransactionFactory.get();
mSurfaceAnimator = new SurfaceAnimator(this, this::onAnimationFinished, wms);
- mSurfaceFreezer = new SurfaceFreezer(this, wms);
}
/**
@@ -908,7 +906,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
final DisplayContent dc = getDisplayContent();
if (dc != null) {
dc.mClosingChangingContainers.remove(this);
- mSurfaceFreezer.unfreeze(getSyncTransaction());
}
while (!mChildren.isEmpty()) {
final E child = mChildren.getLast();
@@ -1124,9 +1121,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
// Cancel any change transition queued-up for this container on the old display when
// this container is moved from the old display.
mDisplayContent.mClosingChangingContainers.remove(this);
- if (mDisplayContent.mChangingContainers.remove(this)) {
- mSurfaceFreezer.unfreeze(getSyncTransaction());
- }
+ mDisplayContent.mChangingContainers.remove(this);
}
mDisplayContent = dc;
if (dc != null && dc != this && mPendingTransaction != null) {
@@ -1434,33 +1429,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
return setVisibleRequested(newVisReq);
}
- /**
- * Called when the visibility of a child is asked to change. This is before visibility actually
- * changes (eg. a transition animation might play out first).
- */
- void onChildVisibilityRequested(boolean visible) {
- // If we are losing visibility, then a snapshot isn't necessary and we are no-longer
- // part of a change transition.
- if (!visible) {
- boolean skipUnfreeze = false;
- if (asTaskFragment() != null) {
- // If the organized TaskFragment is closing while resizing, we want to keep track of
- // its starting bounds to make sure the animation starts at the correct position.
- // This should be called before unfreeze() because we record the starting bounds
- // in SurfaceFreezer.
- skipUnfreeze = asTaskFragment().setClosingChangingStartBoundsIfNeeded();
- }
-
- if (!skipUnfreeze) {
- mSurfaceFreezer.unfreeze(getSyncTransaction());
- }
- }
- WindowContainer parent = getParent();
- if (parent != null) {
- parent.onChildVisibilityRequested(visible);
- }
- }
-
/** Whether this window is closing while resizing. */
boolean isClosingWhenResizing() {
return mDisplayContent != null
@@ -1545,9 +1513,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
}
void onAppTransitionDone() {
- if (mSurfaceFreezer.hasLeash()) {
- mSurfaceFreezer.unfreeze(getSyncTransaction());
- }
for (int i = mChildren.size() - 1; i >= 0; --i) {
final WindowContainer wc = mChildren.get(i);
wc.onAppTransitionDone();
@@ -2772,15 +2737,9 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
}
protected void setLayer(Transaction t, int layer) {
- if (mSurfaceFreezer.hasLeash()) {
- // When the freezer has created animation leash parent for the window, set the layer
- // there instead.
- mSurfaceFreezer.setLayer(t, layer);
- } else {
- // Route through surface animator to accommodate that our surface control might be
- // attached to the leash, and leash is attached to parent container.
- mSurfaceAnimator.setLayer(t, layer);
- }
+ // Route through surface animator to accommodate that our surface control might be
+ // attached to the leash, and leash is attached to parent container.
+ mSurfaceAnimator.setLayer(t, layer);
}
int getLastLayer() {
@@ -2792,20 +2751,14 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
}
protected void setRelativeLayer(Transaction t, SurfaceControl relativeTo, int layer) {
- if (mSurfaceFreezer.hasLeash()) {
- // When the freezer has created animation leash parent for the window, set the layer
- // there instead.
- mSurfaceFreezer.setRelativeLayer(t, relativeTo, layer);
- } else {
- // Route through surface animator to accommodate that our surface control might be
- // attached to the leash, and leash is attached to parent container.
- mSurfaceAnimator.setRelativeLayer(t, relativeTo, layer);
- }
+ // Route through surface animator to accommodate that our surface control might be
+ // attached to the leash, and leash is attached to parent container.
+ mSurfaceAnimator.setRelativeLayer(t, relativeTo, layer);
}
protected void reparentSurfaceControl(Transaction t, SurfaceControl newParent) {
// Don't reparent active leashes since the animator won't know about the change.
- if (mSurfaceFreezer.hasLeash() || mSurfaceAnimator.hasLeash()) return;
+ if (mSurfaceAnimator.hasLeash()) return;
t.reparent(getSurfaceControl(), newParent);
}
@@ -3043,7 +2996,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
// TODO: This should use isVisible() but because isVisible has a really weird meaning at
// the moment this doesn't work for all animatable window containers.
mSurfaceAnimator.startAnimation(t, anim, hidden, type, animationFinishedCallback,
- animationCancelledCallback, snapshotAnim, mSurfaceFreezer);
+ animationCancelledCallback, snapshotAnim);
}
void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden,
@@ -3065,7 +3018,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
void cancelAnimation() {
doAnimationFinished(mSurfaceAnimator.getAnimationType(), mSurfaceAnimator.getAnimation());
mSurfaceAnimator.cancelAnimation();
- mSurfaceFreezer.unfreeze(getSyncTransaction());
}
/** Whether we can start change transition with this window and current display status. */
@@ -3096,7 +3048,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
}
/**
- * Initializes a change transition. See {@link SurfaceFreezer} for more information.
+ * Initializes a change transition.
*
* For now, this will only be called for the following cases:
* 1. {@link Task} is changing windowing mode between fullscreen and freeform.
@@ -3108,8 +3060,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
* use case.
*
* @param startBounds The original bounds (on screen) of the surface we are snapshotting.
- * @param freezeTarget The surface to take snapshot from. If {@code null}, we will take a
- * snapshot from {@link #getFreezeSnapshotTarget()}.
*/
void initializeChangeTransition(Rect startBounds, @Nullable SurfaceControl freezeTarget) {
if (mDisplayContent.mTransitionController.isShellTransitionsEnabled()) {
@@ -3121,7 +3071,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
// Calculate the relative position in parent container.
final Rect parentBounds = getParent().getBounds();
mTmpPoint.set(startBounds.left - parentBounds.left, startBounds.top - parentBounds.top);
- mSurfaceFreezer.freeze(getSyncTransaction(), startBounds, mTmpPoint, freezeTarget);
}
void initializeChangeTransition(Rect startBounds) {
@@ -3133,23 +3082,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
}
@Override
- public SurfaceControl getFreezeSnapshotTarget() {
- // Only allow freezing if this window is in a TRANSIT_CHANGE
- if (!mDisplayContent.mAppTransition.containsTransitRequest(TRANSIT_CHANGE)
- || !mDisplayContent.mChangingContainers.contains(this)) {
- return null;
- }
- return getSurfaceControl();
- }
-
- @Override
- public void onUnfrozen() {
- if (mDisplayContent != null) {
- mDisplayContent.mChangingContainers.remove(this);
- }
- }
-
- @Override
public Builder makeAnimationLeash() {
return makeSurface().setContainerLayer();
}
@@ -3278,7 +3210,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
this, mTmpPoint, localBounds, screenBounds, closingStartBounds,
showBackdrop, false /* shouldCreateSnapshot */);
} else {
- final Rect startBounds = isChanging ? mSurfaceFreezer.mFreezeBounds : null;
+ final Rect startBounds = null;
adapters = controller.createRemoteAnimationRecord(
this, mTmpPoint, localBounds, screenBounds, startBounds, showBackdrop);
}
@@ -3297,16 +3229,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
mTmpRect.offsetTo(mTmpPoint.x, mTmpPoint.y);
final AnimationAdapter adapter = new LocalAnimationAdapter(
- new WindowChangeAnimationSpec(mSurfaceFreezer.mFreezeBounds, mTmpRect,
+ new WindowChangeAnimationSpec(null /* startBounds */, mTmpRect,
displayInfo, durationScale, true /* isAppAnimation */,
false /* isThumbnail */),
getSurfaceAnimationRunner());
- final AnimationAdapter thumbnailAdapter = mSurfaceFreezer.mSnapshot != null
- ? new LocalAnimationAdapter(new WindowChangeAnimationSpec(
- mSurfaceFreezer.mFreezeBounds, mTmpRect, displayInfo, durationScale,
- true /* isAppAnimation */, true /* isThumbnail */), getSurfaceAnimationRunner())
- : null;
+ final AnimationAdapter thumbnailAdapter = null;
resultAdapters = new Pair<>(adapter, thumbnailAdapter);
mTransit = transit;
mTransitFlags = getDisplayContent().mAppTransition.getTransitFlags();
@@ -3730,7 +3658,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
*/
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PROTECTED)
void updateSurfacePosition(Transaction t) {
- if (mSurfaceControl == null || mSurfaceAnimator.hasLeash() || mSurfaceFreezer.hasLeash()) {
+ if (mSurfaceControl == null || mSurfaceAnimator.hasLeash()) {
return;
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppChangeTransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/AppChangeTransitionTests.java
deleted file mode 100644
index 169968c75fc5..000000000000
--- a/services/tests/wmtests/src/com/android/server/wm/AppChangeTransitionTests.java
+++ /dev/null
@@ -1,175 +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 android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
-import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
-import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
-import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
-import static android.view.WindowManager.TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import android.os.IBinder;
-import android.platform.test.annotations.Presubmit;
-import android.view.Display;
-import android.view.IRemoteAnimationFinishedCallback;
-import android.view.IRemoteAnimationRunner;
-import android.view.RemoteAnimationAdapter;
-import android.view.RemoteAnimationDefinition;
-import android.view.RemoteAnimationTarget;
-import android.view.WindowManager;
-
-import androidx.test.filters.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Tests for change transitions
- *
- * Build/Install/Run:
- * atest WmTests:AppChangeTransitionTests
- */
-@SmallTest
-@Presubmit
-@RunWith(WindowTestRunner.class)
-public class AppChangeTransitionTests extends WindowTestsBase {
-
- private Task mTask;
- private ActivityRecord mActivity;
-
- public void setUpOnDisplay(DisplayContent dc) {
- mActivity = createActivityRecord(dc, WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_STANDARD);
- mTask = mActivity.getTask();
-
- // Set a remote animator with snapshot disabled. Snapshots don't work in wmtests.
- RemoteAnimationDefinition definition = new RemoteAnimationDefinition();
- RemoteAnimationAdapter adapter =
- new RemoteAnimationAdapter(new TestRemoteAnimationRunner(), 10, 1, false);
- definition.addRemoteAnimation(TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE, adapter);
- dc.registerRemoteAnimations(definition);
- }
-
- class TestRemoteAnimationRunner implements IRemoteAnimationRunner {
- @Override
- public void onAnimationStart(@WindowManager.TransitionOldType int transit,
- RemoteAnimationTarget[] apps,
- RemoteAnimationTarget[] wallpapers,
- RemoteAnimationTarget[] nonApps,
- IRemoteAnimationFinishedCallback finishedCallback) {
- for (RemoteAnimationTarget target : apps) {
- assertNotNull(target.startBounds);
- }
- try {
- finishedCallback.onAnimationFinished();
- } catch (Exception e) {
- throw new RuntimeException("Something went wrong");
- }
- }
-
- @Override
- public void onAnimationCancelled() {
- }
-
- @Override
- public IBinder asBinder() {
- return null;
- }
- }
-
- @Test
- public void testModeChangeRemoteAnimatorNoSnapshot() {
- // setup currently defaults to no snapshot.
- setUpOnDisplay(mDisplayContent);
-
- mTask.setWindowingMode(WINDOWING_MODE_FREEFORM);
- assertEquals(1, mDisplayContent.mChangingContainers.size());
-
- // Verify we are in a change transition, but without a snapshot.
- // Though, the test will actually have crashed by now if a snapshot is attempted.
- assertNull(mTask.mSurfaceFreezer.mSnapshot);
- assertTrue(mTask.isInChangeTransition());
-
- waitUntilHandlersIdle();
- mActivity.removeImmediately();
- }
-
- @Test
- public void testCancelPendingChangeOnRemove() {
- // setup currently defaults to no snapshot.
- setUpOnDisplay(mDisplayContent);
-
- mTask.setWindowingMode(WINDOWING_MODE_FREEFORM);
- assertEquals(1, mDisplayContent.mChangingContainers.size());
- assertTrue(mTask.isInChangeTransition());
-
- // Removing the app-token from the display should clean-up the
- // the change leash.
- mDisplayContent.removeAppToken(mActivity.token);
- assertEquals(0, mDisplayContent.mChangingContainers.size());
- assertFalse(mTask.isInChangeTransition());
-
- waitUntilHandlersIdle();
- mActivity.removeImmediately();
- }
-
- @Test
- public void testNoChangeOnOldDisplayWhenMoveDisplay() {
- mDisplayContent.getDefaultTaskDisplayArea().setWindowingMode(WINDOWING_MODE_FULLSCREEN);
- final DisplayContent dc1 = createNewDisplay(Display.STATE_ON);
- dc1.getDefaultTaskDisplayArea().setWindowingMode(WINDOWING_MODE_FREEFORM);
- setUpOnDisplay(dc1);
-
- assertEquals(WINDOWING_MODE_FREEFORM, mTask.getWindowingMode());
-
- // Reparenting to a display with different windowing mode may trigger
- // a change transition internally, but it should be cleaned-up once
- // the display change is complete.
- mTask.reparent(mDisplayContent.getDefaultTaskDisplayArea(), true);
-
- assertEquals(WINDOWING_MODE_FULLSCREEN, mTask.getWindowingMode());
-
- // Make sure the change transition is not the old display
- assertFalse(dc1.mChangingContainers.contains(mTask));
-
- waitUntilHandlersIdle();
- mActivity.removeImmediately();
- }
-
- @Test
- public void testCancelPendingChangeOnHide() {
- // setup currently defaults to no snapshot.
- setUpOnDisplay(mDisplayContent);
-
- mTask.setWindowingMode(WINDOWING_MODE_FREEFORM);
- assertEquals(1, mDisplayContent.mChangingContainers.size());
- assertTrue(mTask.isInChangeTransition());
-
- // Changing visibility should cancel the change transition and become closing
- mActivity.setVisibility(false);
- assertEquals(0, mDisplayContent.mChangingContainers.size());
- assertFalse(mTask.isInChangeTransition());
-
- waitUntilHandlersIdle();
- mActivity.removeImmediately();
- }
-}
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java
index 03d904283e83..8553fbd30ab8 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppTransitionTests.java
@@ -409,7 +409,6 @@ public class AppTransitionTests extends WindowTestsBase {
task.getBounds(taskBounds);
taskFragment.setBounds(0, 0, taskBounds.right / 2, taskBounds.bottom);
spyOn(taskFragment);
- mockSurfaceFreezerSnapshot(taskFragment.mSurfaceFreezer);
assertTrue(mDc.mChangingContainers.isEmpty());
assertFalse(mDc.mAppTransition.isTransitionSet());
@@ -422,7 +421,6 @@ public class AppTransitionTests extends WindowTestsBase {
verify(taskFragment).initializeChangeTransition(activity.getBounds(), activityLeash);
assertTrue(mDc.mChangingContainers.contains(taskFragment));
assertTrue(mDc.mAppTransition.containsTransitRequest(TRANSIT_CHANGE));
- assertEquals(startBounds, taskFragment.mSurfaceFreezer.mFreezeBounds);
}
@Test
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
index 0d9772492e59..ee8d7308f6b3 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
@@ -152,7 +152,6 @@ public class TaskFragmentTest extends WindowTestsBase {
ACTIVITY_TYPE_STANDARD);
task.setBoundsUnchecked(new Rect(0, 0, 1000, 1000));
mTaskFragment = createTaskFragmentWithEmbeddedActivity(task, mOrganizer);
- mockSurfaceFreezerSnapshot(mTaskFragment.mSurfaceFreezer);
final Rect startBounds = new Rect(0, 0, 500, 1000);
final Rect endBounds = new Rect(500, 0, 1000, 1000);
mTaskFragment.setRelativeEmbeddedBounds(startBounds);
@@ -179,44 +178,6 @@ public class TaskFragmentTest extends WindowTestsBase {
}
@Test
- public void testStartChangeTransition_resetSurface() {
- final Task task = createTask(mDisplayContent, WINDOWING_MODE_MULTI_WINDOW,
- ACTIVITY_TYPE_STANDARD);
- task.setBoundsUnchecked(new Rect(0, 0, 1000, 1000));
- mTaskFragment = createTaskFragmentWithEmbeddedActivity(task, mOrganizer);
- doReturn(mTransaction).when(mTaskFragment).getSyncTransaction();
- doReturn(mTransaction).when(mTaskFragment).getPendingTransaction();
- mLeash = mTaskFragment.getSurfaceControl();
- mockSurfaceFreezerSnapshot(mTaskFragment.mSurfaceFreezer);
- final Rect startBounds = new Rect(0, 0, 1000, 1000);
- final Rect endBounds = new Rect(500, 500, 1000, 1000);
- mTaskFragment.setRelativeEmbeddedBounds(startBounds);
- mTaskFragment.recomputeConfiguration();
- doReturn(true).when(mTaskFragment).isVisible();
- doReturn(true).when(mTaskFragment).isVisibleRequested();
-
- clearInvocations(mTransaction);
- final Rect relStartBounds = new Rect(mTaskFragment.getRelativeEmbeddedBounds());
- mTaskFragment.deferOrganizedTaskFragmentSurfaceUpdate();
- mTaskFragment.setRelativeEmbeddedBounds(endBounds);
- mTaskFragment.recomputeConfiguration();
- assertTrue(mTaskFragment.shouldStartChangeTransition(startBounds, relStartBounds));
- mTaskFragment.initializeChangeTransition(startBounds);
- mTaskFragment.continueOrganizedTaskFragmentSurfaceUpdate();
-
- // Surface reset when prepare transition.
- verify(mTransaction).setPosition(mLeash, 0, 0);
- verify(mTransaction).setWindowCrop(mLeash, 0, 0);
-
- clearInvocations(mTransaction);
- mTaskFragment.mSurfaceFreezer.unfreeze(mTransaction);
-
- // Update surface after animation.
- verify(mTransaction).setPosition(mLeash, 500, 500);
- verify(mTransaction).setWindowCrop(mLeash, 500, 500);
- }
-
- @Test
public void testStartChangeTransition_doNotFreezeWhenOnlyMoved() {
final Rect startBounds = new Rect(0, 0, 1000, 1000);
final Rect endBounds = new Rect(startBounds);
@@ -235,7 +196,6 @@ public class TaskFragmentTest extends WindowTestsBase {
@Test
public void testNotOkToAnimate_doNotStartChangeTransition() {
- mockSurfaceFreezerSnapshot(mTaskFragment.mSurfaceFreezer);
final Rect startBounds = new Rect(0, 0, 1000, 1000);
final Rect endBounds = new Rect(500, 500, 1000, 1000);
mTaskFragment.setRelativeEmbeddedBounds(startBounds);
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
index cc447a18758c..001446550304 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java
@@ -32,7 +32,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
-import static android.view.WindowManager.TRANSIT_OLD_TASK_FRAGMENT_CHANGE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.window.DisplayAreaOrganizer.FEATURE_DEFAULT_TASK_CONTAINER;
@@ -64,7 +63,6 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -1014,30 +1012,6 @@ public class WindowContainerTests extends WindowTestsBase {
}
@Test
- public void testOnDisplayChanged_cleanupChanging() {
- final Task task = createTask(mDisplayContent);
- addLocalInsets(task);
- spyOn(task.mSurfaceFreezer);
- mDisplayContent.mChangingContainers.add(task);
-
- // Don't remove the changing transition of this window when it is still the old display.
- // This happens on display info changed.
- task.onDisplayChanged(mDisplayContent);
-
- assertTrue(task.mLocalInsetsSources.size() == 1);
- assertTrue(mDisplayContent.mChangingContainers.contains(task));
- verify(task.mSurfaceFreezer, never()).unfreeze(any());
-
- // Remove the changing transition of this window when it is moved or reparented from the old
- // display.
- final DisplayContent newDc = createNewDisplay();
- task.onDisplayChanged(newDc);
-
- assertFalse(mDisplayContent.mChangingContainers.contains(task));
- verify(task.mSurfaceFreezer).unfreeze(any());
- }
-
- @Test
public void testHandleCompleteDeferredRemoval() {
final DisplayContent displayContent = createNewDisplay();
// Do not reparent activity to default display when removing the display.
@@ -1290,157 +1264,17 @@ public class WindowContainerTests extends WindowTestsBase {
final WindowContainer container = new WindowContainer(mWm);
container.mSurfaceControl = mock(SurfaceControl.class);
final SurfaceAnimator surfaceAnimator = container.mSurfaceAnimator;
- final SurfaceFreezer surfaceFreezer = container.mSurfaceFreezer;
final SurfaceControl relativeParent = mock(SurfaceControl.class);
final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
spyOn(container);
spyOn(surfaceAnimator);
- spyOn(surfaceFreezer);
doReturn(t).when(container).getSyncTransaction();
container.setLayer(t, 1);
container.setRelativeLayer(t, relativeParent, 2);
- // Set through surfaceAnimator if surfaceFreezer doesn't have leash.
verify(surfaceAnimator).setLayer(t, 1);
verify(surfaceAnimator).setRelativeLayer(t, relativeParent, 2);
- verify(surfaceFreezer, never()).setLayer(any(), anyInt());
- verify(surfaceFreezer, never()).setRelativeLayer(any(), any(), anyInt());
-
- clearInvocations(surfaceAnimator);
- clearInvocations(surfaceFreezer);
- doReturn(true).when(surfaceFreezer).hasLeash();
-
- container.setLayer(t, 1);
- container.setRelativeLayer(t, relativeParent, 2);
-
- // Set through surfaceFreezer if surfaceFreezer has leash.
- verify(surfaceFreezer).setLayer(t, 1);
- verify(surfaceFreezer).setRelativeLayer(t, relativeParent, 2);
- verify(surfaceAnimator, never()).setLayer(any(), anyInt());
- verify(surfaceAnimator, never()).setRelativeLayer(any(), any(), anyInt());
- }
-
- @Test
- public void testStartChangeTransitionWhenPreviousIsNotFinished() {
- final WindowContainer container = createTaskFragmentWithActivity(
- createTask(mDisplayContent));
- container.mSurfaceControl = mock(SurfaceControl.class);
- final SurfaceAnimator surfaceAnimator = container.mSurfaceAnimator;
- final SurfaceFreezer surfaceFreezer = container.mSurfaceFreezer;
- final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
- spyOn(container);
- spyOn(surfaceAnimator);
- mockSurfaceFreezerSnapshot(surfaceFreezer);
- doReturn(t).when(container).getPendingTransaction();
- doReturn(t).when(container).getSyncTransaction();
-
- // Leash and snapshot created for change transition.
- container.initializeChangeTransition(new Rect(0, 0, 1000, 2000));
-
- assertNotNull(surfaceFreezer.mLeash);
- assertNotNull(surfaceFreezer.mSnapshot);
- assertEquals(surfaceFreezer.mLeash, container.getAnimationLeash());
-
- // Start animation: surfaceAnimator take over the leash and snapshot from surfaceFreezer.
- container.applyAnimationUnchecked(null /* lp */, true /* enter */,
- TRANSIT_OLD_TASK_FRAGMENT_CHANGE, false /* isVoiceInteraction */,
- null /* sources */);
-
- assertNull(surfaceFreezer.mLeash);
- assertNull(surfaceFreezer.mSnapshot);
- assertNotNull(surfaceAnimator.mLeash);
- assertNotNull(surfaceAnimator.mSnapshot);
- final SurfaceControl prevLeash = surfaceAnimator.mLeash;
- final SurfaceFreezer.Snapshot prevSnapshot = surfaceAnimator.mSnapshot;
-
- // Prepare another change transition.
- container.initializeChangeTransition(new Rect(0, 0, 1000, 2000));
-
- assertNotNull(surfaceFreezer.mLeash);
- assertNotNull(surfaceFreezer.mSnapshot);
- assertEquals(surfaceFreezer.mLeash, container.getAnimationLeash());
- assertNotEquals(prevLeash, container.getAnimationLeash());
-
- // Start another animation before the previous one is finished, it should reset the previous
- // one, but not change the current one.
- container.applyAnimationUnchecked(null /* lp */, true /* enter */,
- TRANSIT_OLD_TASK_FRAGMENT_CHANGE, false /* isVoiceInteraction */,
- null /* sources */);
-
- verify(container, never()).onAnimationLeashLost(any());
- verify(surfaceFreezer, never()).unfreeze(any());
- assertNotNull(surfaceAnimator.mLeash);
- assertNotNull(surfaceAnimator.mSnapshot);
- assertEquals(surfaceAnimator.mLeash, container.getAnimationLeash());
- assertNotEquals(prevLeash, surfaceAnimator.mLeash);
- assertNotEquals(prevSnapshot, surfaceAnimator.mSnapshot);
-
- // Clean up after animation finished.
- surfaceAnimator.mInnerAnimationFinishedCallback.onAnimationFinished(
- ANIMATION_TYPE_APP_TRANSITION, surfaceAnimator.getAnimation());
-
- verify(container).onAnimationLeashLost(any());
- assertNull(surfaceAnimator.mLeash);
- assertNull(surfaceAnimator.mSnapshot);
- }
-
- @Test
- public void testUnfreezeWindow_removeWindowFromChanging() {
- final WindowContainer container = createTaskFragmentWithActivity(
- createTask(mDisplayContent));
- mockSurfaceFreezerSnapshot(container.mSurfaceFreezer);
- final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
-
- container.initializeChangeTransition(new Rect(0, 0, 1000, 2000));
-
- assertTrue(mDisplayContent.mChangingContainers.contains(container));
-
- container.mSurfaceFreezer.unfreeze(t);
-
- assertFalse(mDisplayContent.mChangingContainers.contains(container));
- }
-
- @Test
- public void testFailToTaskSnapshot_unfreezeWindow() {
- final WindowContainer container = createTaskFragmentWithActivity(
- createTask(mDisplayContent));
- final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
- spyOn(container.mSurfaceFreezer);
-
- container.initializeChangeTransition(new Rect(0, 0, 1000, 2000));
-
- verify(container.mSurfaceFreezer).freeze(any(), any(), any(), any());
- verify(container.mSurfaceFreezer).unfreeze(any());
- assertTrue(mDisplayContent.mChangingContainers.isEmpty());
- }
-
- @Test
- public void testRemoveUnstartedFreezeSurfaceWhenFreezeAgain() {
- final WindowContainer container = createTaskFragmentWithActivity(
- createTask(mDisplayContent));
- container.mSurfaceControl = mock(SurfaceControl.class);
- final SurfaceFreezer surfaceFreezer = container.mSurfaceFreezer;
- mockSurfaceFreezerSnapshot(surfaceFreezer);
- final SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
- spyOn(container);
- doReturn(t).when(container).getPendingTransaction();
- doReturn(t).when(container).getSyncTransaction();
-
- // Leash and snapshot created for change transition.
- container.initializeChangeTransition(new Rect(0, 0, 1000, 2000));
-
- assertNotNull(surfaceFreezer.mLeash);
- assertNotNull(surfaceFreezer.mSnapshot);
-
- final SurfaceControl prevLeash = surfaceFreezer.mLeash;
- final SurfaceFreezer.Snapshot prevSnapshot = surfaceFreezer.mSnapshot;
- spyOn(prevSnapshot);
-
- container.initializeChangeTransition(new Rect(0, 0, 1500, 2500));
-
- verify(t).remove(prevLeash);
- verify(prevSnapshot).destroy(t);
}
@Test
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
index 2c390c504e9f..b16f5283d532 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
@@ -78,7 +78,6 @@ import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.graphics.Insets;
import android.graphics.Rect;
-import android.hardware.HardwareBuffer;
import android.hardware.display.DisplayManager;
import android.os.Binder;
import android.os.Build;
@@ -113,7 +112,6 @@ import android.window.ActivityWindowInfo;
import android.window.ClientWindowFrames;
import android.window.ITaskFragmentOrganizer;
import android.window.ITransitionPlayer;
-import android.window.ScreenCapture;
import android.window.StartingWindowInfo;
import android.window.StartingWindowRemovalInfo;
import android.window.TaskFragmentOrganizer;
@@ -1112,21 +1110,6 @@ public class WindowTestsBase extends SystemServiceTestsBase {
displayContent -> displayContent.mMinSizeOfResizeableTaskDp = 1);
}
- /** Mocks the behavior of taking a snapshot. */
- void mockSurfaceFreezerSnapshot(SurfaceFreezer surfaceFreezer) {
- final ScreenCapture.ScreenshotHardwareBuffer screenshotBuffer =
- mock(ScreenCapture.ScreenshotHardwareBuffer.class);
- final HardwareBuffer hardwareBuffer = mock(HardwareBuffer.class);
- spyOn(surfaceFreezer);
- doReturn(screenshotBuffer).when(surfaceFreezer)
- .createSnapshotBufferInner(any(), any());
- doReturn(null).when(surfaceFreezer)
- .createFromHardwareBufferInner(any());
- doReturn(hardwareBuffer).when(screenshotBuffer).getHardwareBuffer();
- doReturn(100).when(hardwareBuffer).getWidth();
- doReturn(100).when(hardwareBuffer).getHeight();
- }
-
static ComponentName getUniqueComponentName() {
return getUniqueComponentName(DEFAULT_COMPONENT_PACKAGE_NAME);
}