Snap for 13348984 from efae5662e8 to 25Q3-release

Change-Id: If37bbe96c6f110f8a2aabafd4721be04ba03c64f
This commit is contained in:
Android Build Coastguard Worker committed 2025-04-11 18:19:42 -07:00
commit 2fce8a8fbd
28 files changed
+511 -249

No files matched your search

+1 -28
View File
@@ -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
}
}
}
-10
View File
@@ -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"
+3
View File
@@ -49,6 +49,9 @@
-->
<uses-permission android:name="android.permission.ACCESS_HIDDEN_PROFILES_FULL" />
<!-- Permission required to listen to recent, all app key gestures. -->
<uses-permission android:name="android.permission.MANAGE_KEY_GESTURES" />
<!-- Permission required to start a WidgetPickerActivity. -->
<permission android:name="${applicationId}.permission.START_WIDGET_PICKER_ACTIVITY"
android:protectionLevel="signature|privileged" />
@@ -52,6 +52,7 @@ interface BasePerDisplayModule {
@Module
object PerDisplayRepositoriesModule {
@Provides
@LauncherAppSingleton
fun provideRecentsAnimationDeviceStateRepo(
repositoryFactory: PerDisplayInstanceRepositoryImpl.Factory<RecentsAnimationDeviceState>,
rotationTouchHelperRepository: PerDisplayRepository<RotationTouchHelper>,
@@ -77,6 +78,7 @@ object PerDisplayRepositoriesModule {
}
@Provides
@LauncherAppSingleton
fun provideTaskAnimationManagerRepo(
repositoryFactory: PerDisplayInstanceRepositoryImpl.Factory<TaskAnimationManager>,
instanceFactory: TaskAnimationManager.Factory,
@@ -92,6 +94,7 @@ object PerDisplayRepositoriesModule {
}
@Provides
@LauncherAppSingleton
fun provideRotationTouchHandlerRepo(
repositoryFactory: PerDisplayInstanceRepositoryImpl.Factory<RotationTouchHelper>,
@DisplayContext displayContextRepository: PerDisplayRepository<Context>,
@@ -113,6 +116,7 @@ object PerDisplayRepositoriesModule {
}
@Provides
@LauncherAppSingleton
@DisplayContext
fun provideDisplayContext(
repositoryFactory: PerDisplayInstanceRepositoryImpl.Factory<Context>,
@@ -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
@@ -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;
@@ -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;
@@ -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;
@@ -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,
)
}
@@ -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.
*/
@@ -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()
}
}
}
@@ -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<Integer> 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.
@@ -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<Integer, ThumbnailData> 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);
}
@@ -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);
@@ -92,6 +92,10 @@ public class FallbackRecentsView<CONTAINER_TYPE extends Context & RecentsViewCon
public void init(OverviewActionsView actionsView, SplitSelectStateController splitController,
@Nullable DesktopRecentsTransitionController desktopRecentsTransitionController) {
super.init(actionsView, splitController, desktopRecentsTransitionController);
if (RecentsWindowFlags.getEnableOverviewInWindow()) {
// These will be set during the state transition to DEFAULT
return;
}
setOverviewStateEnabled(true);
setOverlayEnabled(true);
}
@@ -231,34 +231,40 @@ class RecentsWindowManager(context: Context, wallpaperColorHints: Int) :
}
windowManager.addView(windowView, windowLayoutParams)
windowView
?.findOnBackInvokedDispatcher()
?.registerSystemOnBackInvokedCallback(onBackInvokedCallback)
windowView?.let {
actionsView = it.findViewById(R.id.overview_actions_view)
recentsView =
it.findViewById<FallbackRecentsView<RecentsWindowManager>?>(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)
@@ -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"
}
}
@@ -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) {
@@ -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 }
}
@@ -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<*, *>
@@ -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");
}
@@ -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<TransitionFilter>()
@@ -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<TransitionFilter>()
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)
}
}
@@ -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 {},
@@ -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())
}
}
@@ -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<TaskInfo> 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<GroupTask> taskList = mRecentTasksList.loadTasksInBackground(
Integer.MAX_VALUE /* numTasks */, -1 /* requestId */, false /* loadKeysOnly */);
assertEquals(1, taskList.size());
assertEquals(TaskViewType.DESKTOP, taskList.get(0).taskViewType);
List<Task> 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<TaskInfo> tasks = Arrays.asList(
@@ -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<List<Int>> = argumentCaptor()
private val bundleCaptor: KArgumentCaptor<Bundle> = 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
}
}
@@ -151,9 +151,7 @@ public class LauncherDragController extends DragController<Launcher> {
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<Launcher> {
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<Launcher> {
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
@@ -131,7 +131,7 @@ public class FolderPagedView extends PagedView<PageIndicatorDots> 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);
}