Removing RemoteAnimationTargetCompat and using RemoteAnimationTarget directly

Bug: 221961069
Test: Presubmit
Change-Id: I4497b44677a5c32bbf5dc0745559b3bc2f2efcc8
This commit is contained in:
Sunny Goyal
2022-10-19 16:15:07 -07:00
parent 61a511a3d4
commit 8b94a4bb36
7 changed files with 118 additions and 223 deletions

View File

@@ -194,12 +194,8 @@ public class ActivityManagerWrapper {
Rect homeContentInsets, Rect minimizedHomeBounds) { Rect homeContentInsets, Rect minimizedHomeBounds) {
final RecentsAnimationControllerCompat controllerCompat = final RecentsAnimationControllerCompat controllerCompat =
new RecentsAnimationControllerCompat(controller); new RecentsAnimationControllerCompat(controller);
final RemoteAnimationTargetCompat[] appsCompat = animationHandler.onAnimationStart(controllerCompat, apps,
RemoteAnimationTargetCompat.wrap(apps); wallpapers, homeContentInsets, minimizedHomeBounds);
final RemoteAnimationTargetCompat[] wallpapersCompat =
RemoteAnimationTargetCompat.wrap(wallpapers);
animationHandler.onAnimationStart(controllerCompat, appsCompat,
wallpapersCompat, homeContentInsets, minimizedHomeBounds);
} }
@Override @Override
@@ -210,12 +206,7 @@ public class ActivityManagerWrapper {
@Override @Override
public void onTasksAppeared(RemoteAnimationTarget[] apps) { public void onTasksAppeared(RemoteAnimationTarget[] apps) {
final RemoteAnimationTargetCompat[] compats = animationHandler.onTasksAppeared(apps);
new RemoteAnimationTargetCompat[apps.length];
for (int i = 0; i < apps.length; ++i) {
compats[i] = new RemoteAnimationTargetCompat(apps[i]);
}
animationHandler.onTasksAppeared(compats);
} }
}; };
} }

View File

