From 5fa247fd438bcdac79c471db4650f19688f1c46b Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Mon, 5 Jun 2023 17:10:13 -0700 Subject: [PATCH] Include assistant in RemoteTargetGluer * The UI isn't terribly great, but this fixes the crashes Bug: 285781761 Change-Id: Ie3376a98b16c19bbdb4e39e7a0a436ddae200c4a --- .../android/quickstep/RemoteTargetGluer.java | 28 +++++++++++++++++-- .../quickstep/util/TaskViewSimulator.java | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java index 84b90b9b78..27fb476c81 100644 --- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java +++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java @@ -16,6 +16,7 @@ package com.android.quickstep; +import android.app.WindowConfiguration; import android.content.Context; import android.graphics.Rect; import android.view.RemoteAnimationTarget; @@ -123,7 +124,14 @@ public class RemoteTargetGluer { mRemoteTargetHandles = newHandles; } + boolean containsSplitTargets = Arrays.stream(targets.apps) + .anyMatch(remoteAnimationTarget -> + remoteAnimationTarget.windowConfiguration.getWindowingMode() + == WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW); + if (mRemoteTargetHandles.length == 1) { + // Single fullscreen app + // If we're not in split screen, the splitIds count doesn't really matter since we // should always hit this case. mRemoteTargetHandles[0].mTransformParams.setTargetSet(targets); @@ -131,13 +139,29 @@ public class RemoteTargetGluer { // Unclear why/when target.apps length == 0, but it sure does happen :( mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(targets.apps[0], null); } + } else if (!containsSplitTargets) { + // Single App + Assistant + for (int i = 0; i < mRemoteTargetHandles.length; i++) { + mRemoteTargetHandles[i].mTransformParams.setTargetSet(targets); + mRemoteTargetHandles[i].mTaskViewSimulator.setPreview(targets.apps[i], null); + } } else { - RemoteAnimationTarget topLeftTarget = targets.apps[0]; + // Split apps (+ maybe assistant) + RemoteAnimationTarget topLeftTarget = Arrays.stream(targets.apps) + .filter(remoteAnimationTarget -> + remoteAnimationTarget.windowConfiguration.getWindowingMode() + == WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW) + .findFirst().get(); // Fetch the adjacent target for split screen. RemoteAnimationTarget bottomRightTarget = null; - for (int i = 1; i < targets.apps.length; i++) { + for (int i = 0; i < targets.apps.length; i++) { final RemoteAnimationTarget target = targets.apps[i]; + if (target.windowConfiguration.getWindowingMode() != + WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW || + target == topLeftTarget) { + continue; + } Rect topLeftBounds = getStartBounds(topLeftTarget); Rect bounds = getStartBounds(target); if (topLeftBounds.left > bounds.right || topLeftBounds.top > bounds.bottom) { diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index f8893bd9dd..303a5283d8 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -411,7 +411,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { // transitions, the animation leashes are reparented to an animation container so we // can bump layers as needed. builder.setLayer(mDrawsBelowRecents - ? Integer.MIN_VALUE + 1 + ? Integer.MIN_VALUE + app.prefixOrderIndex : ENABLE_SHELL_TRANSITIONS ? Integer.MAX_VALUE : 0); } }