From 58ec24459c34051858efffb6b1f67061155d8dca Mon Sep 17 00:00:00 2001 From: Luca Zuccarini Date: Wed, 21 Feb 2024 14:54:49 +0000 Subject: Move remote animation utils to the Animation lib. This is so that they can be used within the Animation lib itself, while remaining available to all current users, since the SysUI shared lib also depends on Animation lib. Bug: 323863002 Flag: NA Test: still builds, tests still pass, manually tested areas that depend on these utils. Change-Id: I83f087c76159979d35d7ff48b0f6356e72dbc891 --- packages/SystemUI/animation/Android.bp | 1 + .../animation/RemoteAnimationRunnerCompat.java | 243 +++++++++++++++++++++ .../animation/RemoteAnimationTargetCompat.java | 86 ++++++++ .../shared/system/RemoteAnimationRunnerCompat.java | 243 --------------------- .../shared/system/RemoteAnimationTargetCompat.java | 86 -------- .../systemui/statusbar/phone/CentralSurfaces.java | 2 +- .../shared/system/RemoteTransitionTest.java | 1 + 7 files changed, 332 insertions(+), 330 deletions(-) create mode 100644 packages/SystemUI/animation/src/com/android/systemui/animation/RemoteAnimationRunnerCompat.java create mode 100644 packages/SystemUI/animation/src/com/android/systemui/animation/RemoteAnimationTargetCompat.java delete mode 100644 packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java delete mode 100644 packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java diff --git a/packages/SystemUI/animation/Android.bp b/packages/SystemUI/animation/Android.bp index c1125f0b9e92..99b7c36d6fb9 100644 --- a/packages/SystemUI/animation/Android.bp +++ b/packages/SystemUI/animation/Android.bp @@ -45,6 +45,7 @@ android_library { "androidx.core_core-ktx", "androidx.annotation_annotation", "SystemUIShaderLib", + "WindowManager-Shell-shared", "animationlib", ], diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/RemoteAnimationRunnerCompat.java b/packages/SystemUI/animation/src/com/android/systemui/animation/RemoteAnimationRunnerCompat.java new file mode 100644 index 000000000000..e20425d4b98c --- /dev/null +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/RemoteAnimationRunnerCompat.java @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2024 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.systemui.animation; + +import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; +import static android.view.WindowManager.TRANSIT_CLOSE; +import static android.view.WindowManager.TRANSIT_OLD_NONE; +import static android.view.WindowManager.TRANSIT_OPEN; +import static android.view.WindowManager.TRANSIT_TO_BACK; +import static android.view.WindowManager.TRANSIT_TO_FRONT; +import static android.window.TransitionInfo.FLAG_IS_WALLPAPER; + +import android.os.IBinder; +import android.os.RemoteException; +import android.util.ArrayMap; +import android.util.Log; +import android.view.IRemoteAnimationFinishedCallback; +import android.view.IRemoteAnimationRunner; +import android.view.RemoteAnimationTarget; +import android.view.SurfaceControl; +import android.view.WindowManager; +import android.view.WindowManager.TransitionOldType; +import android.window.IRemoteTransition; +import android.window.IRemoteTransitionFinishedCallback; +import android.window.TransitionInfo; + +import com.android.wm.shell.shared.CounterRotator; + +public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner.Stub { + private static final String TAG = "RemoteAnimRunnerCompat"; + + public abstract void onAnimationStart(@WindowManager.TransitionOldType int transit, + RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers, + RemoteAnimationTarget[] nonApps, Runnable finishedCallback); + + @Override + public final void onAnimationStart(@TransitionOldType int transit, + RemoteAnimationTarget[] apps, + RemoteAnimationTarget[] wallpapers, + RemoteAnimationTarget[] nonApps, + final IRemoteAnimationFinishedCallback finishedCallback) { + + onAnimationStart(transit, apps, wallpapers, + nonApps, () -> { + try { + finishedCallback.onAnimationFinished(); + } catch (RemoteException e) { + Log.e(TAG, "Failed to call app controlled animation finished callback", e); + } + }); + } + + public IRemoteTransition toRemoteTransition() { + return wrap(this); + } + + /** Wraps a remote animation runner in a remote-transition. */ + public static IRemoteTransition.Stub wrap(IRemoteAnimationRunner runner) { + return new IRemoteTransition.Stub() { + final ArrayMap mFinishRunnables = new ArrayMap<>(); + + @Override + public void startAnimation(IBinder token, TransitionInfo info, + SurfaceControl.Transaction t, + IRemoteTransitionFinishedCallback finishCallback) throws RemoteException { + final ArrayMap leashMap = new ArrayMap<>(); + final RemoteAnimationTarget[] apps = + RemoteAnimationTargetCompat.wrapApps(info, t, leashMap); + final RemoteAnimationTarget[] wallpapers = + RemoteAnimationTargetCompat.wrapNonApps( + info, true /* wallpapers */, t, leashMap); + final RemoteAnimationTarget[] nonApps = + RemoteAnimationTargetCompat.wrapNonApps( + info, false /* wallpapers */, t, leashMap); + + // TODO(b/177438007): Move this set-up logic into launcher's animation impl. + boolean isReturnToHome = false; + TransitionInfo.Change launcherTask = null; + TransitionInfo.Change wallpaper = null; + int launcherLayer = 0; + int rotateDelta = 0; + float displayW = 0; + float displayH = 0; + for (int i = info.getChanges().size() - 1; i >= 0; --i) { + final TransitionInfo.Change change = info.getChanges().get(i); + // skip changes that we didn't wrap + if (!leashMap.containsKey(change.getLeash())) continue; + if (change.getTaskInfo() != null + && change.getTaskInfo().getActivityType() == ACTIVITY_TYPE_HOME) { + isReturnToHome = change.getMode() == TRANSIT_OPEN + || change.getMode() == TRANSIT_TO_FRONT; + launcherTask = change; + launcherLayer = info.getChanges().size() - i; + } else if ((change.getFlags() & FLAG_IS_WALLPAPER) != 0) { + wallpaper = change; + } + if (change.getParent() == null && change.getEndRotation() >= 0 + && change.getEndRotation() != change.getStartRotation()) { + rotateDelta = change.getEndRotation() - change.getStartRotation(); + displayW = change.getEndAbsBounds().width(); + displayH = change.getEndAbsBounds().height(); + } + } + + // Prepare for rotation if there is one + final CounterRotator counterLauncher = new CounterRotator(); + final CounterRotator counterWallpaper = new CounterRotator(); + if (launcherTask != null && rotateDelta != 0 && launcherTask.getParent() != null) { + final TransitionInfo.Change parent = info.getChange(launcherTask.getParent()); + if (parent != null) { + counterLauncher.setup(t, parent.getLeash(), rotateDelta, displayW, + displayH); + } else { + Log.e(TAG, "Malformed: " + launcherTask + " has parent=" + + launcherTask.getParent() + " but it's not in info."); + } + if (counterLauncher.getSurface() != null) { + t.setLayer(counterLauncher.getSurface(), launcherLayer); + } + } + + if (isReturnToHome) { + if (counterLauncher.getSurface() != null) { + t.setLayer(counterLauncher.getSurface(), info.getChanges().size() * 3); + } + // Need to "boost" the closing things since that's what launcher expects. + for (int i = info.getChanges().size() - 1; i >= 0; --i) { + final TransitionInfo.Change change = info.getChanges().get(i); + final SurfaceControl leash = leashMap.get(change.getLeash()); + // skip changes that we didn't wrap + if (leash == null) continue; + final int mode = info.getChanges().get(i).getMode(); + // Only deal with independent layers + if (!TransitionInfo.isIndependent(change, info)) continue; + if (mode == TRANSIT_CLOSE || mode == TRANSIT_TO_BACK) { + t.setLayer(leash, info.getChanges().size() * 3 - i); + counterLauncher.addChild(t, leash); + } + } + // Make wallpaper visible immediately since launcher apparently won't do this. + for (int i = wallpapers.length - 1; i >= 0; --i) { + t.show(wallpapers[i].leash); + t.setAlpha(wallpapers[i].leash, 1.f); + } + } else { + if (launcherTask != null) { + counterLauncher.addChild(t, leashMap.get(launcherTask.getLeash())); + } + if (wallpaper != null && rotateDelta != 0 && wallpaper.getParent() != null) { + final TransitionInfo.Change parent = info.getChange(wallpaper.getParent()); + if (parent != null) { + counterWallpaper.setup(t, parent.getLeash(), rotateDelta, displayW, + displayH); + } else { + Log.e(TAG, "Malformed: " + wallpaper + " has parent=" + + wallpaper.getParent() + " but it's not in info."); + } + if (counterWallpaper.getSurface() != null) { + t.setLayer(counterWallpaper.getSurface(), -1); + counterWallpaper.addChild(t, leashMap.get(wallpaper.getLeash())); + } + } + } + t.apply(); + + final Runnable animationFinishedCallback = () -> { + final SurfaceControl.Transaction finishTransaction = + new SurfaceControl.Transaction(); + counterLauncher.cleanUp(finishTransaction); + counterWallpaper.cleanUp(finishTransaction); + // Release surface references now. This is apparently to free GPU memory + // before GC would. + info.releaseAllSurfaces(); + // Don't release here since launcher might still be using them. Instead + // let launcher release them (eg. via RemoteAnimationTargets) + leashMap.clear(); + try { + finishCallback.onTransitionFinished(null /* wct */, finishTransaction); + finishTransaction.close(); + } catch (RemoteException e) { + Log.e(TAG, "Failed to call app controlled animation finished callback", e); + } + }; + synchronized (mFinishRunnables) { + mFinishRunnables.put(token, animationFinishedCallback); + } + // TODO(bc-unlcok): Pass correct transit type. + runner.onAnimationStart(TRANSIT_OLD_NONE, + apps, wallpapers, nonApps, new IRemoteAnimationFinishedCallback() { + @Override + public void onAnimationFinished() { + synchronized (mFinishRunnables) { + if (mFinishRunnables.remove(token) == null) return; + } + animationFinishedCallback.run(); + } + + @Override + public IBinder asBinder() { + return null; + } + }); + } + + @Override + public void mergeAnimation(IBinder token, TransitionInfo info, + SurfaceControl.Transaction t, IBinder mergeTarget, + IRemoteTransitionFinishedCallback finishCallback) throws RemoteException { + // TODO: hook up merge to recents onTaskAppeared if applicable. Until then, adapt + // to legacy cancel. + final Runnable finishRunnable; + synchronized (mFinishRunnables) { + finishRunnable = mFinishRunnables.remove(mergeTarget); + } + // Since we're not actually animating, release native memory now + t.close(); + info.releaseAllSurfaces(); + if (finishRunnable == null) return; + runner.onAnimationCancelled(); + finishRunnable.run(); + } + + @Override + public void onTransitionConsumed(IBinder iBinder, boolean aborted) + throws RemoteException { + } + }; + } +} diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/RemoteAnimationTargetCompat.java b/packages/SystemUI/animation/src/com/android/systemui/animation/RemoteAnimationTargetCompat.java new file mode 100644 index 000000000000..e251af44727e --- /dev/null +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/RemoteAnimationTargetCompat.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2024 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.systemui.animation; + +import android.util.ArrayMap; +import android.view.RemoteAnimationTarget; +import android.view.SurfaceControl; +import android.window.TransitionInfo; +import android.window.TransitionInfo.Change; + +import com.android.wm.shell.shared.TransitionUtil; + +import java.util.ArrayList; +import java.util.function.Predicate; + +/** + * Some utility methods for creating {@link RemoteAnimationTarget} instances. + */ +public class RemoteAnimationTargetCompat { + + /** + * Represents a TransitionInfo object as an array of old-style app targets + * + * @param leashMap Temporary map of change leash -> launcher leash. Is an output, so should be + * populated by this function. If null, it is ignored. + */ + public static RemoteAnimationTarget[] wrapApps(TransitionInfo info, + SurfaceControl.Transaction t, ArrayMap leashMap) { + // LeafTaskFilter is order-dependent, so the same object needs to be used for all Change + // objects. That's why it's constructed here and captured by the lambda instead of building + // a new one ad hoc every time. + TransitionUtil.LeafTaskFilter taskFilter = new TransitionUtil.LeafTaskFilter(); + return wrap(info, t, leashMap, (change) -> { + // Intra-task activity -> activity transitions should be categorized as apps. + if (change.getActivityComponent() != null) return true; + return taskFilter.test(change); + }); + } + + /** + * Represents a TransitionInfo object as an array of old-style non-app targets + * + * @param wallpapers If true, this will return wallpaper targets; otherwise it returns + * non-wallpaper targets. + * @param leashMap Temporary map of change leash -> launcher leash. Is an output, so should be + * populated by this function. If null, it is ignored. + */ + public static RemoteAnimationTarget[] wrapNonApps(TransitionInfo info, boolean wallpapers, + SurfaceControl.Transaction t, ArrayMap leashMap) { + return wrap(info, t, leashMap, (change) -> { + // Intra-task activity -> activity transitions should be categorized as apps. + if (change.getActivityComponent() != null) return false; + return wallpapers + ? TransitionUtil.isWallpaper(change) : TransitionUtil.isNonApp(change); + }); + } + + private static RemoteAnimationTarget[] wrap(TransitionInfo info, + SurfaceControl.Transaction t, ArrayMap leashMap, + Predicate filter) { + final ArrayList out = new ArrayList<>(); + for (int i = 0; i < info.getChanges().size(); i++) { + TransitionInfo.Change change = info.getChanges().get(i); + if (TransitionUtil.isOrderOnly(change)) continue; + if (filter.test(change)) { + out.add(TransitionUtil.newTarget( + change, info.getChanges().size() - i, info, t, leashMap)); + } + } + return out.toArray(new RemoteAnimationTarget[out.size()]); + } +} diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java deleted file mode 100644 index a78080fdabf2..000000000000 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationRunnerCompat.java +++ /dev/null @@ -1,243 +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.systemui.shared.system; - -import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; -import static android.view.WindowManager.TRANSIT_CLOSE; -import static android.view.WindowManager.TRANSIT_OLD_NONE; -import static android.view.WindowManager.TRANSIT_OPEN; -import static android.view.WindowManager.TRANSIT_TO_BACK; -import static android.view.WindowManager.TRANSIT_TO_FRONT; -import static android.window.TransitionInfo.FLAG_IS_WALLPAPER; - -import android.os.IBinder; -import android.os.RemoteException; -import android.util.ArrayMap; -import android.util.Log; -import android.view.IRemoteAnimationFinishedCallback; -import android.view.IRemoteAnimationRunner; -import android.view.RemoteAnimationTarget; -import android.view.SurfaceControl; -import android.view.WindowManager; -import android.view.WindowManager.TransitionOldType; -import android.window.IRemoteTransition; -import android.window.IRemoteTransitionFinishedCallback; -import android.window.TransitionInfo; - -import com.android.wm.shell.shared.CounterRotator; - -public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner.Stub { - private static final String TAG = "RemoteAnimRunnerCompat"; - - public abstract void onAnimationStart(@WindowManager.TransitionOldType int transit, - RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers, - RemoteAnimationTarget[] nonApps, Runnable finishedCallback); - - @Override - public final void onAnimationStart(@TransitionOldType int transit, - RemoteAnimationTarget[] apps, - RemoteAnimationTarget[] wallpapers, - RemoteAnimationTarget[] nonApps, - final IRemoteAnimationFinishedCallback finishedCallback) { - - onAnimationStart(transit, apps, wallpapers, - nonApps, () -> { - try { - finishedCallback.onAnimationFinished(); - } catch (RemoteException e) { - Log.e(TAG, "Failed to call app controlled animation finished callback", e); - } - }); - } - - public IRemoteTransition toRemoteTransition() { - return wrap(this); - } - - /** Wraps a remote animation runner in a remote-transition. */ - public static IRemoteTransition.Stub wrap(IRemoteAnimationRunner runner) { - return new IRemoteTransition.Stub() { - final ArrayMap mFinishRunnables = new ArrayMap<>(); - - @Override - public void startAnimation(IBinder token, TransitionInfo info, - SurfaceControl.Transaction t, - IRemoteTransitionFinishedCallback finishCallback) throws RemoteException { - final ArrayMap leashMap = new ArrayMap<>(); - final RemoteAnimationTarget[] apps = - RemoteAnimationTargetCompat.wrapApps(info, t, leashMap); - final RemoteAnimationTarget[] wallpapers = - RemoteAnimationTargetCompat.wrapNonApps( - info, true /* wallpapers */, t, leashMap); - final RemoteAnimationTarget[] nonApps = - RemoteAnimationTargetCompat.wrapNonApps( - info, false /* wallpapers */, t, leashMap); - - // TODO(b/177438007): Move this set-up logic into launcher's animation impl. - boolean isReturnToHome = false; - TransitionInfo.Change launcherTask = null; - TransitionInfo.Change wallpaper = null; - int launcherLayer = 0; - int rotateDelta = 0; - float displayW = 0; - float displayH = 0; - for (int i = info.getChanges().size() - 1; i >= 0; --i) { - final TransitionInfo.Change change = info.getChanges().get(i); - // skip changes that we didn't wrap - if (!leashMap.containsKey(change.getLeash())) continue; - if (change.getTaskInfo() != null - && change.getTaskInfo().getActivityType() == ACTIVITY_TYPE_HOME) { - isReturnToHome = change.getMode() == TRANSIT_OPEN - || change.getMode() == TRANSIT_TO_FRONT; - launcherTask = change; - launcherLayer = info.getChanges().size() - i; - } else if ((change.getFlags() & FLAG_IS_WALLPAPER) != 0) { - wallpaper = change; - } - if (change.getParent() == null && change.getEndRotation() >= 0 - && change.getEndRotation() != change.getStartRotation()) { - rotateDelta = change.getEndRotation() - change.getStartRotation(); - displayW = change.getEndAbsBounds().width(); - displayH = change.getEndAbsBounds().height(); - } - } - - // Prepare for rotation if there is one - final CounterRotator counterLauncher = new CounterRotator(); - final CounterRotator counterWallpaper = new CounterRotator(); - if (launcherTask != null && rotateDelta != 0 && launcherTask.getParent() != null) { - final TransitionInfo.Change parent = info.getChange(launcherTask.getParent()); - if (parent != null) { - counterLauncher.setup(t, parent.getLeash(), rotateDelta, displayW, - displayH); - } else { - Log.e(TAG, "Malformed: " + launcherTask + " has parent=" - + launcherTask.getParent() + " but it's not in info."); - } - if (counterLauncher.getSurface() != null) { - t.setLayer(counterLauncher.getSurface(), launcherLayer); - } - } - - if (isReturnToHome) { - if (counterLauncher.getSurface() != null) { - t.setLayer(counterLauncher.getSurface(), info.getChanges().size() * 3); - } - // Need to "boost" the closing things since that's what launcher expects. - for (int i = info.getChanges().size() - 1; i >= 0; --i) { - final TransitionInfo.Change change = info.getChanges().get(i); - final SurfaceControl leash = leashMap.get(change.getLeash()); - // skip changes that we didn't wrap - if (leash == null) continue; - final int mode = info.getChanges().get(i).getMode(); - // Only deal with independent layers - if (!TransitionInfo.isIndependent(change, info)) continue; - if (mode == TRANSIT_CLOSE || mode == TRANSIT_TO_BACK) { - t.setLayer(leash, info.getChanges().size() * 3 - i); - counterLauncher.addChild(t, leash); - } - } - // Make wallpaper visible immediately since launcher apparently won't do this. - for (int i = wallpapers.length - 1; i >= 0; --i) { - t.show(wallpapers[i].leash); - t.setAlpha(wallpapers[i].leash, 1.f); - } - } else { - if (launcherTask != null) { - counterLauncher.addChild(t, leashMap.get(launcherTask.getLeash())); - } - if (wallpaper != null && rotateDelta != 0 && wallpaper.getParent() != null) { - final TransitionInfo.Change parent = info.getChange(wallpaper.getParent()); - if (parent != null) { - counterWallpaper.setup(t, parent.getLeash(), rotateDelta, displayW, - displayH); - } else { - Log.e(TAG, "Malformed: " + wallpaper + " has parent=" - + wallpaper.getParent() + " but it's not in info."); - } - if (counterWallpaper.getSurface() != null) { - t.setLayer(counterWallpaper.getSurface(), -1); - counterWallpaper.addChild(t, leashMap.get(wallpaper.getLeash())); - } - } - } - t.apply(); - - final Runnable animationFinishedCallback = () -> { - final SurfaceControl.Transaction finishTransaction = - new SurfaceControl.Transaction(); - counterLauncher.cleanUp(finishTransaction); - counterWallpaper.cleanUp(finishTransaction); - // Release surface references now. This is apparently to free GPU memory - // before GC would. - info.releaseAllSurfaces(); - // Don't release here since launcher might still be using them. Instead - // let launcher release them (eg. via RemoteAnimationTargets) - leashMap.clear(); - try { - finishCallback.onTransitionFinished(null /* wct */, finishTransaction); - finishTransaction.close(); - } catch (RemoteException e) { - Log.e(TAG, "Failed to call app controlled animation finished callback", e); - } - }; - synchronized (mFinishRunnables) { - mFinishRunnables.put(token, animationFinishedCallback); - } - // TODO(bc-unlcok): Pass correct transit type. - runner.onAnimationStart(TRANSIT_OLD_NONE, - apps, wallpapers, nonApps, new IRemoteAnimationFinishedCallback() { - @Override - public void onAnimationFinished() { - synchronized (mFinishRunnables) { - if (mFinishRunnables.remove(token) == null) return; - } - animationFinishedCallback.run(); - } - - @Override - public IBinder asBinder() { - return null; - } - }); - } - - @Override - public void mergeAnimation(IBinder token, TransitionInfo info, - SurfaceControl.Transaction t, IBinder mergeTarget, - IRemoteTransitionFinishedCallback finishCallback) throws RemoteException { - // TODO: hook up merge to recents onTaskAppeared if applicable. Until then, adapt - // to legacy cancel. - final Runnable finishRunnable; - synchronized (mFinishRunnables) { - finishRunnable = mFinishRunnables.remove(mergeTarget); - } - // Since we're not actually animating, release native memory now - t.close(); - info.releaseAllSurfaces(); - if (finishRunnable == null) return; - runner.onAnimationCancelled(); - finishRunnable.run(); - } - - @Override - public void onTransitionConsumed(IBinder iBinder, boolean aborted) - throws RemoteException { - } - }; - } -} diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java deleted file mode 100644 index e4d924323bbd..000000000000 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationTargetCompat.java +++ /dev/null @@ -1,86 +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.systemui.shared.system; - -import android.util.ArrayMap; -import android.view.RemoteAnimationTarget; -import android.view.SurfaceControl; -import android.window.TransitionInfo; -import android.window.TransitionInfo.Change; - -import com.android.wm.shell.shared.TransitionUtil; - -import java.util.ArrayList; -import java.util.function.Predicate; - -/** - * Some utility methods for creating {@link RemoteAnimationTarget} instances. - */ -public class RemoteAnimationTargetCompat { - - /** - * Represents a TransitionInfo object as an array of old-style app targets - * - * @param leashMap Temporary map of change leash -> launcher leash. Is an output, so should be - * populated by this function. If null, it is ignored. - */ - public static RemoteAnimationTarget[] wrapApps(TransitionInfo info, - SurfaceControl.Transaction t, ArrayMap leashMap) { - // LeafTaskFilter is order-dependent, so the same object needs to be used for all Change - // objects. That's why it's constructed here and captured by the lambda instead of building - // a new one ad hoc every time. - TransitionUtil.LeafTaskFilter taskFilter = new TransitionUtil.LeafTaskFilter(); - return wrap(info, t, leashMap, (change) -> { - // Intra-task activity -> activity transitions should be categorized as apps. - if (change.getActivityComponent() != null) return true; - return taskFilter.test(change); - }); - } - - /** - * Represents a TransitionInfo object as an array of old-style non-app targets - * - * @param wallpapers If true, this will return wallpaper targets; otherwise it returns - * non-wallpaper targets. - * @param leashMap Temporary map of change leash -> launcher leash. Is an output, so should be - * populated by this function. If null, it is ignored. - */ - public static RemoteAnimationTarget[] wrapNonApps(TransitionInfo info, boolean wallpapers, - SurfaceControl.Transaction t, ArrayMap leashMap) { - return wrap(info, t, leashMap, (change) -> { - // Intra-task activity -> activity transitions should be categorized as apps. - if (change.getActivityComponent() != null) return false; - return wallpapers - ? TransitionUtil.isWallpaper(change) : TransitionUtil.isNonApp(change); - }); - } - - private static RemoteAnimationTarget[] wrap(TransitionInfo info, - SurfaceControl.Transaction t, ArrayMap leashMap, - Predicate filter) { - final ArrayList out = new ArrayList<>(); - for (int i = 0; i < info.getChanges().size(); i++) { - TransitionInfo.Change change = info.getChanges().get(i); - if (TransitionUtil.isOrderOnly(change)) continue; - if (filter.test(change)) { - out.add(TransitionUtil.newTarget( - change, info.getChanges().size() - i, info, t, leashMap)); - } - } - return out.toArray(new RemoteAnimationTarget[out.size()]); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index 9052409b4d8d..a1fae03a2090 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -39,11 +39,11 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.keyguard.AuthKeyguardMessageArea; import com.android.systemui.Dumpable; import com.android.systemui.animation.ActivityTransitionAnimator; +import com.android.systemui.animation.RemoteAnimationRunnerCompat; import com.android.systemui.display.data.repository.DisplayMetricsRepository; import com.android.systemui.navigationbar.NavigationBarView; import com.android.systemui.plugins.ActivityStarter.OnDismissAction; import com.android.systemui.qs.QSPanelController; -import com.android.systemui.shared.system.RemoteAnimationRunnerCompat; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.util.Compile; diff --git a/packages/SystemUI/tests/src/com/android/systemui/shared/system/RemoteTransitionTest.java b/packages/SystemUI/tests/src/com/android/systemui/shared/system/RemoteTransitionTest.java index 460892af1154..660e8da72bf1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shared/system/RemoteTransitionTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shared/system/RemoteTransitionTest.java @@ -49,6 +49,7 @@ import android.window.TransitionInfo; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; +import com.android.systemui.animation.RemoteAnimationTargetCompat; import com.android.wm.shell.shared.TransitionUtil; import org.junit.Before; -- cgit v1.2.3-59-g8ed1b