@@ -17,6 +17,7 @@
package com.android.systemui.shared.system; package com.android.systemui.shared.system;
import android.graphics.Rect; import android.graphics.Rect;
import android.view.RemoteAnimationTarget;
import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.recents.model.ThumbnailData;
@@ -27,7 +28,7 @@ public interface RecentsAnimationListener {
* Called when the animation into Recents can start. This call is made on the binder thread. * Called when the animation into Recents can start. This call is made on the binder thread.
*/ */
void onAnimationStart(RecentsAnimationControllerCompat controller, void onAnimationStart(RecentsAnimationControllerCompat controller,
RemoteAnimationTargetCompat[] apps, RemoteAnimationTargetCompat[] wallpapers, RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers,
Rect homeContentInsets, Rect minimizedHomeBounds); Rect homeContentInsets, Rect minimizedHomeBounds);
/** /**
@@ -39,7 +40,7 @@ public interface RecentsAnimationListener {
* Called when the task of an activity that has been started while the recents animation * Called when the task of an activity that has been started while the recents animation
* was running becomes ready for control. * was running becomes ready for control.
*/ */
void onTasksAppeared(RemoteAnimationTargetCompat[] app); void onTasksAppeared(RemoteAnimationTarget[] app);
/** /**
* Called to request that the current task tile be switched out for a screenshot (if not * Called to request that the current task tile be switched out for a screenshot (if not

View File

@@ -83,12 +83,6 @@ public class RemoteAnimationAdapterCompat {
RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] wallpapers,
RemoteAnimationTarget[] nonApps, RemoteAnimationTarget[] nonApps,
final IRemoteAnimationFinishedCallback finishedCallback) { final IRemoteAnimationFinishedCallback finishedCallback) {
final RemoteAnimationTargetCompat[] appsCompat =
RemoteAnimationTargetCompat.wrap(apps);
final RemoteAnimationTargetCompat[] wallpapersCompat =
RemoteAnimationTargetCompat.wrap(wallpapers);
final RemoteAnimationTargetCompat[] nonAppsCompat =
RemoteAnimationTargetCompat.wrap(nonApps);
final Runnable animationFinishedCallback = new Runnable() { final Runnable animationFinishedCallback = new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -100,8 +94,8 @@ public class RemoteAnimationAdapterCompat {
} }
} }
}; };
remoteAnimationAdapter.onAnimationStart(transit, appsCompat, wallpapersCompat, remoteAnimationAdapter.onAnimationStart(transit, apps, wallpapers,
nonAppsCompat, animationFinishedCallback); nonApps, animationFinishedCallback);
} }
@Override @Override
@@ -121,12 +115,12 @@ public class RemoteAnimationAdapterCompat {
SurfaceControl.Transaction t, SurfaceControl.Transaction t,
IRemoteTransitionFinishedCallback finishCallback) { IRemoteTransitionFinishedCallback finishCallback) {
final ArrayMap<SurfaceControl, SurfaceControl> leashMap = new ArrayMap<>(); final ArrayMap<SurfaceControl, SurfaceControl> leashMap = new ArrayMap<>();
final RemoteAnimationTargetCompat[] appsCompat = final RemoteAnimationTarget[] apps =
RemoteAnimationTargetCompat.wrapApps(info, t, leashMap); RemoteAnimationTargetCompat.wrapApps(info, t, leashMap);
final RemoteAnimationTargetCompat[] wallpapersCompat = final RemoteAnimationTarget[] wallpapers =
RemoteAnimationTargetCompat.wrapNonApps( RemoteAnimationTargetCompat.wrapNonApps(
info, true /* wallpapers */, t, leashMap); info, true /* wallpapers */, t, leashMap);
final RemoteAnimationTargetCompat[] nonAppsCompat = final RemoteAnimationTarget[] nonApps =
RemoteAnimationTargetCompat.wrapNonApps( RemoteAnimationTargetCompat.wrapNonApps(
info, false /* wallpapers */, t, leashMap); info, false /* wallpapers */, t, leashMap);
@@ -189,9 +183,9 @@ public class RemoteAnimationAdapterCompat {
} }
} }
// Make wallpaper visible immediately since launcher apparently won't do this. // Make wallpaper visible immediately since launcher apparently won't do this.
for (int i = wallpapersCompat.length - 1; i >= 0; --i) { for (int i = wallpapers.length - 1; i >= 0; --i) {
t.show(wallpapersCompat[i].leash); t.show(wallpapers[i].leash);
t.setAlpha(wallpapersCompat[i].leash, 1.f); t.setAlpha(wallpapers[i].leash, 1.f);
} }
} else { } else {
if (launcherTask != null) { if (launcherTask != null) {
@@ -237,7 +231,7 @@ public class RemoteAnimationAdapterCompat {
} }
// TODO(bc-unlcok): Pass correct transit type. // TODO(bc-unlcok): Pass correct transit type.
remoteAnimationAdapter.onAnimationStart(TRANSIT_OLD_NONE, remoteAnimationAdapter.onAnimationStart(TRANSIT_OLD_NONE,
appsCompat, wallpapersCompat, nonAppsCompat, () -> { apps, wallpapers, nonApps, () -> {
synchronized (mFinishRunnables) { synchronized (mFinishRunnables) {
if (mFinishRunnables.remove(token) == null) return; if (mFinishRunnables.remove(token) == null) return;
} }

View File

@@ -16,11 +16,12 @@
package com.android.systemui.shared.system; package com.android.systemui.shared.system;
import android.view.RemoteAnimationTarget;
import android.view.WindowManager; import android.view.WindowManager;
public interface RemoteAnimationRunnerCompat { public interface RemoteAnimationRunnerCompat {
void onAnimationStart(@WindowManager.TransitionOldType int transit, void onAnimationStart(@WindowManager.TransitionOldType int transit,
RemoteAnimationTargetCompat[] apps, RemoteAnimationTargetCompat[] wallpapers, RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers,
RemoteAnimationTargetCompat[] nonApps, Runnable finishedCallback); RemoteAnimationTarget[] nonApps, Runnable finishedCallback);
void onAnimationCancelled(); void onAnimationCancelled();
} }

View File

@@ -11,12 +11,15 @@
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License * limitations under the License.
*/ */
package com.android.systemui.shared.system; package com.android.systemui.shared.system;
import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.view.RemoteAnimationTarget.MODE_CHANGING;
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.RemoteAnimationTarget.MODE_OPENING;
import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE; import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_CLOSE;
@@ -29,88 +32,28 @@ import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPI
import static com.android.wm.shell.common.split.SplitScreenConstants.FLAG_IS_DIVIDER_BAR; import static com.android.wm.shell.common.split.SplitScreenConstants.FLAG_IS_DIVIDER_BAR;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.TaskInfo;
import android.app.WindowConfiguration; import android.app.WindowConfiguration;
import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.SparseArray; import android.util.SparseBooleanArray;
import android.view.RemoteAnimationTarget; import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl; import android.view.SurfaceControl;
import android.view.WindowManager; import android.view.WindowManager;
import android.window.TransitionInfo; import android.window.TransitionInfo;
import android.window.TransitionInfo.Change;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.function.BiPredicate;
/** /**
* @see RemoteAnimationTarget * Some utility methods for creating {@link RemoteAnimationTarget} instances.
*/ */
public class RemoteAnimationTargetCompat { public class RemoteAnimationTargetCompat {
public static final int MODE_OPENING = RemoteAnimationTarget.MODE_OPENING;
public static final int MODE_CLOSING = RemoteAnimationTarget.MODE_CLOSING;
public static final int MODE_CHANGING = RemoteAnimationTarget.MODE_CHANGING;
public final int mode;
public static final int ACTIVITY_TYPE_UNDEFINED = WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
public static final int ACTIVITY_TYPE_STANDARD = WindowConfiguration.ACTIVITY_TYPE_STANDARD;
public static final int ACTIVITY_TYPE_HOME = WindowConfiguration.ACTIVITY_TYPE_HOME;
public static final int ACTIVITY_TYPE_RECENTS = WindowConfiguration.ACTIVITY_TYPE_RECENTS;
public static final int ACTIVITY_TYPE_ASSISTANT = WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
public final int activityType;
public final int taskId;
public final SurfaceControl leash;
public final boolean isTranslucent;
public final Rect clipRect;
public final int prefixOrderIndex;
public final Point position;
public final Rect localBounds;
public final Rect sourceContainerBounds;
public final Rect screenSpaceBounds;
public final Rect startScreenSpaceBounds;
public final boolean isNotInRecents;
public final Rect contentInsets;
public final ActivityManager.RunningTaskInfo taskInfo;
public final boolean allowEnterPip;
public final int rotationChange;
public final int windowType;
public final WindowConfiguration windowConfiguration;
private final SurfaceControl mStartLeash;
// Fields used only to unwrap into RemoteAnimationTarget
private final Rect startBounds;
public final boolean willShowImeOnTarget;
public RemoteAnimationTargetCompat(RemoteAnimationTarget app) {
taskId = app.taskId;
mode = app.mode;
leash = app.leash;
isTranslucent = app.isTranslucent;
clipRect = app.clipRect;
position = app.position;
localBounds = app.localBounds;
sourceContainerBounds = app.sourceContainerBounds;
screenSpaceBounds = app.screenSpaceBounds;
startScreenSpaceBounds = screenSpaceBounds;
prefixOrderIndex = app.prefixOrderIndex;
isNotInRecents = app.isNotInRecents;
contentInsets = app.contentInsets;
activityType = app.windowConfiguration.getActivityType();
taskInfo = app.taskInfo;
allowEnterPip = app.allowEnterPip;
rotationChange = app.rotationChange;
mStartLeash = app.startLeash;
windowType = app.windowType;
windowConfiguration = app.windowConfiguration;
startBounds = app.startBounds;
willShowImeOnTarget = app.willShowImeOnTarget;
}
private static int newModeToLegacyMode(int newMode) { private static int newModeToLegacyMode(int newMode) {
switch (newMode) { switch (newMode) {
case WindowManager.TRANSIT_OPEN: case WindowManager.TRANSIT_OPEN:
@@ -120,21 +63,10 @@ public class RemoteAnimationTargetCompat {
case WindowManager.TRANSIT_TO_BACK: case WindowManager.TRANSIT_TO_BACK:
return MODE_CLOSING; return MODE_CLOSING;
default: default:
return 2; // MODE_CHANGING return MODE_CHANGING;
} }
} }
public RemoteAnimationTarget unwrap() {
final RemoteAnimationTarget target = new RemoteAnimationTarget(
taskId, mode, leash, isTranslucent, clipRect, contentInsets,
prefixOrderIndex, position, localBounds, screenSpaceBounds, windowConfiguration,
isNotInRecents, mStartLeash, startBounds, taskInfo, allowEnterPip, windowType
);
target.setWillShowImeOnTarget(willShowImeOnTarget);
target.setRotationChange(rotationChange);
return target;
}
/** /**
* Almost a copy of Transitions#setupStartState. * Almost a copy of Transitions#setupStartState.
* TODO: remove when there is proper cross-process transaction sync. * TODO: remove when there is proper cross-process transaction sync.
@@ -206,54 +138,61 @@ public class RemoteAnimationTargetCompat {
return leashSurface; return leashSurface;
} }
public RemoteAnimationTargetCompat(TransitionInfo.Change change, int order, /**
TransitionInfo info, SurfaceControl.Transaction t) { * Creates a new RemoteAnimationTarget from the provided change info
mode = newModeToLegacyMode(change.getMode()); */
public static RemoteAnimationTarget newTarget(TransitionInfo.Change change, int order,
TransitionInfo info, SurfaceControl.Transaction t,
@Nullable ArrayMap<SurfaceControl, SurfaceControl> leashMap) {
int taskId;
boolean isNotInRecents;
ActivityManager.RunningTaskInfo taskInfo;
WindowConfiguration windowConfiguration;
taskInfo = change.getTaskInfo(); taskInfo = change.getTaskInfo();
if (taskInfo != null) { if (taskInfo != null) {
taskId = taskInfo.taskId; taskId = taskInfo.taskId;
isNotInRecents = !taskInfo.isRunning; isNotInRecents = !taskInfo.isRunning;
activityType = taskInfo.getActivityType();
windowConfiguration = taskInfo.configuration.windowConfiguration; windowConfiguration = taskInfo.configuration.windowConfiguration;
} else { } else {
taskId = INVALID_TASK_ID; taskId = INVALID_TASK_ID;
isNotInRecents = true; isNotInRecents = true;
activityType = ACTIVITY_TYPE_UNDEFINED;
windowConfiguration = new WindowConfiguration(); windowConfiguration = new WindowConfiguration();
} }
// TODO: once we can properly sync transactions across process, then get rid of this leash. Rect localBounds = new Rect(change.getEndAbsBounds());
leash = createLeash(info, change, order, t);
isTranslucent = (change.getFlags() & TransitionInfo.FLAG_TRANSLUCENT) != 0;
clipRect = null;
position = null;
localBounds = new Rect(change.getEndAbsBounds());
localBounds.offsetTo(change.getEndRelOffset().x, change.getEndRelOffset().y); localBounds.offsetTo(change.getEndRelOffset().x, change.getEndRelOffset().y);
sourceContainerBounds = null;
screenSpaceBounds = new Rect(change.getEndAbsBounds());
startScreenSpaceBounds = new Rect(change.getStartAbsBounds());
prefixOrderIndex = order; RemoteAnimationTarget target = new RemoteAnimationTarget(
// TODO(shell-transitions): I guess we need to send content insets? evaluate how its used. taskId,
contentInsets = new Rect(0, 0, 0, 0); newModeToLegacyMode(change.getMode()),
allowEnterPip = change.getAllowEnterPip(); // TODO: once we can properly sync transactions across process,
mStartLeash = null; // then get rid of this leash.
rotationChange = change.getEndRotation() - change.getStartRotation(); createLeash(info, change, order, t),
windowType = (change.getFlags() & FLAG_IS_DIVIDER_BAR) != 0 (change.getFlags() & TransitionInfo.FLAG_TRANSLUCENT) != 0,
? TYPE_DOCK_DIVIDER : INVALID_WINDOW_TYPE; null,
// TODO(shell-transitions): we need to send content insets? evaluate how its used.
startBounds = change.getStartAbsBounds(); new Rect(0, 0, 0, 0),
willShowImeOnTarget = (change.getFlags() & TransitionInfo.FLAG_WILL_IME_SHOWN) != 0; order,
null,
localBounds,
new Rect(change.getEndAbsBounds()),
windowConfiguration,
isNotInRecents,
null,
new Rect(change.getStartAbsBounds()),
taskInfo,
change.getAllowEnterPip(),
(change.getFlags() & FLAG_IS_DIVIDER_BAR) != 0
? TYPE_DOCK_DIVIDER : INVALID_WINDOW_TYPE
);
target.setWillShowImeOnTarget(
(change.getFlags() & TransitionInfo.FLAG_WILL_IME_SHOWN) != 0);
target.setRotationChange(change.getEndRotation() - change.getStartRotation());
if (leashMap != null) {
leashMap.put(change.getLeash(), target.leash);
} }
return target;
public static RemoteAnimationTargetCompat[] wrap(RemoteAnimationTarget[] apps) {
final int length = apps != null ? apps.length : 0;
final RemoteAnimationTargetCompat[] appsCompat = new RemoteAnimationTargetCompat[length];
for (int i = 0; i < length; i++) {
appsCompat[i] = new RemoteAnimationTargetCompat(apps[i]);
}
return appsCompat;
} }
/** /**
@@ -262,35 +201,20 @@ public class RemoteAnimationTargetCompat {
* @param leashMap Temporary map of change leash -> launcher leash. Is an output, so should be * @param leashMap Temporary map of change leash -> launcher leash. Is an output, so should be
* populated by this function. If null, it is ignored. * populated by this function. If null, it is ignored.
*/ */
public static RemoteAnimationTargetCompat[] wrapApps(TransitionInfo info, public static RemoteAnimationTarget[] wrapApps(TransitionInfo info,
SurfaceControl.Transaction t, ArrayMap<SurfaceControl, SurfaceControl> leashMap) { SurfaceControl.Transaction t, ArrayMap<SurfaceControl, SurfaceControl> leashMap) {
final ArrayList<RemoteAnimationTargetCompat> out = new ArrayList<>(); SparseBooleanArray childTaskTargets = new SparseBooleanArray();
final SparseArray<TransitionInfo.Change> childTaskTargets = new SparseArray<>(); return wrap(info, t, leashMap, (change, taskInfo) -> {
for (int i = 0; i < info.getChanges().size(); i++) {
final TransitionInfo.Change change = info.getChanges().get(i);
if (change.getTaskInfo() == null) continue;
final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo();
// Children always come before parent since changes are in top-to-bottom z-order. // Children always come before parent since changes are in top-to-bottom z-order.
if (taskInfo != null) { if ((taskInfo == null) || childTaskTargets.get(taskInfo.taskId)) {
if (childTaskTargets.contains(taskInfo.taskId)) {
// has children, so not a leaf. Skip. // has children, so not a leaf. Skip.
continue; return false;
} }
if (taskInfo.hasParentTask()) { if (taskInfo.hasParentTask()) {
childTaskTargets.put(taskInfo.parentTaskId, change); childTaskTargets.put(taskInfo.parentTaskId, true);
} }
} return true;
});
final RemoteAnimationTargetCompat targetCompat =
new RemoteAnimationTargetCompat(change, info.getChanges().size() - i, info, t);
if (leashMap != null) {
leashMap.put(change.getLeash(), targetCompat.leash);
}
out.add(targetCompat);
}
return out.toArray(new RemoteAnimationTargetCompat[out.size()]);
} }
/** /**
@@ -301,38 +225,22 @@ public class RemoteAnimationTargetCompat {
* @param leashMap Temporary map of change leash -> launcher leash. Is an output, so should be * @param leashMap Temporary map of change leash -> launcher leash. Is an output, so should be
* populated by this function. If null, it is ignored. * populated by this function. If null, it is ignored.
*/ */
public static RemoteAnimationTargetCompat[] wrapNonApps(TransitionInfo info, boolean wallpapers, public static RemoteAnimationTarget[] wrapNonApps(TransitionInfo info, boolean wallpapers,
SurfaceControl.Transaction t, ArrayMap<SurfaceControl, SurfaceControl> leashMap) { SurfaceControl.Transaction t, ArrayMap<SurfaceControl, SurfaceControl> leashMap) {
final ArrayList<RemoteAnimationTargetCompat> out = new ArrayList<>(); return wrap(info, t, leashMap, (change, taskInfo) -> (taskInfo == null)
&& wallpapers == ((change.getFlags() & TransitionInfo.FLAG_IS_WALLPAPER) != 0));
}
private static RemoteAnimationTarget[] wrap(TransitionInfo info,
SurfaceControl.Transaction t, ArrayMap<SurfaceControl, SurfaceControl> leashMap,
BiPredicate<Change, TaskInfo> filter) {
final ArrayList<RemoteAnimationTarget> out = new ArrayList<>();
for (int i = 0; i < info.getChanges().size(); i++) { for (int i = 0; i < info.getChanges().size(); i++) {
final TransitionInfo.Change change = info.getChanges().get(i); TransitionInfo.Change change = info.getChanges().get(i);
if (change.getTaskInfo() != null) continue; if (filter.test(change, change.getTaskInfo())) {
out.add(newTarget(change, info.getChanges().size() - i, info, t, leashMap));
final boolean changeIsWallpaper =
(change.getFlags() & TransitionInfo.FLAG_IS_WALLPAPER) != 0;
if (wallpapers != changeIsWallpaper) continue;
final RemoteAnimationTargetCompat targetCompat =
new RemoteAnimationTargetCompat(change, info.getChanges().size() - i, info, t);
if (leashMap != null) {
leashMap.put(change.getLeash(), targetCompat.leash);
}
out.add(targetCompat);
}
return out.toArray(new RemoteAnimationTargetCompat[out.size()]);
}
/**
* @see SurfaceControl#release()
*/
public void release() {
if (leash != null) {
leash.release();
}
if (mStartLeash != null) {
mStartLeash.release();
} }
} }
return out.toArray(new RemoteAnimationTarget[out.size()]);
}
} }

View File

@@ -17,7 +17,9 @@
package com.android.systemui.shared.system; package com.android.systemui.shared.system;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.WindowManager.TRANSIT_CHANGE; import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY; import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
@@ -27,8 +29,7 @@ import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT; import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.window.TransitionFilter.CONTAINER_ORDER_TOP; import static android.window.TransitionFilter.CONTAINER_ORDER_TOP;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_RECENTS; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.newTarget;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
@@ -45,6 +46,7 @@ import android.util.ArrayMap;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.IRecentsAnimationController; import android.view.IRecentsAnimationController;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl; import android.view.SurfaceControl;
import android.window.IRemoteTransition; import android.window.IRemoteTransition;
import android.window.IRemoteTransitionFinishedCallback; import android.window.IRemoteTransitionFinishedCallback;
@@ -127,9 +129,9 @@ public class RemoteTransitionCompat implements Parcelable {
SurfaceControl.Transaction t, SurfaceControl.Transaction t,
IRemoteTransitionFinishedCallback finishedCallback) { IRemoteTransitionFinishedCallback finishedCallback) {
final ArrayMap<SurfaceControl, SurfaceControl> leashMap = new ArrayMap<>(); final ArrayMap<SurfaceControl, SurfaceControl> leashMap = new ArrayMap<>();
final RemoteAnimationTargetCompat[] apps = final RemoteAnimationTarget[] apps =
RemoteAnimationTargetCompat.wrapApps(info, t, leashMap); RemoteAnimationTargetCompat.wrapApps(info, t, leashMap);
final RemoteAnimationTargetCompat[] wallpapers = final RemoteAnimationTarget[] wallpapers =
RemoteAnimationTargetCompat.wrapNonApps( RemoteAnimationTargetCompat.wrapNonApps(
info, true /* wallpapers */, t, leashMap); info, true /* wallpapers */, t, leashMap);
// TODO(b/177438007): Move this set-up logic into launcher's animation impl. // TODO(b/177438007): Move this set-up logic into launcher's animation impl.
@@ -230,7 +232,7 @@ public class RemoteTransitionCompat implements Parcelable {
private PictureInPictureSurfaceTransaction mPipTransaction = null; private PictureInPictureSurfaceTransaction mPipTransaction = null;
private IBinder mTransition = null; private IBinder mTransition = null;
private boolean mKeyguardLocked = false; private boolean mKeyguardLocked = false;
private RemoteAnimationTargetCompat[] mAppearedTargets; private RemoteAnimationTarget[] mAppearedTargets;
private boolean mWillFinishToHome = false; private boolean mWillFinishToHome = false;
void setup(RecentsAnimationControllerCompat wrapped, TransitionInfo info, void setup(RecentsAnimationControllerCompat wrapped, TransitionInfo info,
@@ -325,18 +327,15 @@ public class RemoteTransitionCompat implements Parcelable {
final int layer = mInfo.getChanges().size() * 3; final int layer = mInfo.getChanges().size() * 3;
mOpeningLeashes = new ArrayList<>(); mOpeningLeashes = new ArrayList<>();
mOpeningHome = cancelRecents; mOpeningHome = cancelRecents;
final RemoteAnimationTargetCompat[] targets = final RemoteAnimationTarget[] targets =
new RemoteAnimationTargetCompat[openingTasks.size()]; new RemoteAnimationTarget[openingTasks.size()];
for (int i = 0; i < openingTasks.size(); ++i) { for (int i = 0; i < openingTasks.size(); ++i) {
final TransitionInfo.Change change = openingTasks.valueAt(i); final TransitionInfo.Change change = openingTasks.valueAt(i);
mOpeningLeashes.add(change.getLeash()); mOpeningLeashes.add(change.getLeash());
// We are receiving new opening tasks, so convert to onTasksAppeared. // We are receiving new opening tasks, so convert to onTasksAppeared.
final RemoteAnimationTargetCompat target = new RemoteAnimationTargetCompat( targets[i] = newTarget(change, layer, info, t, mLeashMap);
change, layer, info, t); t.reparent(targets[i].leash, mInfo.getRootLeash());
mLeashMap.put(mOpeningLeashes.get(i), target.leash); t.setLayer(targets[i].leash, layer);
t.reparent(target.leash, mInfo.getRootLeash());
t.setLayer(target.leash, layer);
targets[i] = target;
} }
t.apply(); t.apply();
mAppearedTargets = targets; mAppearedTargets = targets;

View File

@@ -16,6 +16,11 @@
package com.android.systemui.shared.system; package com.android.systemui.shared.system;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.view.RemoteAnimationTarget.MODE_CHANGING;
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.RemoteAnimationTarget.MODE_OPENING;
import static android.view.WindowManager.TRANSIT_CHANGE; import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_OPEN;
@@ -25,11 +30,6 @@ import static android.window.TransitionInfo.FLAG_SHOW_WALLPAPER;
import static android.window.TransitionInfo.FLAG_TRANSLUCENT; import static android.window.TransitionInfo.FLAG_TRANSLUCENT;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_STANDARD;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CHANGING;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@@ -40,6 +40,7 @@ import android.app.ActivityManager;
import android.graphics.Rect; import android.graphics.Rect;
import android.testing.AndroidTestingRunner; import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper; import android.testing.TestableLooper;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl; import android.view.SurfaceControl;
import android.view.WindowManager; import android.view.WindowManager;
import android.window.TransitionInfo; import android.window.TransitionInfo;
@@ -73,12 +74,12 @@ public class RemoteTransitionTest extends SysuiTestCase {
.addChange(TRANSIT_OPEN, FLAG_IS_WALLPAPER, null /* taskInfo */) .addChange(TRANSIT_OPEN, FLAG_IS_WALLPAPER, null /* taskInfo */)
.addChange(TRANSIT_CHANGE, FLAG_FIRST_CUSTOM, null /* taskInfo */).build(); .addChange(TRANSIT_CHANGE, FLAG_FIRST_CUSTOM, null /* taskInfo */).build();
// Check apps extraction // Check apps extraction
RemoteAnimationTargetCompat[] wrapped = RemoteAnimationTargetCompat.wrapApps(combined, RemoteAnimationTarget[] wrapped = RemoteAnimationTargetCompat.wrapApps(combined,
mock(SurfaceControl.Transaction.class), null /* leashes */); mock(SurfaceControl.Transaction.class), null /* leashes */);
assertEquals(2, wrapped.length); assertEquals(2, wrapped.length);
int changeLayer = -1; int changeLayer = -1;
int closeLayer = -1; int closeLayer = -1;
for (RemoteAnimationTargetCompat t : wrapped) { for (RemoteAnimationTarget t : wrapped) {
if (t.mode == MODE_CHANGING) { if (t.mode == MODE_CHANGING) {
changeLayer = t.prefixOrderIndex; changeLayer = t.prefixOrderIndex;
} else if (t.mode == MODE_CLOSING) { } else if (t.mode == MODE_CLOSING) {
@@ -91,14 +92,14 @@ public class RemoteTransitionTest extends SysuiTestCase {
assertTrue(closeLayer < changeLayer); assertTrue(closeLayer < changeLayer);
// Check wallpaper extraction // Check wallpaper extraction
RemoteAnimationTargetCompat[] wallps = RemoteAnimationTargetCompat.wrapNonApps(combined, RemoteAnimationTarget[] wallps = RemoteAnimationTargetCompat.wrapNonApps(combined,
true /* wallpapers */, mock(SurfaceControl.Transaction.class), null /* leashes */); true /* wallpapers */, mock(SurfaceControl.Transaction.class), null /* leashes */);
assertEquals(1, wallps.length); assertEquals(1, wallps.length);
assertTrue(wallps[0].prefixOrderIndex < closeLayer); assertTrue(wallps[0].prefixOrderIndex < closeLayer);
assertEquals(MODE_OPENING, wallps[0].mode); assertEquals(MODE_OPENING, wallps[0].mode);
// Check non-apps extraction // Check non-apps extraction
RemoteAnimationTargetCompat[] nonApps = RemoteAnimationTargetCompat.wrapNonApps(combined, RemoteAnimationTarget[] nonApps = RemoteAnimationTargetCompat.wrapNonApps(combined,
false /* wallpapers */, mock(SurfaceControl.Transaction.class), null /* leashes */); false /* wallpapers */, mock(SurfaceControl.Transaction.class), null /* leashes */);
assertEquals(1, nonApps.length); assertEquals(1, nonApps.length);
assertTrue(nonApps[0].prefixOrderIndex < closeLayer); assertTrue(nonApps[0].prefixOrderIndex < closeLayer);
@@ -115,9 +116,9 @@ public class RemoteTransitionTest extends SysuiTestCase {
change.setTaskInfo(createTaskInfo(1 /* taskId */, ACTIVITY_TYPE_HOME)); change.setTaskInfo(createTaskInfo(1 /* taskId */, ACTIVITY_TYPE_HOME));
change.setEndAbsBounds(endBounds); change.setEndAbsBounds(endBounds);
change.setEndRelOffset(0, 0); change.setEndRelOffset(0, 0);
final RemoteAnimationTargetCompat wrapped = new RemoteAnimationTargetCompat(change, RemoteAnimationTarget wrapped = RemoteAnimationTargetCompat.newTarget(
0 /* order */, tinfo, mock(SurfaceControl.Transaction.class)); change, 0 /* order */, tinfo, mock(SurfaceControl.Transaction.class), null);
assertEquals(ACTIVITY_TYPE_HOME, wrapped.activityType); assertEquals(ACTIVITY_TYPE_HOME, wrapped.windowConfiguration.getActivityType());
assertEquals(new Rect(0, 0, 100, 140), wrapped.localBounds); assertEquals(new Rect(0, 0, 100, 140), wrapped.localBounds);
assertEquals(endBounds, wrapped.screenSpaceBounds); assertEquals(endBounds, wrapped.screenSpaceBounds);
assertTrue(wrapped.isTranslucent); assertTrue(wrapped.isTranslucent);