From 3bf889a02fbaf01c72f6e9a1df9962f66fe8cd98 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Tue, 30 Jun 2020 16:43:51 -0700 Subject: [PATCH] Fixes the issue Launcher state propagation is slower than onDeferredResume. There's currently a bug prevents Launcher release drag lock for two step widgets. Supposedly, onDeferredResume should release the drag lock; However, in 3-button navigation mode, the transition from Overview -> Normal is triggered in Launcher#onNewIntent, which happens after onDeferredResume. This issue is not reproducible with gesture navigation because its transition from Overview -> Normal is handled in NavBarToHomeTouchController Test: manual verified with following steps 1. Enable 3-button navigation 2. Long press in WorkSpace -> Widgets 3. Drag Settings Widget to WorkSpace 4. When the config activity is shown, press "recents" button to see Overview 5. press "home" button to go back to workspace 6. repeat 2 and 3, verify the widget can be dragged Bug: 149659788 Change-Id: I396ffa8a7db44bf3872a10de4208340a99a7efe8 --- .../src/com/android/launcher3/BaseQuickstepLauncher.java | 6 ++++++ src/com/android/launcher3/Launcher.java | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 47ce320331..6b941be471 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -157,6 +157,12 @@ public abstract class BaseQuickstepLauncher extends Launcher @Override protected void onDeferredResumed() { super.onDeferredResumed(); + handlePendingActivityRequest(); + } + + @Override + protected void handlePendingActivityRequest() { + super.handlePendingActivityRequest(); if (mPendingActivityRequestCode != -1 && isInState(NORMAL)) { // Remove any active ProxyActivityStarter task and send RESULT_CANCELED to Launcher. onActivityResult(mPendingActivityRequestCode, RESULT_CANCELED, null); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 0970dae479..d06ae7a9c5 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -923,6 +923,7 @@ public class Launcher extends StatefulActivity implements Launche DiscoveryBounce.showForHomeIfNeeded(this); } + protected void handlePendingActivityRequest() { } private void logStopAndResume(int command) { int pageIndex = mWorkspace.isOverlayShown() ? -1 : mWorkspace.getCurrentPage(); @@ -1423,7 +1424,8 @@ public class Launcher extends StatefulActivity implements Launche if (!isInState(NORMAL)) { // Only change state, if not already the same. This prevents cancelling any // animations running as part of resume - mStateManager.goToState(NORMAL); + mStateManager.goToState(NORMAL, mStateManager.shouldAnimateStateChange(), + this::handlePendingActivityRequest); } // Reset the apps view