From 10de7a4f56852e5d81a11be60535f27b06a512a0 Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Wed, 1 Sep 2021 23:49:54 +0800 Subject: [PATCH] Fix first drag to split not working There's a timing when dragging to split opening a new app, the new app might not be put into DC.mOpeningApps yet while startLegacyTransition triggering app transition. And result to executing an extra TRANSIT_NONE app transition. This patch leaves the app transition triggering to ActivityTaskSupervisor.reportResumedActivityLocked where the new opening app has been put into DC.mOpeningApps. With CL[1], it'll invoke onAnimationCancelled when there's no valid app to anmate while executing app transition. So we don't need to cancel animation with startActivity result. Also unbind exit split screen logic with onAnimationCancelled in wm-shell since it only enters split screen after a new task being launched/reparented to the side stage root after CL[2]. [1]: I50ddc91f7bd7ed24a977fa3face9c6e56e1bea02 [2]: I1cad96f6265eb1a14369bfc708871f701764066a Fix: 197917994 Test: drag and drop to split works Change-Id: If9ab7c3a89c8153c3731103571162fe21c94b3aa --- .../splitscreen/SplitScreenController.java | 36 +++++++------------ .../server/wm/WindowOrganizerController.java | 12 +------ 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java index 437b52a31ee43..e74e116a2157a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java @@ -22,7 +22,6 @@ import static android.view.RemoteAnimationTarget.MODE_OPENING; import static com.android.wm.shell.common.ExecutorUtils.executeRemoteCallWithTaskPermission; import static com.android.wm.shell.common.split.SplitLayout.SPLIT_POSITION_BOTTOM_OR_RIGHT; import static com.android.wm.shell.common.split.SplitLayout.SPLIT_POSITION_TOP_OR_LEFT; -import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_MAIN; import android.app.ActivityManager; import android.app.ActivityTaskManager; @@ -76,6 +75,7 @@ import java.util.concurrent.Executor; * {@link SplitScreen}. * @see StageCoordinator */ +// TODO(b/198577848): Implement split screen flicker test to consolidate CUJ of split screen. public class SplitScreenController implements DragAndDropPolicy.Starter, RemoteCallable { private static final String TAG = SplitScreenController.class.getSimpleName(); @@ -241,46 +241,34 @@ public class SplitScreenController implements DragAndDropPolicy.Starter, private void startIntentLegacy(PendingIntent intent, Intent fillInIntent, @SplitScreen.StageType int stage, @SplitPosition int position, @Nullable Bundle options) { - final boolean wasInSplit = isSplitScreenVisible(); - LegacyTransitions.ILegacyTransition transition = new LegacyTransitions.ILegacyTransition() { @Override public void onAnimationStart(int transit, RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers, RemoteAnimationTarget[] nonApps, IRemoteAnimationFinishedCallback finishedCallback, SurfaceControl.Transaction t) { - boolean cancelled = apps == null || apps.length == 0; mStageCoordinator.updateSurfaceBounds(null /* layout */, t); - if (cancelled) { - if (!wasInSplit) { - final WindowContainerTransaction undoWct = new WindowContainerTransaction(); - mStageCoordinator.prepareExitSplitScreen(STAGE_TYPE_MAIN, undoWct); - mSyncQueue.queue(undoWct); - mSyncQueue.runInSync(undoT -> { - // looks weird, but we want undoT to execute after t but still want the - // rest of the syncQueue runnables to aggregate. - t.merge(undoT); - undoT.merge(t); - }); - return; - } - } else { + + if (apps != null) { for (int i = 0; i < apps.length; ++i) { if (apps[i].mode == MODE_OPENING) { t.show(apps[i].leash); } } } - RemoteAnimationTarget divider = mStageCoordinator.getDividerBarLegacyTarget(); + + final RemoteAnimationTarget divider = mStageCoordinator.getDividerBarLegacyTarget(); if (divider.leash != null) { t.show(divider.leash); } + t.apply(); - if (cancelled) return; - try { - finishedCallback.onAnimationFinished(); - } catch (RemoteException e) { - Slog.e(TAG, "Error finishing legacy transition: ", e); + if (finishedCallback != null) { + try { + finishedCallback.onAnimationFinished(); + } catch (RemoteException e) { + Slog.e(TAG, "Error finishing legacy transition: ", e); + } } } }; diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java index b568774903c27..8bcd62dffca1c 100644 --- a/services/core/java/com/android/server/wm/WindowOrganizerController.java +++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java @@ -275,8 +275,6 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub syncId = startSyncWithOrganizer(callback); applyTransaction(t, syncId, null /* transition */, caller); setSyncReady(syncId); - mService.mRootWindowContainer.getDisplayContent(DEFAULT_DISPLAY) - .executeAppTransition(); } } finally { Binder.restoreCallingIdentity(ident); @@ -653,18 +651,10 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub options = activityOptions.toBundle(); } - int res = mService.mAmInternal.sendIntentSender(hop.getPendingIntent().getTarget(), + mService.mAmInternal.sendIntentSender(hop.getPendingIntent().getTarget(), hop.getPendingIntent().getWhitelistToken(), 0 /* code */, hop.getActivityIntent(), resolvedType, null /* finishReceiver */, null /* requiredPermission */, options); - if (res != ActivityManager.START_SUCCESS - && res != ActivityManager.START_TASK_TO_FRONT) { - if (!mTransitionController.isShellTransitionsEnabled()) { - final DisplayContent dc = - mService.mRootWindowContainer.getDisplayContent(DEFAULT_DISPLAY); - dc.cancelAppTransition(); - } - } break; case HIERARCHY_OP_TYPE_CREATE_TASK_FRAGMENT: final TaskFragmentCreationParams taskFragmentCreationOptions =