diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index 4e892e2722..ab3ae9f1dc 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -149,6 +149,11 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { case TestProtocol.REQUEST_DISABLE_TRANSIENT_TASKBAR: enableTransientTaskbar(false); return response; + + case TestProtocol.REQUEST_SHELL_DRAG_READY: + response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, + SystemUiProxy.INSTANCE.get(mContext).isDragAndDropReady()); + return response; } return super.call(method, arg, extras); diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index 616ddef748..89f06f6895 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -70,6 +70,7 @@ import com.android.systemui.unfold.progress.IUnfoldAnimation; import com.android.systemui.unfold.progress.IUnfoldTransitionListener; import com.android.wm.shell.back.IBackAnimation; import com.android.wm.shell.desktopmode.IDesktopMode; +import com.android.wm.shell.draganddrop.IDragAndDrop; import com.android.wm.shell.onehanded.IOneHanded; import com.android.wm.shell.pip.IPip; import com.android.wm.shell.pip.IPipAnimationListener; @@ -128,6 +129,7 @@ public class SystemUiProxy implements ISystemUiProxy { private IBinder mOriginalTransactionToken = null; private IOnBackInvokedCallback mBackToLauncherCallback; private IRemoteAnimationRunner mBackToLauncherRunner; + private IDragAndDrop mDragAndDrop; // Used to dedupe calls to SystemUI private int mLastShelfHeight; @@ -203,7 +205,7 @@ public class SystemUiProxy implements ISystemUiProxy { IStartingWindow startingWindow, IRecentTasks recentTasks, ISysuiUnlockAnimationController sysuiUnlockAnimationController, IBackAnimation backAnimation, IDesktopMode desktopMode, - IUnfoldAnimation unfoldAnimation) { + IUnfoldAnimation unfoldAnimation, IDragAndDrop dragAndDrop) { unlinkToDeath(); mSystemUiProxy = proxy; mPip = pip; @@ -216,6 +218,7 @@ public class SystemUiProxy implements ISystemUiProxy { mBackAnimation = backAnimation; mDesktopMode = desktopMode; mUnfoldAnimation = unfoldAnimation; + mDragAndDrop = dragAndDrop; linkToDeath(); // re-attach the listeners once missing due to setProxy has not been initialized yet. setPipAnimationListener(mPipAnimationListener); @@ -230,7 +233,7 @@ public class SystemUiProxy implements ISystemUiProxy { } public void clearProxy() { - setProxy(null, null, null, null, null, null, null, null, null, null, null); + setProxy(null, null, null, null, null, null, null, null, null, null, null, null); } // TODO(141886704): Find a way to remove this @@ -1099,6 +1102,11 @@ public class SystemUiProxy implements ISystemUiProxy { Log.e(TAG, "Failed call setUnfoldAnimationListener", e); } } + + // + // Recents + // + /** * Starts the recents activity. The caller should manage the thread on which this is called. */ @@ -1131,10 +1139,30 @@ public class SystemUiProxy implements ISystemUiProxy { try { mRecentTasks.startRecentsTransition(mRecentsPendingIntent, intent, optsBundle, mContext.getIApplicationThread(), runner); + return true; } catch (RemoteException e) { Log.e(TAG, "Error starting recents via shell", e); return false; } - return true; + } + + // + // Drag and drop + // + + /** + * For testing purposes. Returns `true` only if the shell drop target has shown and + * drawn and is ready to handle drag events and the subsequent drop. + */ + public boolean isDragAndDropReady() { + if (mDragAndDrop == null) { + return false; + } + try { + return mDragAndDrop.isReadyToHandleDrag(); + } catch (RemoteException e) { + Log.e(TAG, "Error querying drag state", e); + return false; + } } } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 038c6743dd..6ea171e6e2 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -43,6 +43,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_Q import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_TRACING_ENABLED; import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_BACK_ANIMATION; import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_DESKTOP_MODE; +import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_DRAG_AND_DROP; import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_ONE_HANDED; import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_PIP; import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_RECENT_TASKS; @@ -125,6 +126,7 @@ import com.android.systemui.shared.tracing.ProtoTraceable; import com.android.systemui.unfold.progress.IUnfoldAnimation; import com.android.wm.shell.back.IBackAnimation; import com.android.wm.shell.desktopmode.IDesktopMode; +import com.android.wm.shell.draganddrop.IDragAndDrop; import com.android.wm.shell.onehanded.IOneHanded; import com.android.wm.shell.pip.IPip; import com.android.wm.shell.recents.IRecentTasks; @@ -185,11 +187,13 @@ public class TouchInteractionService extends Service bundle.getBinder(KEY_EXTRA_SHELL_DESKTOP_MODE)); IUnfoldAnimation unfoldTransition = IUnfoldAnimation.Stub.asInterface( bundle.getBinder(KEY_EXTRA_UNFOLD_ANIMATION_FORWARDER)); + IDragAndDrop dragAndDrop = IDragAndDrop.Stub.asInterface( + bundle.getBinder(KEY_EXTRA_SHELL_DRAG_AND_DROP)); MAIN_EXECUTOR.execute(() -> { SystemUiProxy.INSTANCE.get(TouchInteractionService.this).setProxy(proxy, pip, splitscreen, onehanded, shellTransitions, startingWindow, recentTasks, launcherUnlockAnimationController, backAnimation, desktopMode, - unfoldTransition); + unfoldTransition, dragAndDrop); TouchInteractionService.this.initInputMonitor("TISBinder#onInitialize()"); preloadOverview(true /* fromInit */); }); diff --git a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java index 36255b4628..b472cdbea3 100644 --- a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java +++ b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java @@ -111,6 +111,7 @@ public final class TestProtocol { public static final String REQUEST_IS_TABLET = "is-tablet"; public static final String REQUEST_IS_TWO_PANELS = "is-two-panel"; public static final String REQUEST_START_DRAG_THRESHOLD = "start-drag-threshold"; + public static final String REQUEST_SHELL_DRAG_READY = "shell-drag-ready"; public static final String REQUEST_GET_ACTIVITIES_CREATED_COUNT = "get-activities-created-count"; public static final String REQUEST_GET_ACTIVITIES = "get-activities"; diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java index 4a3507ed69..58d5a36d66 100644 --- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java +++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java @@ -16,11 +16,14 @@ package com.android.launcher3.tapl; +import static com.android.launcher3.tapl.LauncherInstrumentation.DEFAULT_POLL_INTERVAL; import static com.android.launcher3.tapl.LauncherInstrumentation.TASKBAR_RES_ID; +import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_BLOCK_TIMEOUT; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_BLOCK_TIMEOUT; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING; +import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_SHELL_DRAG_READY; import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_STASHED_TASKBAR_HEIGHT; import android.graphics.Point; @@ -146,6 +149,12 @@ public final class LaunchedAppState extends Background { try (LauncherInstrumentation.Closable c2 = launcher.addContextLayer( "started item drag")) { + launcher.assertTrue("Shell drag not marked as ready", launcher.waitAndGet(() -> { + LauncherInstrumentation.log("Checking shell drag ready"); + return launcher.getTestInfo(REQUEST_SHELL_DRAG_READY) + .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, false); + }, WAIT_TIME_MS, DEFAULT_POLL_INTERVAL)); + launcher.movePointer( dragStart, endPoint,