From d386d7da7c03bd0b66f0ff7327836520dc9acf32 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Thu, 17 Oct 2019 11:59:53 -0700 Subject: [PATCH] Forces OveriewInputConsumer to be used when Assistant is running on top of Launcher. Previously it was using OtherActivityInputConsumer, which got things in a pretty weird state (e.g. most recent app would appear in the center as if it was the active app when you started Quick Switching, etc.). By default (toggleable by a feature flag), OverviewWithoutFocusInputConsumer is used because Assistant doesn't seem to respect the CLOSE_SYSTEM_DIALOGS broadcast, at least in half-shelf mode. In this case, the Home intent is sent on swipe up, or you can dismiss it with the back gesture or by tapping above the half shelf. The new feature flag ASSISTANT_GIVES_LAUNCHER_FOCUS routes touches through OverviewInputConsumer. As opposed to OverviewWithoutFocusInputConsumer, this allows Quick Step to work while Assistant is running. Additional logic is added to dismiss the Assistant when appropriate. Note that the dismissal happens atomically, so it's not completely fluid with the other animations. As mentioned above, this is disabled by default because Assistant doesn't currently respect CLOSE_SYSTEM_DIALOGS. Demo with the flag enabled (and Assistant respecting CLOSE_SYSTEM_DIALOGS): https://drive.google.com/open?id=1W5jGpn_TEC-KjrYwQtaBT3pzxG_5tC4W Bug: 139661510 Change-Id: I261653118aff289b329ec2a7ca6e52f100f7835a Tested: Manually used quick switch after invoking Assistant from home screen. --- .../NavBarToHomeTouchController.java | 10 ++++ .../QuickSwitchTouchController.java | 4 ++ .../quickstep/TouchInteractionService.java | 38 +++++++-------- .../OverviewWithoutFocusInputConsumer.java | 11 ++--- .../quickstep/util/AssistantUtilities.java | 47 +++++++++++++++++++ .../launcher3/config/FeatureFlags.java | 4 ++ .../launcher3/views/BaseDragLayer.java | 4 +- 7 files changed, 89 insertions(+), 29 deletions(-) create mode 100644 quickstep/recents_ui_overrides/src/com/android/quickstep/util/AssistantUtilities.java diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index 738436a757..1897fb2f9c 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -23,6 +23,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS; import static com.android.launcher3.anim.Interpolators.DEACCEL_3; import static com.android.launcher3.touch.AbstractStateChangeTouchController.SUCCESS_TRANSITION_PROGRESS; +import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import android.animation.Animator; import android.animation.AnimatorSet; @@ -43,11 +44,14 @@ import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.compat.AccessibilityManagerCompat; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.touch.SingleAxisSwipeDetector; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.launcher3.util.TouchController; +import com.android.quickstep.util.AssistantUtilities; import com.android.quickstep.views.RecentsView; +import com.android.systemui.shared.system.ActivityManagerWrapper; /** * Handles swiping up on the nav bar to go home from launcher, e.g. overview or all apps. @@ -104,6 +108,10 @@ public class NavBarToHomeTouchController implements TouchController, if (AbstractFloatingView.getTopOpenView(mLauncher) != null) { return true; } + if (FeatureFlags.ASSISTANT_GIVES_LAUNCHER_FOCUS.get() + && AssistantUtilities.isExcludedAssistantRunning()) { + return true; + } return false; } @@ -194,6 +202,8 @@ public class NavBarToHomeTouchController implements TouchController, AbstractFloatingView.closeAllOpenViews(mLauncher); logStateChange(topOpenView.getLogContainerType(), logAction); } + ActivityManagerWrapper.getInstance() + .closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); } else { // Quickly return to the state we came from (we didn't move far). ValueAnimator anim = mCurrentAnimation.getAnimationPlayer(); diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java index a4ac1b0c00..912be983f7 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -30,6 +30,7 @@ import static com.android.launcher3.anim.Interpolators.INSTANT; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW; import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD; +import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED; import android.view.MotionEvent; @@ -50,6 +51,7 @@ import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; +import com.android.systemui.shared.system.ActivityManagerWrapper; /** * Handles quick switching to a recent task from the home screen. @@ -94,6 +96,8 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll super.onDragStart(start); mStartContainerType = LauncherLogProto.ContainerType.NAVBAR; mTaskToLaunch = mLauncher.getOverviewPanel().getTaskViewAt(0); + ActivityManagerWrapper.getInstance() + .closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); } @Override 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 a8974e5e4a..7ad3f37d66 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -33,7 +33,6 @@ import android.annotation.TargetApi; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.app.Service; -import android.app.TaskInfo; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -57,6 +56,7 @@ import androidx.annotation.WorkerThread; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.Utilities; import com.android.launcher3.allapps.DiscoveryBounce; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.model.AppLaunchTracker; import com.android.launcher3.provider.RestoreDbTask; @@ -74,6 +74,7 @@ import com.android.quickstep.inputconsumers.OverviewWithoutFocusInputConsumer; import com.android.quickstep.inputconsumers.ResetGestureInputConsumer; import com.android.quickstep.inputconsumers.ScreenPinnedInputConsumer; import com.android.quickstep.util.ActiveGestureLog; +import com.android.quickstep.util.AssistantUtilities; import com.android.systemui.plugins.OverscrollPlugin; import com.android.systemui.plugins.PluginListener; import com.android.systemui.shared.recents.IOverviewProxy; @@ -83,7 +84,6 @@ import com.android.systemui.shared.system.InputChannelCompat.InputEventReceiver; import com.android.systemui.shared.system.InputConsumerController; import com.android.systemui.shared.system.InputMonitorCompat; import com.android.systemui.shared.system.RecentsAnimationListener; -import com.android.systemui.shared.system.TaskInfoCompat; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -518,17 +518,16 @@ public class TouchInteractionService extends Service implements PluginListener mAM.getRunningTask(ACTIVITY_TYPE_ASSISTANT))); - if (!ActivityManagerWrapper.isHomeTask(gestureState.getRunningTask())) { - final ComponentName homeComponent = - mOverviewComponentObserver.getHomeIntent().getComponent(); - forceOverviewInputConsumer = gestureState.getRunningTask() - .baseIntent.getComponent().equals(homeComponent); - } + () -> mAM.getRunningTask(ACTIVITY_TYPE_ASSISTANT /* ignoreActivityType */))); + ComponentName homeComponent = mOverviewComponentObserver.getHomeIntent().getComponent(); + ComponentName runningComponent = + gestureState.getRunningTask().baseIntent.getComponent(); + forceOverviewInputConsumer = + runningComponent != null && runningComponent.equals(homeComponent); } if (previousGestureState.getFinishingRecentsAnimationTaskId() > 0) { @@ -543,10 +542,12 @@ public class TouchInteractionService extends Service implements PluginListener // Only look for controllers if we are not dispatching from gesture area and proxy is // not active mActiveController = findControllerToHandleTouch(ev); - - if (mActiveController != null) return true; } - return false; + return mActiveController != null; } @Override