diff options
| author | 2022-03-31 08:46:59 +0000 | |
|---|---|---|
| committer | 2022-03-31 08:46:59 +0000 | |
| commit | 033ac7f4543caab5dbb455cd681728c8deee0658 (patch) | |
| tree | b5306a8b3d09cf0b5bd08ad917049ef5eff52455 | |
| parent | c5a4e1ab7c52ebd96db4402efd3e8d614e2ccc37 (diff) | |
| parent | 0c414c0740b78fde686fd35af7184e7232162998 (diff) | |
Merge changes from topic "presubmit-am-0ceaf5de4b364feeaa00d2d1e8e8414b" into tm-dev
* changes:
Revert "Revert "Use new T activity transitions in legacy""
Remove edge extension surface onAnimationLeashLost
8 files changed, 55 insertions, 224 deletions
diff --git a/core/java/com/android/internal/policy/TransitionAnimation.java b/core/java/com/android/internal/policy/TransitionAnimation.java index e2d250589a8f..fd8534d45b2b 100644 --- a/core/java/com/android/internal/policy/TransitionAnimation.java +++ b/core/java/com/android/internal/policy/TransitionAnimation.java @@ -101,10 +101,6 @@ public class TransitionAnimation { private static final String DEFAULT_PACKAGE = "android"; - // TODO (b/215515255): remove once we full migrate to shell transitions - private static final boolean SHELL_TRANSITIONS_ENABLED = - SystemProperties.getBoolean("persist.wm.debug.shell_transit", false); - private final Context mContext; private final String mTag; @@ -259,9 +255,6 @@ public class TransitionAnimation { resId = ent.array.getResourceId(animAttr, 0); } } - if (!SHELL_TRANSITIONS_ENABLED) { - resId = updateToLegacyIfNeeded(resId); - } resId = updateToTranslucentAnimIfNeeded(resId, transit); if (ResourceId.isValid(resId)) { return loadAnimationSafely(context, resId, mTag); @@ -269,24 +262,6 @@ public class TransitionAnimation { return null; } - /** - * Replace animations that are not compatible with the legacy transition system with ones that - * are compatible with it. - * TODO (b/215515255): remove once we full migrate to shell transitions - */ - private int updateToLegacyIfNeeded(int anim) { - if (anim == R.anim.activity_open_enter) { - return R.anim.activity_open_enter_legacy; - } else if (anim == R.anim.activity_open_exit) { - return R.anim.activity_open_exit_legacy; - } else if (anim == R.anim.activity_close_enter) { - return R.anim.activity_close_enter_legacy; - } else if (anim == R.anim.activity_close_exit) { - return R.anim.activity_close_exit_legacy; - } - return anim; - } - /** Load animation by attribute Id from a specific AnimationStyle resource. */ @Nullable public Animation loadAnimationAttr(String packageName, int animStyleResId, int animAttr, diff --git a/core/res/res/anim/activity_close_enter_legacy.xml b/core/res/res/anim/activity_close_enter_legacy.xml deleted file mode 100644 index 9fa7c5498ea6..000000000000 --- a/core/res/res/anim/activity_close_enter_legacy.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** Copyright 2009, 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. -*/ ---> - -<set xmlns:android="http://schemas.android.com/apk/res/android" - android:shareInterpolator="false"> - <scale - android:fromXScale="1.1" - android:toXScale="1" - android:fromYScale="1.1" - android:toYScale="1" - android:pivotX="50%" - android:pivotY="50%" - android:fillEnabled="true" - android:fillBefore="true" - android:fillAfter="true" - android:interpolator="@interpolator/fast_out_extra_slow_in" - android:duration="400"/> -</set>
\ No newline at end of file diff --git a/core/res/res/anim/activity_close_exit_legacy.xml b/core/res/res/anim/activity_close_exit_legacy.xml deleted file mode 100644 index 1599ae8cb19f..000000000000 --- a/core/res/res/anim/activity_close_exit_legacy.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** Copyright 2009, 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. -*/ ---> - -<set xmlns:android="http://schemas.android.com/apk/res/android" - android:shareInterpolator="false" - android:zAdjustment="top"> - <alpha - android:fromAlpha="1" - android:toAlpha="0.0" - android:fillEnabled="true" - android:fillBefore="true" - android:fillAfter="true" - android:interpolator="@interpolator/linear" - android:startOffset="33" - android:duration="50"/> - <scale - android:fromXScale="1" - android:toXScale="0.9" - android:fromYScale="1" - android:toYScale="0.9" - android:pivotX="50%" - android:pivotY="50%" - android:fillEnabled="true" - android:fillBefore="true" - android:fillAfter="true" - android:interpolator="@interpolator/fast_out_extra_slow_in" - android:duration="400"/> -</set> diff --git a/core/res/res/anim/activity_open_enter_legacy.xml b/core/res/res/anim/activity_open_enter_legacy.xml deleted file mode 100644 index 38d3e8ed06ce..000000000000 --- a/core/res/res/anim/activity_open_enter_legacy.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?><!-- -/* -** Copyright 2009, 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. -*/ ---> - -<set xmlns:android="http://schemas.android.com/apk/res/android" - android:shareInterpolator="false"> - <alpha - android:fromAlpha="0" - android:toAlpha="1.0" - android:fillEnabled="true" - android:fillBefore="true" - android:fillAfter="true" - android:interpolator="@interpolator/linear" - android:startOffset="50" - android:duration="50"/> - <scale - android:fromXScale="0.85" - android:toXScale="1" - android:fromYScale="0.85" - android:toYScale="1" - android:pivotX="50%" - android:pivotY="50%" - android:fillEnabled="true" - android:fillBefore="true" - android:fillAfter="true" - android:interpolator="@interpolator/fast_out_extra_slow_in" - android:duration="400"/> -</set> diff --git a/core/res/res/anim/activity_open_exit_legacy.xml b/core/res/res/anim/activity_open_exit_legacy.xml deleted file mode 100644 index 3865d2149f42..000000000000 --- a/core/res/res/anim/activity_open_exit_legacy.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?><!-- -/* -** Copyright 2009, 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. -*/ ---> - -<set xmlns:android="http://schemas.android.com/apk/res/android" - android:shareInterpolator="false"> - - <!-- Fade out, over a black surface, which simulates a black scrim --> - <alpha - android:fromAlpha="1" - android:toAlpha="0.4" - android:fillEnabled="true" - android:fillBefore="true" - android:fillAfter="true" - android:interpolator="@interpolator/linear" - android:startOffset="83" - android:duration="167"/> - - <scale - android:fromXScale="1" - android:toXScale="1.05" - android:fromYScale="1" - android:toYScale="1.05" - android:pivotX="50%" - android:pivotY="50%" - android:fillEnabled="true" - android:fillBefore="true" - android:fillAfter="true" - android:interpolator="@interpolator/fast_out_extra_slow_in" - android:duration="400"/> -</set>
\ No newline at end of file diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 15af08c46de1..f366a53f6341 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1716,10 +1716,6 @@ <java-symbol type="anim" name="activity_open_exit" /> <java-symbol type="anim" name="activity_close_enter" /> <java-symbol type="anim" name="activity_close_exit" /> - <java-symbol type="anim" name="activity_open_enter_legacy" /> - <java-symbol type="anim" name="activity_open_exit_legacy" /> - <java-symbol type="anim" name="activity_close_enter_legacy" /> - <java-symbol type="anim" name="activity_close_exit_legacy" /> <java-symbol type="anim" name="task_fragment_close_enter" /> <java-symbol type="anim" name="task_fragment_close_exit" /> <java-symbol type="anim" name="task_fragment_open_enter" /> diff --git a/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java b/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java index b57670914c11..65dca86d0259 100644 --- a/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java +++ b/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java @@ -50,7 +50,6 @@ import com.android.server.AnimationThread; import com.android.server.wm.LocalAnimationAdapter.AnimationSpec; import java.util.ArrayList; -import java.util.List; import java.util.function.Supplier; /** @@ -66,6 +65,12 @@ class SurfaceAnimationRunner { */ private final Object mCancelLock = new Object(); + /** + * Lock for synchronizing {@link #mEdgeExtensions} to prevent race conditions when managing + * created edge extension surfaces. + */ + private final Object mEdgeExtensionLock = new Object(); + @VisibleForTesting Choreographer mChoreographer; @@ -93,6 +98,11 @@ class SurfaceAnimationRunner { @GuardedBy("mLock") private boolean mAnimationStartDeferred; + // Mapping animation leashes to a list of edge extension surfaces associated with them + @GuardedBy("mEdgeExtensionLock") + private final ArrayMap<SurfaceControl, ArrayList<SurfaceControl>> mEdgeExtensions = + new ArrayMap<>(); + /** * There should only ever be one instance of this class. Usual spot for it is with * {@link WindowManagerService} @@ -154,21 +164,22 @@ class SurfaceAnimationRunner { boolean requiresEdgeExtension = requiresEdgeExtension(a); if (requiresEdgeExtension) { + final ArrayList<SurfaceControl> extensionSurfaces = new ArrayList<>(); + synchronized (mEdgeExtensionLock) { + mEdgeExtensions.put(animationLeash, extensionSurfaces); + } + mPreProcessingAnimations.put(animationLeash, runningAnim); // We must wait for t to be committed since otherwise the leash doesn't have the // windows we want to screenshot and extend as children. t.addTransactionCommittedListener(Runnable::run, () -> { final WindowAnimationSpec animationSpec = a.asWindowAnimationSpec(); - final Runnable cleanUpEdgeExtension = edgeExtendWindow(animationLeash, + + edgeExtendWindow(animationLeash, animationSpec.getRootTaskBounds(), animationSpec.getAnimation(), mFrameTransaction); - runningAnim.mFinishCallback = () -> { - cleanUpEdgeExtension.run(); - finishCallback.run(); - }; - synchronized (mLock) { // only run if animation is not yet canceled by this point if (mPreProcessingAnimations.get(animationLeash) == runningAnim) { @@ -320,7 +331,7 @@ class SurfaceAnimationRunner { mApplyScheduled = false; } - private Runnable edgeExtendWindow(SurfaceControl leash, Rect bounds, Animation a, + private void edgeExtendWindow(SurfaceControl leash, Rect bounds, Animation a, Transaction transaction) { final Transformation transformationAtStart = new Transformation(); a.getTransformationAt(0, transformationAtStart); @@ -335,17 +346,14 @@ class SurfaceAnimationRunner { final int targetSurfaceHeight = bounds.height(); final int targetSurfaceWidth = bounds.width(); - final List<SurfaceControl> extensionSurfaces = new ArrayList<>(); - if (maxExtensionInsets.left < 0) { final Rect edgeBounds = new Rect(0, 0, 1, targetSurfaceHeight); final Rect extensionRect = new Rect(0, 0, -maxExtensionInsets.left, targetSurfaceHeight); final int xPos = maxExtensionInsets.left; final int yPos = 0; - final SurfaceControl extensionSurface = createExtensionSurface(leash, edgeBounds, + createExtensionSurface(leash, edgeBounds, extensionRect, xPos, yPos, "Left Edge Extension", transaction); - extensionSurfaces.add(extensionSurface); } if (maxExtensionInsets.top < 0) { @@ -354,9 +362,8 @@ class SurfaceAnimationRunner { targetSurfaceWidth, -maxExtensionInsets.top); final int xPos = 0; final int yPos = maxExtensionInsets.top; - final SurfaceControl extensionSurface = createExtensionSurface(leash, edgeBounds, + createExtensionSurface(leash, edgeBounds, extensionRect, xPos, yPos, "Top Edge Extension", transaction); - extensionSurfaces.add(extensionSurface); } if (maxExtensionInsets.right < 0) { @@ -366,9 +373,8 @@ class SurfaceAnimationRunner { -maxExtensionInsets.right, targetSurfaceHeight); final int xPos = targetSurfaceWidth; final int yPos = 0; - final SurfaceControl extensionSurface = createExtensionSurface(leash, edgeBounds, + createExtensionSurface(leash, edgeBounds, extensionRect, xPos, yPos, "Right Edge Extension", transaction); - extensionSurfaces.add(extensionSurface); } if (maxExtensionInsets.bottom < 0) { @@ -378,23 +384,25 @@ class SurfaceAnimationRunner { targetSurfaceWidth, -maxExtensionInsets.bottom); final int xPos = maxExtensionInsets.left; final int yPos = targetSurfaceHeight; - final SurfaceControl extensionSurface = createExtensionSurface(leash, edgeBounds, + createExtensionSurface(leash, edgeBounds, extensionRect, xPos, yPos, "Bottom Edge Extension", transaction); - extensionSurfaces.add(extensionSurface); } + } - Runnable cleanUp = () -> { - for (final SurfaceControl extensionSurface : extensionSurfaces) { - if (extensionSurface != null) { - transaction.remove(extensionSurface); - } + private void createExtensionSurface(SurfaceControl leash, Rect edgeBounds, + Rect extensionRect, int xPos, int yPos, String layerName, + Transaction startTransaction) { + synchronized (mEdgeExtensionLock) { + if (!mEdgeExtensions.containsKey(leash)) { + // Animation leash has already been removed so we shouldn't perform any extension + return; } - }; - - return cleanUp; + createExtensionSurfaceLocked(leash, edgeBounds, extensionRect, xPos, yPos, layerName, + startTransaction); + } } - private SurfaceControl createExtensionSurface(SurfaceControl surfaceToExtend, Rect edgeBounds, + private void createExtensionSurfaceLocked(SurfaceControl surfaceToExtend, Rect edgeBounds, Rect extensionRect, int xPos, int yPos, String layerName, Transaction startTransaction) { final SurfaceControl edgeExtensionLayer = new SurfaceControl.Builder() @@ -420,7 +428,7 @@ class SurfaceAnimationRunner { if (edgeBuffer == null) { Log.e("SurfaceAnimationRunner", "Failed to create edge extension - " + "edge buffer is null"); - return null; + return; } android.graphics.BitmapShader shader = @@ -440,13 +448,13 @@ class SurfaceAnimationRunner { startTransaction.setPosition(edgeExtensionLayer, xPos, yPos); startTransaction.setVisibility(edgeExtensionLayer, true); - return edgeExtensionLayer; + mEdgeExtensions.get(surfaceToExtend).add(edgeExtensionLayer); } private static final class RunningAnimation { final AnimationSpec mAnimSpec; final SurfaceControl mLeash; - Runnable mFinishCallback; + final Runnable mFinishCallback; ValueAnimator mAnim; @GuardedBy("mCancelLock") @@ -459,6 +467,22 @@ class SurfaceAnimationRunner { } } + protected void onAnimationLeashLost(SurfaceControl animationLeash, + Transaction t) { + synchronized (mEdgeExtensionLock) { + if (!mEdgeExtensions.containsKey(animationLeash)) { + return; + } + + final ArrayList<SurfaceControl> edgeExtensions = mEdgeExtensions.get(animationLeash); + for (int i = 0; i < edgeExtensions.size(); i++) { + final SurfaceControl extension = edgeExtensions.get(i); + t.remove(extension); + } + mEdgeExtensions.remove(animationLeash); + } + } + @VisibleForTesting interface AnimatorFactory { ValueAnimator makeAnimator(); diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 99e39f1969e1..214524c2f42c 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -3179,6 +3179,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< @Override public void onAnimationLeashLost(Transaction t) { mLastLayer = -1; + mWmService.mSurfaceAnimationRunner.onAnimationLeashLost(mAnimationLeash, t); mAnimationLeash = null; reassignLayer(t); updateSurfacePosition(t); |