From acd2f586932382b2eab641abab55ecd8946fe919 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Thu, 28 May 2020 17:58:40 -0700 Subject: [PATCH] Start quickswitch on task switch instead of touch down Previously we would enter a quickswitch session state whenever user tapped on navbar and sent flags to sysui to only enable edge gesture for the current rotation. Now we only do that on a new task resulting from the gesture or when going into recents to show nav bar in the orientation user would expect it (only if they never quickswitched). Fixes: 155844780 Test: Tested swiping back from quickswitching into apps of different orientations. Note that back is still broken when you quickswitch and then rotate the foreground app. Change-Id: I935e7c66489d46e59156414d64653c846ae4c5d8 --- .../quickstep/BaseSwipeUpHandlerV2.java | 7 +- .../quickstep/TouchInteractionService.java | 2 +- .../OtherActivityInputConsumer.java | 5 ++ .../com/android/quickstep/InputConsumer.java | 5 ++ .../OrientationTouchTransformer.java | 28 +++++--- .../RecentsAnimationDeviceState.java | 71 ++++++++++++++----- 6 files changed, 85 insertions(+), 33 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java index 46799ff272..1be0bac417 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java @@ -29,6 +29,7 @@ import static com.android.quickstep.GestureState.GestureEndTarget.LAST_TASK; import static com.android.quickstep.GestureState.GestureEndTarget.NEW_TASK; import static com.android.quickstep.GestureState.GestureEndTarget.RECENTS; import static com.android.quickstep.GestureState.STATE_END_TARGET_ANIMATION_FINISHED; +import static com.android.quickstep.GestureState.STATE_END_TARGET_SET; import static com.android.quickstep.GestureState.STATE_RECENTS_SCROLLING_FINISHED; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS; @@ -253,6 +254,10 @@ public abstract class BaseSwipeUpHandlerV2, Q exte mStateCallback.runOnceAtState(STATE_HANDLER_INVALIDATED | STATE_RESUME_LAST_TASK, this::notifyTransitionCancelled); + mGestureState.runOnceAtState(STATE_END_TARGET_SET, + () -> mDeviceState.onEndTargetCalculated(mGestureState.getEndTarget(), + mActivityInterface)); + if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) { mStateCallback.addChangeListener(STATE_APP_CONTROLLER_RECEIVED | STATE_LAUNCHER_PRESENT | STATE_SCREENSHOT_VIEW_SHOWN | STATE_CAPTURE_SCREENSHOT, @@ -1232,7 +1237,6 @@ public abstract class BaseSwipeUpHandlerV2, Q exte } ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", true); doLogGesture(HOME); - mDeviceState.enableMultipleRegions(false); } protected abstract void finishRecentsControllerToHome(Runnable callback); @@ -1248,7 +1252,6 @@ public abstract class BaseSwipeUpHandlerV2, Q exte SystemUiProxy.INSTANCE.get(mContext).onOverviewShown(false, TAG); doLogGesture(RECENTS); - mDeviceState.onSwipeUpToOverview(mActivityInterface); reset(); } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java index 4954588790..8c772408a8 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -613,7 +613,7 @@ public class TouchInteractionService extends Service implements PluginListener { - mInOverview = false; - enableMultipleRegions(false); - }); + void enableMultipleRegions(boolean enable) { + mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo()); + notifySysuiForRotation(mOrientationTouchTransformer.getQuickStepStartingRotation()); } - void enableMultipleRegions(boolean enable) { - if (mInOverview) { - return; + private void notifySysuiForRotation(int rotation) { + UI_HELPER_EXECUTOR.execute(() -> + SystemUiProxy.INSTANCE.get(mContext).onQuickSwitchToNewTask(rotation)); + } + + public void onStartGesture() { + if (mTaskListFrozen) { + // Prioritize whatever nav bar user touches once in quickstep + // This case is specifically when user changes what nav bar they are using mid + // quickswitch session before tasks list is unfrozen + notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); + } + } + + + void onEndTargetCalculated(GestureState.GestureEndTarget endTarget, + BaseActivityInterface activityInterface) { + if (endTarget == GestureState.GestureEndTarget.RECENTS) { + mInOverview = true; + if (!mTaskListFrozen) { + // If we're in landscape w/o ever quickswitching, show the navbar in landscape + enableMultipleRegions(true); + } + activityInterface.onExitOverview(this, () -> { + mInOverview = false; + enableMultipleRegions(false); + }); + } else if (endTarget == GestureState.GestureEndTarget.HOME) { + enableMultipleRegions(false); + } else if (endTarget == GestureState.GestureEndTarget.NEW_TASK) { + if (mOrientationTouchTransformer.getQuickStepStartingRotation() == -1) { + // First gesture to start quickswitch + enableMultipleRegions(true); + } else { + notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); + } + } else if (endTarget == GestureState.GestureEndTarget.LAST_TASK) { + if (!mTaskListFrozen) { + // touched nav bar but didn't go anywhere and not quickswitching, do nothing + return; + } + notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); } - mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo()); - UI_HELPER_EXECUTOR.execute(() -> { - int quickStepStartingRotation = - mOrientationTouchTransformer.getQuickStepStartingRotation(); - SystemUiProxy.INSTANCE.get(mContext) - .onQuickSwitchToNewTask(quickStepStartingRotation); - }); } public int getCurrentActiveRotation() {