diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig index 269936179b..a24c199724 100644 --- a/aconfig/launcher.aconfig +++ b/aconfig/launcher.aconfig @@ -223,16 +223,6 @@ flag { bug: "323886237" } -flag { - name: "enable_handle_delayed_gesture_callbacks" - namespace: "launcher" - description: "Enables additional handling for delayed mid-gesture callbacks" - bug: "285636175" - metadata { - purpose: PURPOSE_BUGFIX - } -} - flag { name: "enable_fallback_overview_in_window" namespace: "lse_desktop_experience" @@ -355,16 +345,6 @@ flag { bug: "358673724" } -flag { - name: "enable_desktop_task_alpha_animation" - namespace: "launcher" - description: "Enables the animation of the desktop task's background view" - bug: "320307666" - metadata { - purpose: PURPOSE_BUGFIX - } -} - flag { name: "ignore_three_finger_trackpad_for_nav_handle_long_press" namespace: "launcher" @@ -448,13 +428,6 @@ flag { bug: "368119679" } -flag { - name: "enable_active_gesture_proto_log" - namespace: "launcher" - description: "Enables tracking active gesture logs in ProtoLog" - bug: "293182501" -} - flag { name: "enable_recents_window_proto_log" namespace: "lse_desktop_experience" @@ -706,4 +679,4 @@ flag { metadata { purpose: PURPOSE_BUGFIX } -} \ No newline at end of file +} diff --git a/aconfig/launcher_overview.aconfig b/aconfig/launcher_overview.aconfig index 776c737de8..e1b7df33a3 100644 --- a/aconfig/launcher_overview.aconfig +++ b/aconfig/launcher_overview.aconfig @@ -60,16 +60,6 @@ flag { bug: "381239462" } -flag { - name: "enable_separate_external_display_tasks" - namespace: "launcher_overview" - description: "Enables separating external display tasks in Overview." - bug: "391311008" - metadata { - purpose: PURPOSE_BUGFIX - } -} - flag { name: "enable_overview_on_connected_displays" namespace: "launcher_overview" diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml index 5ca7143624..5590e5c3d8 100644 --- a/quickstep/AndroidManifest.xml +++ b/quickstep/AndroidManifest.xml @@ -49,6 +49,9 @@ --> + + + diff --git a/quickstep/src/com/android/launcher3/dagger/PerDisplayModule.kt b/quickstep/src/com/android/launcher3/dagger/PerDisplayModule.kt index 3bef6ca284..def588ccd9 100644 --- a/quickstep/src/com/android/launcher3/dagger/PerDisplayModule.kt +++ b/quickstep/src/com/android/launcher3/dagger/PerDisplayModule.kt @@ -52,6 +52,7 @@ interface BasePerDisplayModule { @Module object PerDisplayRepositoriesModule { @Provides + @LauncherAppSingleton fun provideRecentsAnimationDeviceStateRepo( repositoryFactory: PerDisplayInstanceRepositoryImpl.Factory, rotationTouchHelperRepository: PerDisplayRepository, @@ -77,6 +78,7 @@ object PerDisplayRepositoriesModule { } @Provides + @LauncherAppSingleton fun provideTaskAnimationManagerRepo( repositoryFactory: PerDisplayInstanceRepositoryImpl.Factory, instanceFactory: TaskAnimationManager.Factory, @@ -92,6 +94,7 @@ object PerDisplayRepositoriesModule { } @Provides + @LauncherAppSingleton fun provideRotationTouchHandlerRepo( repositoryFactory: PerDisplayInstanceRepositoryImpl.Factory, @DisplayContext displayContextRepository: PerDisplayRepository, @@ -113,6 +116,7 @@ object PerDisplayRepositoriesModule { } @Provides + @LauncherAppSingleton @DisplayContext fun provideDisplayContext( repositoryFactory: PerDisplayInstanceRepositoryImpl.Factory, diff --git a/quickstep/src/com/android/launcher3/desktop/DesktopAppLaunchTransitionManager.kt b/quickstep/src/com/android/launcher3/desktop/DesktopAppLaunchTransitionManager.kt index a72b5c43c5..1434168687 100644 --- a/quickstep/src/com/android/launcher3/desktop/DesktopAppLaunchTransitionManager.kt +++ b/quickstep/src/com/android/launcher3/desktop/DesktopAppLaunchTransitionManager.kt @@ -19,6 +19,7 @@ package com.android.launcher3.desktop import android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.content.Context +import android.window.DesktopExperienceFlags import android.window.DesktopModeFlags import android.window.RemoteTransition import android.window.TransitionFilter @@ -84,7 +85,9 @@ class DesktopAppLaunchTransitionManager( mWindowingMode = WINDOWING_MODE_FREEFORM mModes = DesktopAppLaunchTransition.LAUNCH_CHANGE_MODES mMustBeTask = true - mOrder = CONTAINER_ORDER_TOP + if (!DesktopExperienceFlags.ENABLE_DESKTOP_APP_LAUNCH_BUGFIX.isTrue) { + mOrder = CONTAINER_ORDER_TOP + } } return TransitionFilter().apply { mTypeSet = DesktopAppLaunchTransition.LAUNCH_CHANGE_MODES diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index 09d7ff725d..4738c0ff9e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -15,8 +15,8 @@ */ package com.android.launcher3.taskbar; -import static com.android.launcher3.taskbar.TaskbarDesktopModeFlags.enableAltTabKqsFlatenning; -import static com.android.launcher3.taskbar.TaskbarDesktopModeFlags.enableAltTabKqsOnConnectedDisplays; +import static com.android.launcher3.taskbar.TaskbarDesktopExperienceFlags.enableAltTabKqsFlatenning; +import static com.android.launcher3.taskbar.TaskbarDesktopExperienceFlags.enableAltTabKqsOnConnectedDisplays; import android.app.ActivityManager; import android.content.ComponentName; diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java index d69830a8b9..693fe9cc8f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java @@ -17,7 +17,7 @@ package com.android.launcher3.taskbar; import static androidx.constraintlayout.widget.ConstraintLayout.LayoutParams.PARENT_ID; -import static com.android.launcher3.taskbar.TaskbarDesktopModeFlags.enableAltTabKqsFlatenning; +import static com.android.launcher3.taskbar.TaskbarDesktopExperienceFlags.enableAltTabKqsFlatenning; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java index b537660bc7..47791b79fb 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java @@ -16,7 +16,7 @@ package com.android.launcher3.taskbar; import static com.android.launcher3.desktop.DesktopAppLaunchTransition.AppLaunchType.UNMINIMIZE; -import static com.android.launcher3.taskbar.TaskbarDesktopModeFlags.enableAltTabKqsFlatenning; +import static com.android.launcher3.taskbar.TaskbarDesktopExperienceFlags.enableAltTabKqsFlatenning; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeFlags.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopExperienceFlags.kt similarity index 51% rename from quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeFlags.kt rename to quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopExperienceFlags.kt index 870a2ca8f6..ab876e43c3 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeFlags.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopExperienceFlags.kt @@ -16,17 +16,23 @@ package com.android.launcher3.taskbar -import android.window.DesktopModeFlags.DesktopModeFlag +import android.window.DesktopExperienceFlags.DesktopExperienceFlag import com.android.launcher3.Flags -class TaskbarDesktopModeFlags { - companion object { - @JvmField - val enableAltTabKqsOnConnectedDisplays: DesktopModeFlag = - DesktopModeFlag(Flags::enableAltTabKqsOnConnectedDisplays, false) +object TaskbarDesktopExperienceFlags { + @JvmField + val enableAltTabKqsOnConnectedDisplays: DesktopExperienceFlag = + DesktopExperienceFlag( + Flags::enableAltTabKqsOnConnectedDisplays, + /* shouldOverrideByDevOption= */ false, + Flags.FLAG_ENABLE_ALT_TAB_KQS_ON_CONNECTED_DISPLAYS, + ) - @JvmField - val enableAltTabKqsFlatenning: DesktopModeFlag = - DesktopModeFlag(Flags::enableAltTabKqsFlatenning, false) - } + @JvmField + val enableAltTabKqsFlatenning: DesktopExperienceFlag = + DesktopExperienceFlag( + Flags::enableAltTabKqsFlatenning, + /* shouldOverrideByDevOption= */ false, + Flags.FLAG_ENABLE_ALT_TAB_KQS_FLATENNING, + ) } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index 3bfe047ad6..e19fd5764b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -34,6 +34,7 @@ import static com.android.launcher3.util.DisplayController.CHANGE_DESKTOP_MODE; import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE; import static com.android.launcher3.util.DisplayController.CHANGE_SHOW_LOCKED_TASKBAR; import static com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING; +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange; import static com.android.quickstep.util.SystemActionConstants.ACTION_SHOW_TASKBAR; @@ -44,12 +45,16 @@ import android.annotation.SuppressLint; import android.app.PendingIntent; import android.content.ComponentCallbacks; import android.content.Context; +import android.content.IIntentReceiver; +import android.content.IIntentSender; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.hardware.display.DisplayManager; import android.net.Uri; +import android.os.Bundle; import android.os.Handler; +import android.os.IBinder; import android.os.Trace; import android.provider.Settings; import android.util.ArraySet; @@ -116,6 +121,12 @@ public class TaskbarManager implements DisplayDecorationListener { // TODO: b/397738606 - Remove all logs with this tag after the growth framework is integrated. public static final String GROWTH_FRAMEWORK_TAG = "Growth Framework"; + /** + * An integer extra specifying the ID of the display on which the All Apps UI should be shown + * or hidden. + */ + public static final String EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID = + "com.android.quickstep.allapps.display_id"; /** * All the configurations which do not initiate taskbar recreation. @@ -575,10 +586,19 @@ public class TaskbarManager implements DisplayDecorationListener { } /** - * Toggles All Apps for Taskbar or Launcher depending on the current state. + * Shows or hides the All Apps view in the Taskbar or Launcher, based on its current + * visibility on the System UI tracked focused display. */ public void toggleAllAppsSearch() { - TaskbarActivityContext taskbar = getTaskbarForDisplay(getFocusedDisplayId()); + toggleAllAppsSearchForDisplay(getFocusedDisplayId()); + } + + /** + * Shows or hides the All Apps view in the Taskbar or Launcher, based on its current + * visibility on the given display, with ID {@code displayId}. + */ + public void toggleAllAppsSearchForDisplay(int displayId) { + TaskbarActivityContext taskbar = getTaskbarForDisplay(displayId); if (taskbar == null) { // Home All Apps should be toggled from this class, because the controllers are not // initialized when Taskbar is disabled (i.e. TaskbarActivityContext is null). @@ -1713,6 +1733,28 @@ public class TaskbarManager implements DisplayDecorationListener { debugTaskbarManager(debugReason, mPrimaryDisplayId, verbose); } + /** Creates a {@link PendingIntent} for showing / hiding the all apps UI. */ + public PendingIntent createAllAppsPendingIntent() { + return new PendingIntent(new IIntentSender.Stub() { + @Override + public void send(int code, Intent intent, String resolvedType, + IBinder allowlistToken, IIntentReceiver finishedReceiver, + String requiredPermission, Bundle options) { + MAIN_EXECUTOR.execute(() -> { + int displayId = -1; + if (options != null) { + displayId = options.getInt(EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID, -1); + } + if (displayId == -1) { + toggleAllAppsSearch(); + } else { + toggleAllAppsSearchForDisplay(displayId); + } + }); + } + }); + } + /** * Logs verbose debug information about the TaskbarManager for a specific display. */ diff --git a/quickstep/src/com/android/quickstep/AllAppsActionManager.kt b/quickstep/src/com/android/quickstep/AllAppsActionManager.kt index b807a4bfe3..2d179f95df 100644 --- a/quickstep/src/com/android/quickstep/AllAppsActionManager.kt +++ b/quickstep/src/com/android/quickstep/AllAppsActionManager.kt @@ -27,6 +27,7 @@ import android.view.accessibility.AccessibilityManager import com.android.launcher3.R import com.android.launcher3.util.SettingsCache import com.android.launcher3.util.SettingsCache.OnChangeListener +import com.android.quickstep.input.QuickstepKeyGestureEventsManager import java.util.concurrent.Executor private val USER_SETUP_COMPLETE_URI = Settings.Secure.getUriFor(USER_SETUP_COMPLETE) @@ -41,6 +42,7 @@ private val USER_SETUP_COMPLETE_URI = Settings.Secure.getUriFor(USER_SETUP_COMPL class AllAppsActionManager( private val context: Context, private val bgExecutor: Executor, + private val quickstepKeyGestureEventsManager: QuickstepKeyGestureEventsManager, private val createAllAppsPendingIntent: () -> PendingIntent, ) { @@ -92,17 +94,22 @@ class AllAppsActionManager( val accessibilityManager = context.getSystemService(AccessibilityManager::class.java) ?: return@execute if (shouldRegisterAction) { + val allAppsPendingIntent = createAllAppsPendingIntent() accessibilityManager.registerSystemAction( RemoteAction( Icon.createWithResource(context, R.drawable.ic_apps), context.getString(R.string.all_apps_label), context.getString(R.string.all_apps_label), - createAllAppsPendingIntent(), + allAppsPendingIntent, ), GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS, ) + quickstepKeyGestureEventsManager.registerAllAppsKeyGestureEvent( + allAppsPendingIntent + ) } else { accessibilityManager.unregisterSystemAction(GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS) + quickstepKeyGestureEventsManager.unregisterAllAppsKeyGestureEvent() } } } diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index ea9bdb01f3..93924cb3c5 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -18,7 +18,6 @@ package com.android.quickstep; import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; -import static com.android.launcher3.Flags.enableSeparateExternalDisplayTasks; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.quickstep.util.SplitScreenUtils.convertShellSplitBoundsToLauncher; import static com.android.wm.shell.shared.GroupedTaskInfo.TYPE_DESK; @@ -498,8 +497,7 @@ public class RecentTasksList implements WindowManagerProxy.DesktopVisibilityList Set minimizedTaskIds = minimizedTaskIdArray != null ? CollectionsKt.toSet(ArraysKt.asIterable(minimizedTaskIdArray)) : Collections.emptySet(); - if (enableSeparateExternalDisplayTasks() - && !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue()) { + if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue()) { // This code is not needed when the multiple desktop feature is enabled, since Shell // will send a single `GroupedTaskInfo` for each desk with a unique `deskId` across // all displays. diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index f2baf812a1..bd1b4918d6 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -17,7 +17,6 @@ package com.android.quickstep; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; -import static com.android.launcher3.Flags.enableHandleDelayedGestureCallbacks; import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.NavigationMode.NO_BUTTON; @@ -184,7 +183,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn @Override public void onRecentsAnimationStart(RecentsAnimationController controller, RecentsAnimationTargets targets, @Nullable TransitionInfo transitionInfo) { - if (enableHandleDelayedGestureCallbacks() && mRecentsAnimationStartPending) { + if (mRecentsAnimationStartPending) { ActiveGestureProtoLogProxy.logStartRecentsAnimationCallback( "onRecentsAnimationStart"); mRecentsAnimationStartPending = false; @@ -229,7 +228,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn @Override public void onRecentsAnimationCanceled(HashMap thumbnailDatas) { - if (enableHandleDelayedGestureCallbacks() && mRecentsAnimationStartPending) { + if (mRecentsAnimationStartPending) { ActiveGestureProtoLogProxy.logStartRecentsAnimationCallback( "onRecentsAnimationCanceled"); mRecentsAnimationStartPending = false; @@ -239,7 +238,7 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn @Override public void onRecentsAnimationFinished(RecentsAnimationController controller) { - if (enableHandleDelayedGestureCallbacks() && mRecentsAnimationStartPending) { + if (mRecentsAnimationStartPending) { ActiveGestureProtoLogProxy.logStartRecentsAnimationCallback( "onRecentsAnimationFinished"); mRecentsAnimationStartPending = false; @@ -350,11 +349,8 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn mRecentsAnimationStartPending = getSystemUiProxy().startRecentsActivity(intent, options, mCallbacks, false /* useSyntheticRecentsTransition */); } - - if (enableHandleDelayedGestureCallbacks()) { - ActiveGestureProtoLogProxy.logSettingRecentsAnimationStartPending( - mRecentsAnimationStartPending); - } + ActiveGestureProtoLogProxy.logSettingRecentsAnimationStartPending( + mRecentsAnimationStartPending); gestureState.setState(STATE_RECENTS_ANIMATION_INITIALIZED); return mCallbacks; } @@ -549,10 +545,8 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn pw.println(prefix + "TaskAnimationManager:"); pw.println(prefix + "\tmDisplayId=" + mDisplayId); - if (enableHandleDelayedGestureCallbacks()) { - pw.println(prefix + "\tmRecentsAnimationStartPending=" + mRecentsAnimationStartPending); - pw.println(prefix + "\tmShouldIgnoreUpcomingGestures=" + mShouldIgnoreMotionEvents); - } + pw.println(prefix + "\tmRecentsAnimationStartPending=" + mRecentsAnimationStartPending); + pw.println(prefix + "\tmShouldIgnoreUpcomingGestures=" + mShouldIgnoreMotionEvents); if (mController != null) { mController.dump(prefix + '\t', pw); } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index c5197054b5..9c84e76bab 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -24,12 +24,11 @@ import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.Flags.enableCursorHoverStates; -import static com.android.launcher3.Flags.enableHandleDelayedGestureCallbacks; import static com.android.launcher3.Flags.enableOverviewOnConnectedDisplays; import static com.android.launcher3.LauncherPrefs.backedUpItem; import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe; -import static com.android.launcher3.taskbar.TaskbarDesktopModeFlags.enableAltTabKqsOnConnectedDisplays; +import static com.android.launcher3.taskbar.TaskbarDesktopExperienceFlags.enableAltTabKqsOnConnectedDisplays; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.OnboardingPrefs.HOME_BOUNCE_SEEN; @@ -42,11 +41,8 @@ import static com.android.quickstep.InputConsumerUtils.newConsumer; import static com.android.quickstep.InputConsumerUtils.tryCreateAssistantInputConsumer; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; -import android.app.PendingIntent; import android.app.Service; import android.content.Context; -import android.content.IIntentReceiver; -import android.content.IIntentSender; import android.content.Intent; import android.content.res.Configuration; import android.graphics.Region; @@ -101,6 +97,7 @@ import com.android.quickstep.OverviewComponentObserver.OverviewChangeListener; import com.android.quickstep.fallback.window.RecentsDisplayModel; import com.android.quickstep.fallback.window.RecentsWindowFlags; import com.android.quickstep.fallback.window.RecentsWindowSwipeHandler; +import com.android.quickstep.input.QuickstepKeyGestureEventsManager; import com.android.quickstep.inputconsumers.BubbleBarInputConsumer; import com.android.quickstep.inputconsumers.OneHandedModeInputConsumer; import com.android.quickstep.util.ActiveGestureLog; @@ -639,6 +636,8 @@ public class TouchInteractionService extends Service { private DisplayRepository mDisplayRepository; + private QuickstepKeyGestureEventsManager mQuickstepKeyGestureEventsHandler; + @Override public void onCreate() { super.onCreate(); @@ -653,8 +652,10 @@ public class TouchInteractionService extends Service { mRotationTouchHelperRepository = RotationTouchHelper.REPOSITORY_INSTANCE.get(this); mRecentsDisplayModel = RecentsDisplayModel.getINSTANCE().get(this); mSystemDecorationChangeObserver = SystemDecorationChangeObserver.getINSTANCE().get(this); - mAllAppsActionManager = new AllAppsActionManager( - this, UI_HELPER_EXECUTOR, this::createAllAppsPendingIntent); + mQuickstepKeyGestureEventsHandler = new QuickstepKeyGestureEventsManager(this); + mAllAppsActionManager = new AllAppsActionManager(this, UI_HELPER_EXECUTOR, + mQuickstepKeyGestureEventsHandler, + () -> mTaskbarManager.createAllAppsPendingIntent()); mTrackpadsConnected = new ActiveTrackpadList(this, () -> { if (mInputMonitorCompat != null && !mTrackpadsConnected.isEmpty()) { // Don't destroy and reinitialize input monitor due to trackpad @@ -812,17 +813,6 @@ public class TouchInteractionService extends Service { } } - private PendingIntent createAllAppsPendingIntent() { - return new PendingIntent(new IIntentSender.Stub() { - @Override - public void send(int code, Intent intent, String resolvedType, - IBinder allowlistToken, IIntentReceiver finishedReceiver, - String requiredPermission, Bundle options) { - MAIN_EXECUTOR.execute(() -> mTaskbarManager.toggleAllAppsSearch()); - } - }); - } - @UiThread private void onSystemUiFlagsChanged(@SystemUiStateFlags long lastSysUIFlags, int displayId) { if (LockedUserState.get(this).isUserUnlocked()) { @@ -949,16 +939,14 @@ public class TouchInteractionService extends Service { ActiveGestureProtoLogProxy.logOnTaskAnimationManagerNotAvailable(displayId); return; } - if (enableHandleDelayedGestureCallbacks()) { + if (action == ACTION_DOWN || isHoverActionWithoutConsumer) { + taskAnimationManager.notifyNewGestureStart(); + } + if (taskAnimationManager.shouldIgnoreMotionEvents()) { if (action == ACTION_DOWN || isHoverActionWithoutConsumer) { - taskAnimationManager.notifyNewGestureStart(); - } - if (taskAnimationManager.shouldIgnoreMotionEvents()) { - if (action == ACTION_DOWN || isHoverActionWithoutConsumer) { - ActiveGestureProtoLogProxy.logOnInputIgnoringFollowingEvents(displayId); - } - return; + ActiveGestureProtoLogProxy.logOnInputIgnoringFollowingEvents(displayId); } + return; } InputMonitorCompat inputMonitorCompat = getInputMonitorCompat(displayId); diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index a2c2f0b19f..5b98d07e81 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -92,6 +92,10 @@ public class FallbackRecentsView?>(R.id.overview_panel) + ?.apply { + init( + actionsView, + SplitSelectStateController( + /* container= */ this@RecentsWindowManager, + stateManager, + /* depthController= */ null, + statsLogManager, + SystemUiProxy.INSTANCE[this@RecentsWindowManager], + RecentsModel.INSTANCE[this@RecentsWindowManager], + /* activityBackCallback= */ null, + ), + /* desktopRecentsTransitionController= */ null, + ) + } + actionsView?.apply { + updateDimension(getDeviceProfile(), recentsView?.lastComputedTaskSize) + updateVerticalMargin(DisplayController.getNavigationMode(this@RecentsWindowManager)) + } + scrimView = it.findViewById(R.id.scrim_view) + dragLayer = it.findViewById(R.id.drag_layer) - windowView?.systemUiVisibility = - (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) + it.findOnBackInvokedDispatcher() + ?.registerSystemOnBackInvokedCallback(onBackInvokedCallback) - recentsView = windowView?.findViewById(R.id.overview_panel) - actionsView = windowView?.findViewById(R.id.overview_actions_view) - scrimView = windowView?.findViewById(R.id.scrim_view) - val systemUiProxy = SystemUiProxy.INSTANCE[this] - val splitSelectStateController = - SplitSelectStateController( - this, - getStateManager(), - null, /* depthController */ - statsLogManager, - systemUiProxy, - RecentsModel.INSTANCE[this], - null, /*activityBackCallback*/ - ) - recentsView?.init(actionsView, splitSelectStateController, null) - dragLayer = windowView?.findViewById(R.id.drag_layer) - - actionsView?.updateDimension(getDeviceProfile(), recentsView?.lastComputedTaskSize) - actionsView?.updateVerticalMargin(DisplayController.getNavigationMode(this)) + it.systemUiVisibility = + (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) + } systemUiController = SystemUiController(windowView) recentsWindowTracker.handleCreate(this) diff --git a/quickstep/src/com/android/quickstep/input/QuickstepKeyGestureEventsManager.kt b/quickstep/src/com/android/quickstep/input/QuickstepKeyGestureEventsManager.kt new file mode 100644 index 0000000000..d6355e9a91 --- /dev/null +++ b/quickstep/src/com/android/quickstep/input/QuickstepKeyGestureEventsManager.kt @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.quickstep.input + +import android.app.PendingIntent +import android.content.Context +import android.hardware.input.InputManager +import android.hardware.input.InputManager.KeyGestureEventHandler +import android.hardware.input.KeyGestureEvent +import android.os.Bundle +import android.os.IBinder +import android.util.Log +import androidx.annotation.VisibleForTesting +import com.android.launcher3.taskbar.TaskbarManager +import com.android.window.flags.Flags + +/** + * Manages subscription and unsubscription to launcher's key gesture events, e.g. all apps and + * recents (incl. alt + tab). + */ +class QuickstepKeyGestureEventsManager(context: Context) { + private val inputManager = requireNotNull(context.getSystemService(InputManager::class.java)) + private var allAppsPendingIntent: PendingIntent? = null + @VisibleForTesting + val allAppsKeyGestureEventHandler = + object : KeyGestureEventHandler { + override fun handleKeyGestureEvent(event: KeyGestureEvent, focusedToken: IBinder?) { + if (!Flags.enableKeyGestureHandlerForRecents()) { + return + } + if (event.keyGestureType != KeyGestureEvent.KEY_GESTURE_TYPE_ALL_APPS) { + Log.e(TAG, "Ignore unsupported key gesture event type: ${event.keyGestureType}") + return + } + + allAppsPendingIntent?.send( + Bundle().apply { + putInt(TaskbarManager.EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID, event.displayId) + } + ) + } + } + + /** Registers the all apps key gesture events. */ + fun registerAllAppsKeyGestureEvent(allAppsPendingIntent: PendingIntent) { + if (Flags.enableKeyGestureHandlerForRecents()) { + this.allAppsPendingIntent = allAppsPendingIntent + inputManager.registerKeyGestureEventHandler( + listOf(KeyGestureEvent.KEY_GESTURE_TYPE_ALL_APPS), + allAppsKeyGestureEventHandler, + ) + } + } + + /** Unregisters the all apps key gesture events. */ + fun unregisterAllAppsKeyGestureEvent() { + if (Flags.enableKeyGestureHandlerForRecents()) { + inputManager.unregisterKeyGestureEventHandler(allAppsKeyGestureEventHandler) + } + } + + private companion object { + const val TAG = "KeyGestureEventsHandler" + } +} diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 5168cc7316..0ebd79bd86 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -37,12 +37,10 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE; import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS; import static com.android.launcher3.Flags.enableAdditionalHomeAnimations; import static com.android.launcher3.Flags.enableDesktopExplodedView; -import static com.android.launcher3.Flags.enableDesktopTaskAlphaAnimation; import static com.android.launcher3.Flags.enableExpressiveDismissTaskMotion; import static com.android.launcher3.Flags.enableLargeDesktopWindowingTile; import static com.android.launcher3.Flags.enableOverviewBackgroundWallpaperBlur; import static com.android.launcher3.Flags.enableRefactorTaskThumbnail; -import static com.android.launcher3.Flags.enableSeparateExternalDisplayTasks; import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS; import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA; import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR; @@ -2011,9 +2009,7 @@ public abstract class RecentsView< if (enableLargeDesktopWindowingTile()) { taskGroups = mUtils.sortDesktopTasksToFront(taskGroups); } - if (enableSeparateExternalDisplayTasks()) { - taskGroups = mUtils.sortExternalDisplayTasksToFront(taskGroups); - } + taskGroups = mUtils.sortExternalDisplayTasksToFront(taskGroups); if (mAddDesktopButton != null) { // Add `mAddDesktopButton` as the first child. @@ -2760,7 +2756,9 @@ public abstract class RecentsView< mBlurUtils.setDrawLiveTileBelowRecents(false); // These are relatively expensive and don't need to be done this frame (RecentsView isn't // visible anyway), so defer by a frame to get off the critical path, e.g. app to home. - post(this::onReset); + // Defer onto the main thread rather than the view message queue since this will not always + // be called in the Recents In Window case. + MAIN_EXECUTOR.getHandler().post(this::onReset); } private void onReset() { @@ -2907,7 +2905,7 @@ public abstract class RecentsView< * Returns whether the running task's attach alpha should be updated during the attach animation */ public boolean shouldUpdateRunningTaskAlpha() { - return enableDesktopTaskAlphaAnimation() && getRunningTaskView() instanceof DesktopTaskView; + return getRunningTaskView() instanceof DesktopTaskView; } private boolean isGestureActive() { @@ -4951,9 +4949,8 @@ public abstract class RecentsView< : showAsGrid ? gridOffsetSize : i < modalMidpoint ? modalLeftOffsetSize : modalRightOffsetSize; - boolean skipTranslationOffset = enableDesktopTaskAlphaAnimation() - && i == getRunningTaskIndex() - && child instanceof DesktopTaskView; + boolean skipTranslationOffset = + i == getRunningTaskIndex() && child instanceof DesktopTaskView; float totalTranslationX = (skipTranslationOffset ? 0f : translation) + modalTranslation + carouselHiddenOffsetSize; if (child instanceof TaskView taskView) { diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt index 33963b817b..0f60fa5602 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt @@ -32,7 +32,6 @@ import com.android.launcher3.AbstractFloatingView.TYPE_TASK_MENU import com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType import com.android.launcher3.Flags.enableDesktopExplodedView import com.android.launcher3.Flags.enableLargeDesktopWindowingTile -import com.android.launcher3.Flags.enableSeparateExternalDisplayTasks import com.android.launcher3.Utilities.getPivotsForScalingRectToRect import com.android.launcher3.statehandlers.DesktopVisibilityController import com.android.launcher3.statehandlers.DesktopVisibilityController.Companion.INACTIVE_DESK_ID @@ -189,10 +188,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi fun getExpectedCurrentTask(runningTaskView: TaskView?, focusedTaskView: TaskView?): TaskView? = runningTaskView ?: focusedTaskView - ?: taskViews.firstOrNull { - it !is DesktopTaskView && - !(enableSeparateExternalDisplayTasks() && it.isExternalDisplay) - } + ?: taskViews.firstOrNull { it !is DesktopTaskView && !it.isExternalDisplay } ?: taskViews.lastOrNull() private fun getDeviceProfile() = (recentsView.mContainer as RecentsViewContainer).deviceProfile @@ -215,17 +211,13 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi if (enableLargeDesktopWindowingTile() && runningTaskView !is DesktopTaskView) { // For fullsreen tasks, skip over Desktop tasks in its section index += - if (enableSeparateExternalDisplayTasks()) { - if (runningTaskView.isExternalDisplay) { - taskViews.count { it is DesktopTaskView && it.isExternalDisplay } - } else { - taskViews.count { it is DesktopTaskView && !it.isExternalDisplay } - } + if (runningTaskView.isExternalDisplay) { + taskViews.count { it is DesktopTaskView && it.isExternalDisplay } } else { - getDesktopTaskViewCount() + taskViews.count { it is DesktopTaskView && !it.isExternalDisplay } } } - if (enableSeparateExternalDisplayTasks() && !runningTaskView.isExternalDisplay) { + if (!runningTaskView.isExternalDisplay) { // For main display section, skip over external display tasks index += taskViews.count { it.isExternalDisplay } } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 8c1ce04b98..17a9d60d06 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -49,7 +49,6 @@ import com.android.launcher3.Flags.enableDesktopExplodedView import com.android.launcher3.Flags.enableLargeDesktopWindowingTile import com.android.launcher3.Flags.enableRefactorTaskContentView import com.android.launcher3.Flags.enableRefactorTaskThumbnail -import com.android.launcher3.Flags.enableSeparateExternalDisplayTasks import com.android.launcher3.R import com.android.launcher3.Utilities import com.android.launcher3.anim.AnimatedFloat @@ -170,7 +169,7 @@ constructor( get() = this == recentsView?.focusedTaskView || (enableLargeDesktopWindowingTile() && type == TaskViewType.DESKTOP) || - (enableSeparateExternalDisplayTasks() && isExternalDisplay) + isExternalDisplay val recentsView: RecentsView<*, *>? get() = parent as? RecentsView<*, *> diff --git a/quickstep/src_protolog/com/android/quickstep/util/ActiveGestureProtoLogProxy.java b/quickstep/src_protolog/com/android/quickstep/util/ActiveGestureProtoLogProxy.java index 4466458ef4..cf1eb87df1 100644 --- a/quickstep/src_protolog/com/android/quickstep/util/ActiveGestureProtoLogProxy.java +++ b/quickstep/src_protolog/com/android/quickstep/util/ActiveGestureProtoLogProxy.java @@ -17,7 +17,6 @@ package com.android.quickstep.util; import static android.view.MotionEvent.ACTION_DOWN; -import static com.android.launcher3.Flags.enableActiveGestureProtoLog; import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.CANCEL_RECENTS_ANIMATION; import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.FINISH_RECENTS_ANIMATION; import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.INVALID_VELOCITY_ON_SWIPE_UP; @@ -71,7 +70,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog( /* event= */ "AbsSwipeUpHandler.onRecentsAnimationCanceled", /* gestureEvent= */ CANCEL_RECENTS_ANIMATION); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.onRecentsAnimationCanceled"); } @@ -79,7 +78,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog( /* event= */ "RecentsAnimationCallbacks.onAnimationFinished", ON_FINISH_RECENTS_ANIMATION); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.onAnimationFinished"); } @@ -87,27 +86,27 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog( "AbsSwipeUpHandler.cancelCurrentAnimation", ActiveGestureErrorDetector.GestureEvent.CANCEL_CURRENT_ANIMATION); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.cancelCurrentAnimation"); } public static void logAbsSwipeUpHandlerOnTasksAppeared() { ActiveGestureLog.INSTANCE.addLog("AbsSwipeUpHandler.onTasksAppeared: " + "force finish recents animation complete; clearing state callback."); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.onTasksAppeared: " + "force finish recents animation complete; clearing state callback."); } public static void logHandOffAnimation() { ActiveGestureLog.INSTANCE.addLog("AbsSwipeUpHandler.handOffAnimation"); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.handOffAnimation"); } public static void logFinishRecentsAnimationOnTasksAppeared() { ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimationOnTasksAppeared"); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRecentsAnimationOnTasksAppeared"); } @@ -115,14 +114,14 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog( /* event= */ "RecentsAnimationCallbacks.onAnimationCanceled", /* gestureEvent= */ ON_CANCEL_RECENTS_ANIMATION); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onAnimationCanceled"); } public static void logRecentsAnimationCallbacksOnTasksAppeared() { ActiveGestureLog.INSTANCE.addLog("RecentsAnimationCallbacks.onTasksAppeared", ActiveGestureErrorDetector.GestureEvent.TASK_APPEARED); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onTasksAppeared"); } @@ -130,32 +129,32 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog( /* event= */ "TaskAnimationManager.startRecentsAnimation", /* gestureEvent= */ START_RECENTS_ANIMATION); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TaskAnimationManager.startRecentsAnimation"); } public static void logLaunchingSideTaskFailed() { ActiveGestureLog.INSTANCE.addLog("Unable to launch side task (no recents)"); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Unable to launch side task (no recents)"); } public static void logContinueRecentsAnimation() { ActiveGestureLog.INSTANCE.addLog(/* event= */ "continueRecentsAnimation"); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "continueRecentsAnimation"); } public static void logCleanUpRecentsAnimationSkipped() { ActiveGestureLog.INSTANCE.addLog( /* event= */ "cleanUpRecentsAnimation skipped due to wrong callbacks"); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "cleanUpRecentsAnimation skipped due to wrong callbacks"); } public static void logCleanUpRecentsAnimation() { ActiveGestureLog.INSTANCE.addLog(/* event= */ "cleanUpRecentsAnimation"); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "cleanUpRecentsAnimation"); } @@ -163,7 +162,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "TIS.onInputEvent(displayId=%d): Cannot process input event: user is locked", displayId)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onInputEvent(displayId=%d): Cannot process input event: user is locked", displayId); @@ -175,7 +174,7 @@ public class ActiveGestureProtoLogProxy { + "but a previously-requested recents animation hasn't started. " + "Ignoring all following motion events.", displayId), RECENTS_ANIMATION_START_PENDING); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onMotionEvent(displayId=%d): A new gesture has been started, " + "but a previously-requested recents animation hasn't started. " @@ -186,7 +185,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "TIS.onInputEvent(displayId=%d): Cannot process input event: " + "using 3-button nav and event is not a trackpad event", displayId)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onInputEvent(displayId=%d): Cannot process input event: " + "using 3-button nav and event is not a trackpad event", displayId); @@ -194,46 +193,46 @@ public class ActiveGestureProtoLogProxy { public static void logPreloadRecentsAnimation() { ActiveGestureLog.INSTANCE.addLog("preloadRecentsAnimation"); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "preloadRecentsAnimation"); } public static void logRecentTasksMissing() { ActiveGestureLog.INSTANCE.addLog("Null mRecentTasks", RECENT_TASKS_MISSING); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Null mRecentTasks"); } public static void logExecuteHomeCommand() { ActiveGestureLog.INSTANCE.addLog("OverviewCommandHelper.executeCommand(HOME)"); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "OverviewCommandHelper.executeCommand(HOME)"); } public static void logFinishRecentsAnimationCallback() { ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation-callback"); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRecentsAnimation-callback"); } public static void logOnScrollerAnimationAborted() { ActiveGestureLog.INSTANCE.addLog("scroller animation aborted", ActiveGestureErrorDetector.GestureEvent.SCROLLER_ANIMATION_ABORTED); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "scroller animation aborted"); } public static void logInputConsumerBecameActive(@NonNull String consumerName) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "%s became active", consumerName)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "%s became active", consumerName); } public static void logTaskLaunchFailed(int launchedTaskId) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "Launch failed, task (id=%d) finished mid transition", launchedTaskId)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Launch failed, task (id=%d) finished mid transition", launchedTaskId); } @@ -241,7 +240,7 @@ public class ActiveGestureProtoLogProxy { public static void logOnPageEndTransition(int nextPageIndex) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "onPageEndTransition: current page index updated: %d", nextPageIndex)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "onPageEndTransition: current page index updated: %d", nextPageIndex); } @@ -251,7 +250,7 @@ public class ActiveGestureProtoLogProxy { "Quick switch from home fallback case: The TaskView at index %d is missing.", taskIndex), QUICK_SWITCH_FROM_HOME_FALLBACK); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Quick switch from home fallback case: The TaskView at index %d is missing.", taskIndex); @@ -262,7 +261,7 @@ public class ActiveGestureProtoLogProxy { "Quick switch from home failed: TaskViews at indices %d and 0 are missing.", taskIndex), QUICK_SWITCH_FROM_HOME_FAILED); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Quick switch from home failed: TaskViews at indices %d and 0 are missing.", taskIndex); @@ -272,42 +271,42 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "finishRecentsAnimation: %b", toRecents), /* gestureEvent= */ FINISH_RECENTS_ANIMATION); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRecentsAnimation: %b", toRecents); } public static void logSetEndTarget(@NonNull String target) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "setEndTarget %s", target), /* gestureEvent= */ SET_END_TARGET); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "setEndTarget %s", target); } public static void logStartHomeIntent(@NonNull String reason) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "OverviewComponentObserver.startHomeIntent: %s", reason)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "OverviewComponentObserver.startHomeIntent: %s", reason); } public static void logRunningTaskPackage(@NonNull String packageName) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "Current running task package name=%s", packageName)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Current running task package name=%s", packageName); } public static void logSysuiStateFlags(@NonNull String stateFlags) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "Current SystemUi state flags=%s", stateFlags)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Current SystemUi state flags=%s", stateFlags); } public static void logSetInputConsumer(@NonNull String consumerName, @NonNull String reason) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "setInputConsumer: %s. reason(s):%s", consumerName, reason)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "setInputConsumer: %s. reason(s):%s", consumerName, reason); } @@ -319,7 +318,7 @@ public class ActiveGestureProtoLogProxy { + "one (%s) was excluded from recents", otherTaskPackage, runningTaskPackage)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Changing active task to %s because the previous task running on top of this " + "one (%s) was excluded from recents", @@ -340,7 +339,7 @@ public class ActiveGestureProtoLogProxy { /* gestureEvent= */ action == ACTION_DOWN ? MOTION_DOWN : MOTION_UP); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "onMotionEvent(%d, %d): %s, %s, displayId=%d", x, @@ -362,7 +361,7 @@ public class ActiveGestureProtoLogProxy { pointerCount, displayId), MOTION_MOVE); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "onMotionEvent: %s, %s, pointerCount: %d, displayId=%d", action, @@ -375,7 +374,7 @@ public class ActiveGestureProtoLogProxy { @NonNull String action, @NonNull String classification, int displayId) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "onMotionEvent: %s, %s, displayId=%d", action, classification, displayId)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "onMotionEvent: %s, %s, displayId=%d", action, classification, displayId); } @@ -389,7 +388,7 @@ public class ActiveGestureProtoLogProxy { startNavMode, currentNavMode), NAVIGATION_MODE_SWITCHED); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onInputEvent(displayId=%d): Navigation mode switched mid-gesture (%s -> %s); " + "cancelling gesture.", @@ -402,7 +401,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "TIS.onInputEvent(displayId=%d): Cannot process input event: " + "received unknown event %s", displayId, event)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onInputEvent(displayId=%d): Cannot process input event: " + "received unknown event %s", displayId, event); @@ -411,14 +410,14 @@ public class ActiveGestureProtoLogProxy { public static void logFinishRunningRecentsAnimation(boolean toHome) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "finishRunningRecentsAnimation: %b", toHome)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRunningRecentsAnimation: %b", toHome); } public static void logOnRecentsAnimationStartCancelled() { ActiveGestureLog.INSTANCE.addLog("RecentsAnimationCallbacks.onAnimationStart (canceled): 0", /* gestureEvent= */ ON_START_RECENTS_ANIMATION); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onAnimationStart (canceled): 0"); } @@ -426,7 +425,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "RecentsAnimationCallbacks.onAnimationStart: %d", appCount), /* gestureEvent= */ ON_START_RECENTS_ANIMATION); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onAnimationStart: %d", appCount); } @@ -436,7 +435,7 @@ public class ActiveGestureProtoLogProxy { "TaskAnimationManager.startRecentsAnimation(%s): " + "Setting mRecentsAnimationStartPending = false", callback)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TaskAnimationManager.startRecentsAnimation(%s): " + "Setting mRecentsAnimationStartPending = false", @@ -448,7 +447,7 @@ public class ActiveGestureProtoLogProxy { "TaskAnimationManager.startRecentsAnimation: " + "Setting mRecentsAnimationStartPending = %b", value)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TaskAnimationManager.startRecentsAnimation: " + "Setting mRecentsAnimationStartPending = %b", @@ -458,7 +457,7 @@ public class ActiveGestureProtoLogProxy { public static void logLaunchingSideTask(int taskId) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "Launching side task id=%d", taskId)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Launching side task id=%d", taskId); } @@ -466,7 +465,7 @@ public class ActiveGestureProtoLogProxy { int displayId, @NonNull ActiveGestureLog.CompoundString reason) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "TIS.onMotionEvent(displayId=%d): ", displayId).append(reason)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onMotionEvent(displayId=%d): %s", displayId, reason.toString()); } @@ -474,14 +473,14 @@ public class ActiveGestureProtoLogProxy { public static void logStartNewTask(@NonNull ActiveGestureLog.CompoundString tasks) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "Launching task: ").append(tasks)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onMotionEvent: %s", tasks.toString()); } public static void logMotionPauseDetectorEvent(@NonNull ActiveGestureLog.CompoundString event) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "MotionPauseDetector: ").append(event)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "MotionPauseDetector: %s", event.toString()); } @@ -489,7 +488,7 @@ public class ActiveGestureProtoLogProxy { @NonNull ActiveGestureLog.CompoundString reason) { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "handleTaskAppeared check failed: ").append(reason)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "handleTaskAppeared check failed: %s", reason.toString()); } @@ -501,7 +500,7 @@ public class ActiveGestureProtoLogProxy { @NonNull String string, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { ActiveGestureLog.INSTANCE.addLog(string, gestureEvent); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "%s", string); } @@ -509,7 +508,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "onSettledOnEndTarget %s", endTarget), /* gestureEvent= */ ON_SETTLED_ON_END_TARGET); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "onSettledOnEndTarget %s", endTarget); } @@ -520,7 +519,7 @@ public class ActiveGestureProtoLogProxy { velocityY, angle), velocityX == 0 && velocityY == 0 ? INVALID_VELOCITY_ON_SWIPE_UP : null); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "calculateEndTarget: velocities=(x=%fdp/ms, y=%fdp/ms), angle=%f", velocityX, @@ -533,7 +532,7 @@ public class ActiveGestureProtoLogProxy { "Forcefully finishing recents animation: Unexpected task appeared id=%d, pkg=%s", taskId, packageName)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Forcefully finishing recents animation: Unexpected task appeared id=%d, pkg=%s", taskId, @@ -543,7 +542,7 @@ public class ActiveGestureProtoLogProxy { public static void logCreateTouchRegionForDisplay(int displayRotation, @NonNull Point displaySize, @NonNull RectF swipeRegion, @NonNull RectF ohmRegion, int gesturalHeight, int largerGesturalHeight, @NonNull String reason) { - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "OrientationTouchTransformer.createRegionForDisplay: " + "dispRot=%d, dispSize=%s, swipeRegion=%s, ohmRegion=%s, " @@ -556,7 +555,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "TaskAnimationManager not available for displayId=%d", displayId)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "TaskAnimationManager not available for displayId=%d", displayId); } @@ -565,7 +564,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "AbsSwipeUpHandler not available for displayId=%d", displayId)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler not available for displayId=%d", displayId); } @@ -574,7 +573,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( "OtherActivityInputConsumer.startTouchTrackingForWindowAnimation: " + "interactionHandler=%s", interactionHandler)); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "OtherActivityInputConsumer.startTouchTrackingForWindowAnimation: " + "interactionHandler=%s", interactionHandler); @@ -584,7 +583,7 @@ public class ActiveGestureProtoLogProxy { ActiveGestureLog.INSTANCE.addLog("Launcher destroyed while mRecentsAnimationStartPending ==" + " true, queuing a callback to clean the pending animation up on start", /* gestureEvent= */ ON_START_RECENTS_ANIMATION); - if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; + if (!isProtoLogInitialized()) return; ProtoLog.d(ACTIVE_GESTURE_LOG, "Launcher destroyed while mRecentsAnimationStartPending ==" + " true, queuing a callback to clean the pending animation up on start"); } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/desktop/DesktopAppLaunchTransitionManagerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/desktop/DesktopAppLaunchTransitionManagerTest.kt index 7ebef45d27..b705beab6e 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/desktop/DesktopAppLaunchTransitionManagerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/desktop/DesktopAppLaunchTransitionManagerTest.kt @@ -25,9 +25,12 @@ import android.platform.test.flag.junit.SetFlagsRule import android.view.WindowManager.TRANSIT_OPEN import android.view.WindowManager.TRANSIT_TO_FRONT import android.window.TransitionFilter +import android.window.TransitionFilter.CONTAINER_ORDER_ANY +import android.window.TransitionFilter.CONTAINER_ORDER_TOP import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.quickstep.SystemUiProxy +import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_APP_LAUNCH_BUGFIX import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_APP_LAUNCH_TRANSITIONS_BUGFIX import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import com.google.common.truth.Truth.assertThat @@ -77,7 +80,8 @@ class DesktopAppLaunchTransitionManagerTest { @Test @EnableFlags(FLAG_ENABLE_DESKTOP_APP_LAUNCH_TRANSITIONS_BUGFIX) - fun registerTransitions_usesCorrectFilter() { + @DisableFlags(FLAG_ENABLE_DESKTOP_APP_LAUNCH_BUGFIX) + fun registerTransitions_usesCorrectFilter_flagDisabled() { transitionManager.registerTransitions() val filterArgumentCaptor = argumentCaptor() @@ -92,5 +96,29 @@ class DesktopAppLaunchTransitionManagerTest { assertThat(launchRequirement.mModes).isEqualTo(intArrayOf(TRANSIT_OPEN, TRANSIT_TO_FRONT)) assertThat(launchRequirement.mActivityType).isEqualTo(ACTIVITY_TYPE_STANDARD) assertThat(launchRequirement.mWindowingMode).isEqualTo(WINDOWING_MODE_FREEFORM) + assertThat(launchRequirement.mOrder).isEqualTo(CONTAINER_ORDER_TOP) + } + + @Test + @EnableFlags( + FLAG_ENABLE_DESKTOP_APP_LAUNCH_TRANSITIONS_BUGFIX, + FLAG_ENABLE_DESKTOP_APP_LAUNCH_BUGFIX, + ) + fun registerTransitions_usesCorrectFilter_flagEnabled() { + transitionManager.registerTransitions() + val filterArgumentCaptor = argumentCaptor() + + verify(systemUiProxy, times(1)) + .registerRemoteTransition(any(), filterArgumentCaptor.capture()) + + assertThat(filterArgumentCaptor.lastValue).isNotNull() + assertThat(filterArgumentCaptor.lastValue.mTypeSet) + .isEqualTo(intArrayOf(TRANSIT_OPEN, TRANSIT_TO_FRONT)) + assertThat(filterArgumentCaptor.lastValue.mRequirements).hasLength(1) + val launchRequirement = filterArgumentCaptor.lastValue.mRequirements!![0] + assertThat(launchRequirement.mModes).isEqualTo(intArrayOf(TRANSIT_OPEN, TRANSIT_TO_FRONT)) + assertThat(launchRequirement.mActivityType).isEqualTo(ACTIVITY_TYPE_STANDARD) + assertThat(launchRequirement.mWindowingMode).isEqualTo(WINDOWING_MODE_FREEFORM) + assertThat(launchRequirement.mOrder).isEqualTo(CONTAINER_ORDER_ANY) } } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt index 19c88240d9..6ccc063459 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt @@ -35,6 +35,7 @@ import com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR import com.android.launcher3.util.TestUtil import com.android.quickstep.AllAppsActionManager import com.android.quickstep.fallback.window.RecentsDisplayModel +import com.android.quickstep.input.QuickstepKeyGestureEventsManager import java.lang.reflect.Field import java.lang.reflect.ParameterizedType import java.util.Locale @@ -108,7 +109,11 @@ class TaskbarUnitTestRule( object : TaskbarManager( context, - AllAppsActionManager(context, UI_HELPER_EXECUTOR) { + AllAppsActionManager( + context, + UI_HELPER_EXECUTOR, + QuickstepKeyGestureEventsManager(context), + ) { PendingIntent(IIntentSender.Default()) }, object : TaskbarNavButtonCallbacks {}, diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/AllAppsActionManagerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/AllAppsActionManagerTest.kt index a1bd107caf..a37655186e 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/AllAppsActionManagerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/AllAppsActionManagerTest.kt @@ -18,6 +18,7 @@ package com.android.quickstep import android.app.PendingIntent import android.content.IIntentSender +import android.hardware.input.InputManager import android.provider.Settings import android.provider.Settings.Secure.USER_SETUP_COMPLETE import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -29,6 +30,7 @@ import com.android.launcher3.util.SandboxApplication import com.android.launcher3.util.SettingsCache import com.android.launcher3.util.SettingsCacheSandbox import com.android.launcher3.util.TestUtil +import com.android.quickstep.input.QuickstepKeyGestureEventsManager import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component @@ -39,6 +41,11 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.mockito.Mockito.spy +import org.mockito.Mockito.verify +import org.mockito.kotlin.any +import org.mockito.kotlin.doNothing +import org.mockito.kotlin.whenever private const val TIMEOUT = 5L private val USER_SETUP_COMPLETE_URI = Settings.Secure.getUriFor(USER_SETUP_COMPLETE) @@ -49,24 +56,29 @@ class AllAppsActionManagerTest { private val bgExecutor = UI_HELPER_EXECUTOR @get:Rule val context = SandboxApplication() + private val inputManager = context.spyService(InputManager::class.java) private val settingsCacheSandbox = SettingsCacheSandbox().also { it[USER_SETUP_COMPLETE_URI] = 1 } + private val quickstepKeyGestureEventsManager = spy(QuickstepKeyGestureEventsManager(context)) private val allAppsActionManager by lazy(LazyThreadSafetyMode.NONE) { - AllAppsActionManager(context, bgExecutor) { + AllAppsActionManager(context, bgExecutor, quickstepKeyGestureEventsManager) { callbackSemaphore.release() PendingIntent(IIntentSender.Default()) } } @Before - fun initDaggerComponent() { + fun setUp() { context.initDaggerComponent( DaggerAllAppsActionManagerTestComponent.builder() .bindSettingsCache(settingsCacheSandbox.cache) ) + + doNothing().whenever(inputManager).registerKeyGestureEventHandler(any(), any()) + doNothing().whenever(inputManager).unregisterKeyGestureEventHandler(any()) } @After fun destroyManager() = allAppsActionManager.onDestroy() @@ -74,15 +86,19 @@ class AllAppsActionManagerTest { @Test fun taskbarPresent_actionRegistered() { allAppsActionManager.isTaskbarPresent = true + TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to register. assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue() assertThat(allAppsActionManager.isActionRegistered).isTrue() + verify(quickstepKeyGestureEventsManager).registerAllAppsKeyGestureEvent(any()) } @Test fun homeAndOverviewSame_actionRegistered() { allAppsActionManager.isHomeAndOverviewSame = true + TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to register. assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue() assertThat(allAppsActionManager.isActionRegistered).isTrue() + verify(quickstepKeyGestureEventsManager).registerAllAppsKeyGestureEvent(any()) } @Test @@ -93,6 +109,7 @@ class AllAppsActionManagerTest { allAppsActionManager.isTaskbarPresent = false TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to unregister. assertThat(allAppsActionManager.isActionRegistered).isFalse() + verify(quickstepKeyGestureEventsManager).unregisterAllAppsKeyGestureEvent() } @Test @@ -103,6 +120,7 @@ class AllAppsActionManagerTest { TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to unregister. assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue() assertThat(allAppsActionManager.isActionRegistered).isFalse() + verify(quickstepKeyGestureEventsManager).unregisterAllAppsKeyGestureEvent() } @Test @@ -136,8 +154,10 @@ class AllAppsActionManagerTest { allAppsActionManager.isTaskbarPresent = true settingsCacheSandbox[USER_SETUP_COMPLETE_URI] = 1 + TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to register. assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue() assertThat(allAppsActionManager.isActionRegistered).isTrue() + verify(quickstepKeyGestureEventsManager).registerAllAppsKeyGestureEvent(any()) } @Test @@ -146,8 +166,10 @@ class AllAppsActionManagerTest { allAppsActionManager.isTaskbarPresent = true allAppsActionManager.isSetupUiVisible = false + TestUtil.runOnExecutorSync(bgExecutor) {} // Force system action to register. assertThat(callbackSemaphore.tryAcquire(TIMEOUT, SECONDS)).isTrue() assertThat(allAppsActionManager.isActionRegistered).isTrue() + verify(quickstepKeyGestureEventsManager).registerAllAppsKeyGestureEvent(any()) } } diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentTasksListTest.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentTasksListTest.java index 1e4315a040..867995ff8b 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentTasksListTest.java +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentTasksListTest.java @@ -18,7 +18,6 @@ package com.android.quickstep; import static android.view.Display.DEFAULT_DISPLAY; -import static com.android.launcher3.Flags.FLAG_ENABLE_SEPARATE_EXTERNAL_DISPLAY_TASKS; import static com.android.window.flags.Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND; import static com.google.common.truth.Truth.assertThat; @@ -236,39 +235,6 @@ public class RecentTasksListTest { } @Test - @DisableFlags({FLAG_ENABLE_SEPARATE_EXTERNAL_DISPLAY_TASKS, - FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND}) - public void loadTasksInBackground_freeformTask_createsDesktopTask() throws Exception { - List tasks = Arrays.asList( - createRecentTaskInfo(1 /* taskId */, DEFAULT_DISPLAY), - createRecentTaskInfo(4 /* taskId */, DEFAULT_DISPLAY), - createRecentTaskInfo(5 /* taskId */, 1 /* displayId */), - createRecentTaskInfo(6 /* taskId */, 1 /* displayId */)); - GroupedTaskInfo recentTaskInfos = GroupedTaskInfo.forDeskTasks( - 0 /* deskId */, DEFAULT_DISPLAY, tasks, - Collections.emptySet() /* minimizedTaskIds */); - when(mSystemUiProxy.getRecentTasks(anyInt(), anyInt())) - .thenReturn(new ArrayList<>(Collections.singletonList(recentTaskInfos))); - - List taskList = mRecentTasksList.loadTasksInBackground( - Integer.MAX_VALUE /* numTasks */, -1 /* requestId */, false /* loadKeysOnly */); - - assertEquals(1, taskList.size()); - assertEquals(TaskViewType.DESKTOP, taskList.get(0).taskViewType); - List actualFreeformTasks = taskList.get(0).getTasks(); - assertEquals(4, actualFreeformTasks.size()); - assertEquals(1, actualFreeformTasks.get(0).key.id); - assertFalse(actualFreeformTasks.get(0).isMinimized); - assertEquals(4, actualFreeformTasks.get(1).key.id); - assertFalse(actualFreeformTasks.get(1).isMinimized); - assertEquals(5, actualFreeformTasks.get(2).key.id); - assertFalse(actualFreeformTasks.get(2).isMinimized); - assertEquals(6, actualFreeformTasks.get(3).key.id); - assertFalse(actualFreeformTasks.get(3).isMinimized); - } - - @Test - @EnableFlags(FLAG_ENABLE_SEPARATE_EXTERNAL_DISPLAY_TASKS) @DisableFlags(FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND) public void loadTasksInBackground_freeformTask_createsDesktopTaskPerDisplay() throws Exception { List tasks = Arrays.asList( diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/input/QuickstepKeyGestureEventsHandlerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/input/QuickstepKeyGestureEventsHandlerTest.kt new file mode 100644 index 0000000000..e5b517ede9 --- /dev/null +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/input/QuickstepKeyGestureEventsHandlerTest.kt @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.quickstep.input + +import android.app.PendingIntent +import android.hardware.input.InputManager +import android.hardware.input.KeyGestureEvent +import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_ALL_APPS +import android.os.Bundle +import android.platform.test.annotations.DisableFlags +import android.platform.test.annotations.EnableFlags +import android.platform.test.flag.junit.SetFlagsRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.SmallTest +import com.android.launcher3.taskbar.TaskbarManager.EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID +import com.android.launcher3.util.SandboxApplication +import com.android.window.flags.Flags +import com.google.common.truth.Truth.assertThat +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.kotlin.KArgumentCaptor +import org.mockito.kotlin.any +import org.mockito.kotlin.argumentCaptor +import org.mockito.kotlin.doNothing +import org.mockito.kotlin.eq +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify +import org.mockito.kotlin.verifyNoInteractions +import org.mockito.kotlin.whenever + +@SmallTest +@RunWith(AndroidJUnit4::class) +class QuickstepKeyGestureEventsHandlerTest { + @get:Rule val context = SandboxApplication() + + @get:Rule val setFlagsRule = SetFlagsRule(SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT) + + private val inputManager = context.spyService(InputManager::class.java) + private val keyGestureEventsManager = QuickstepKeyGestureEventsManager(context) + private val allAppsPendingIntent: PendingIntent = mock() + private val keyGestureEventsCaptor: KArgumentCaptor> = argumentCaptor() + private val bundleCaptor: KArgumentCaptor = argumentCaptor() + + @Before + fun setup() { + doNothing().whenever(inputManager).registerKeyGestureEventHandler(any(), any()) + doNothing().whenever(inputManager).unregisterKeyGestureEventHandler(any()) + } + + @Test + @EnableFlags(Flags.FLAG_ENABLE_KEY_GESTURE_HANDLER_FOR_RECENTS) + fun registerKeyGestureEventsHandler_flagEnabled_registerWithExpectedKeyGestureEvents() { + keyGestureEventsManager.registerAllAppsKeyGestureEvent(allAppsPendingIntent) + + verify(inputManager) + .registerKeyGestureEventHandler( + keyGestureEventsCaptor.capture(), + eq(keyGestureEventsManager.allAppsKeyGestureEventHandler), + ) + assertThat(keyGestureEventsCaptor.firstValue).containsExactly(KEY_GESTURE_TYPE_ALL_APPS) + } + + @Test + @DisableFlags(Flags.FLAG_ENABLE_KEY_GESTURE_HANDLER_FOR_RECENTS) + fun registerKeyGestureEventsHandler_flagDisabled_noRegister() { + keyGestureEventsManager.registerAllAppsKeyGestureEvent(allAppsPendingIntent) + + verifyNoInteractions(inputManager) + } + + @Test + @EnableFlags(Flags.FLAG_ENABLE_KEY_GESTURE_HANDLER_FOR_RECENTS) + fun unregisterKeyGestureEventsHandler_flagEnabled_unregisterHandler() { + keyGestureEventsManager.unregisterAllAppsKeyGestureEvent() + + verify(inputManager) + .unregisterKeyGestureEventHandler( + eq(keyGestureEventsManager.allAppsKeyGestureEventHandler) + ) + } + + @Test + @DisableFlags(Flags.FLAG_ENABLE_KEY_GESTURE_HANDLER_FOR_RECENTS) + fun unregisterKeyGestureEventsHandler_flagDisabled_noUnregister() { + keyGestureEventsManager.unregisterAllAppsKeyGestureEvent() + + verifyNoInteractions(inputManager) + } + + @Test + @EnableFlags(Flags.FLAG_ENABLE_KEY_GESTURE_HANDLER_FOR_RECENTS) + fun handleEvent_flagEnabled_allApps_toggleAllAppsSearchWithDisplayId() { + keyGestureEventsManager.registerAllAppsKeyGestureEvent(allAppsPendingIntent) + + keyGestureEventsManager.allAppsKeyGestureEventHandler.handleKeyGestureEvent( + KeyGestureEvent.Builder() + .setDisplayId(TEST_DISPLAY_ID) + .setKeyGestureType(KEY_GESTURE_TYPE_ALL_APPS) + .build(), + /* focusedToken= */ null, + ) + + verify(allAppsPendingIntent).send(bundleCaptor.capture()) + assertThat(bundleCaptor.firstValue.getInt(EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID)) + .isEqualTo(TEST_DISPLAY_ID) + } + + @Test + @DisableFlags(Flags.FLAG_ENABLE_KEY_GESTURE_HANDLER_FOR_RECENTS) + fun handleEvent_flagDisabled_allApps_noInteractionWithTaskbar() { + keyGestureEventsManager.registerAllAppsKeyGestureEvent(allAppsPendingIntent) + + keyGestureEventsManager.allAppsKeyGestureEventHandler.handleKeyGestureEvent( + KeyGestureEvent.Builder() + .setDisplayId(TEST_DISPLAY_ID) + .setKeyGestureType(KEY_GESTURE_TYPE_ALL_APPS) + .build(), + /* focusedToken= */ null, + ) + + verifyNoInteractions(allAppsPendingIntent) + } + + private companion object { + const val TEST_DISPLAY_ID = 6789 + } +} diff --git a/src/com/android/launcher3/dragndrop/LauncherDragController.java b/src/com/android/launcher3/dragndrop/LauncherDragController.java index dd433c02d3..ed07542f31 100644 --- a/src/com/android/launcher3/dragndrop/LauncherDragController.java +++ b/src/com/android/launcher3/dragndrop/LauncherDragController.java @@ -151,9 +151,7 @@ public class LauncherDragController extends DragController { initialDragViewScale, dragViewScaleOnDrop, scalePx); - // During a drag, we don't want to expose the descendendants of drag view to a11y users, - // since those decendents are not a valid position in the workspace. - dragView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + dragView.setItemInfo(dragInfo); mDragObject.dragComplete = false; @@ -161,6 +159,7 @@ public class LauncherDragController extends DragController { mDragObject.yOffset = mMotionDown.y - (dragLayerY + dragRegionTop); mDragDriver = DragDriver.create(this, mOptions, mFlingToDeleteHelper::recordMotionEvent); + prepareViewForAccessibility(dragView); if (!mOptions.isAccessibleDrag) { mDragObject.stateAnnouncer = DragViewStateAnnouncer.createFor(dragView); } @@ -198,6 +197,21 @@ public class LauncherDragController extends DragController { return dragView; } + /** + * During a drag, we don't want to expose the descendants of drag view to a11y users, + * since those descendants are not a valid position in the workspace. + * We need to go through the children because the view itself is important for + * accessibility, basically we are implementing: + * IMPORTANT_FOR_ACCESSIBILITY_YES_HIDE_DESCENDANTS + */ + void prepareViewForAccessibility(DragView dragView) { + for (int i = 0; i < dragView.getChildCount(); i++) { + dragView.getChildAt(i).setImportantForAccessibility( + View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS + ); + } + } + /** * Returns the scale in terms of pixels (to be applied on width) to scale the preview diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java index 4a60390477..4c86b09275 100644 --- a/src/com/android/launcher3/folder/FolderPagedView.java +++ b/src/com/android/launcher3/folder/FolderPagedView.java @@ -131,7 +131,7 @@ public class FolderPagedView extends PagedView implements Cli public void setFolder(Folder folder) { mFolder = folder; mPageIndicator = folder.findViewById(R.id.folder_page_indicator); - mPageIndicator.setArrowClickListener(direction -> snapToPageImmediately( + mPageIndicator.setArrowClickListener(direction -> snapToPage( (Direction.END == direction) ? mCurrentPage + 1 : mCurrentPage - 1)); initParentViews(folder); }