Merge "Dismiss recents when device goes to sleep" into main
diff --git a/aconfig/launcher_overview.aconfig b/aconfig/launcher_overview.aconfig
index 93d8d54..b299edf 100644
--- a/aconfig/launcher_overview.aconfig
+++ b/aconfig/launcher_overview.aconfig
@@ -61,4 +61,14 @@
namespace: "launcher_overview"
description: "Enables the non-overlapping layout for desktop windows in Overview mode."
bug: "378011776"
+}
+
+flag {
+ name: "enable_use_top_visible_activity_for_exclude_from_recent_task"
+ namespace: "launcher_overview"
+ description: "Enables using the top visible activity for exclude from recent task instead of the activity indicies."
+ bug: "342627272"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
}
\ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java
index fd0243a..2ff9b18 100644
--- a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java
+++ b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java
@@ -111,10 +111,9 @@
public boolean areDesktopTasksVisible() {
boolean desktopTasksVisible = mVisibleDesktopTasksCount > 0;
if (DEBUG) {
- Log.d(TAG, "areDesktopTasksVisible: desktopVisible=" + desktopTasksVisible
- + " overview=" + mInOverviewState);
+ Log.d(TAG, "areDesktopTasksVisible: desktopVisible=" + desktopTasksVisible);
}
- return desktopTasksVisible && !mInOverviewState;
+ return desktopTasksVisible;
}
/**
@@ -219,12 +218,8 @@
+ " currentValue=" + mInOverviewState);
}
if (overviewStateEnabled != mInOverviewState) {
- final boolean wereDesktopTasksVisibleBefore = areDesktopTasksVisible();
mInOverviewState = overviewStateEnabled;
final boolean areDesktopTasksVisibleNow = areDesktopTasksVisible();
- if (wereDesktopTasksVisibleBefore != areDesktopTasksVisibleNow) {
- notifyDesktopVisibilityListeners(areDesktopTasksVisibleNow);
- }
if (ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY.isTrue()) {
return;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 0f639f9..70cb7ce 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -196,6 +196,12 @@
private boolean mIsFullscreen;
// The size we should return to when we call setTaskbarWindowFullscreen(false)
private int mLastRequestedNonFullscreenSize;
+ /**
+ * When this is true, the taskbar window size is not updated. Requests to update the window
+ * size are stored in {@link #mLastRequestedNonFullscreenSize} and will take effect after
+ * bubbles no longer animate and {@link #setTaskbarWindowForAnimatingBubble()} is called.
+ */
+ private boolean mIsTaskbarSizeFrozenForAnimatingBubble;
private NavigationMode mNavMode;
private boolean mImeDrawsImeNavBar;
@@ -442,6 +448,8 @@
onNavButtonsDarkIntensityChanged(sharedState.navButtonsDarkIntensity);
onNavigationBarLumaSamplingEnabled(sharedState.mLumaSamplingDisplayId,
sharedState.mIsLumaSamplingEnabled);
+ setWallpaperVisible(sharedState.wallpaperVisible);
+ onTransitionModeUpdated(sharedState.barMode, true /* checkBarModes */);
if (ENABLE_TASKBAR_NAVBAR_UNIFICATION) {
// W/ the flag not set this entire class gets re-created, which resets the value of
@@ -496,6 +504,13 @@
return getBubbleControllers() != null && BubbleBarController.isBubbleBarEnabled();
}
+ private boolean isBubbleBarAnimating() {
+ return mControllers
+ .bubbleControllers
+ .map(controllers -> controllers.bubbleBarViewController.isAnimatingNewBubble())
+ .orElse(false);
+ }
+
/**
* Returns if software keyboard is docked or input toolbar is placed at the taskbar area
*/
@@ -1062,6 +1077,25 @@
}
/**
+ * Updates the taskbar window size according to whether bubbles are animating.
+ *
+ * <p>This method should be called when bubbles start animating and again after the animation is
+ * complete.
+ */
+ public void setTaskbarWindowForAnimatingBubble() {
+ if (isBubbleBarAnimating()) {
+ // the default window size accounts for the bubble flyout
+ setTaskbarWindowSize(getDefaultTaskbarWindowSize());
+ mIsTaskbarSizeFrozenForAnimatingBubble = true;
+ } else {
+ mIsTaskbarSizeFrozenForAnimatingBubble = false;
+ setTaskbarWindowSize(
+ mLastRequestedNonFullscreenSize != 0
+ ? mLastRequestedNonFullscreenSize : getDefaultTaskbarWindowSize());
+ }
+ }
+
+ /**
* Called when drag ends or when a view is removed from the DragLayer.
*/
void onDragEndOrViewRemoved() {
@@ -1097,11 +1131,13 @@
size = mDeviceProfile.heightPx;
} else {
mLastRequestedNonFullscreenSize = size;
- if (mIsFullscreen) {
- // We still need to be fullscreen, so defer any change to our height until we call
- // setTaskbarWindowFullscreen(false). For example, this could happen when dragging
- // from the gesture region, as the drag will cancel the gesture and reset launcher's
- // state, which in turn normally would reset the taskbar window height as well.
+ if (mIsFullscreen || mIsTaskbarSizeFrozenForAnimatingBubble) {
+ // We either still need to be fullscreen or a bubble is still animating, so defer
+ // any change to our height until setTaskbarWindowFullscreen(false) is called or
+ // setTaskbarWindowForAnimatingBubble() is called after the bubble animation
+ // completed. For example, this could happen when dragging from the gesture region,
+ // as the drag will cancel the gesture and reset launcher's state, which in turn
+ // normally would reset the taskbar window height as well.
return;
}
}
@@ -1285,9 +1321,25 @@
} else if (tag instanceof TaskItemInfo info) {
RemoteTransition remoteTransition = canUnminimizeDesktopTask(info.getTaskId())
? createUnminimizeRemoteTransition() : null;
- UI_HELPER_EXECUTOR.execute(() ->
- SystemUiProxy.INSTANCE.get(this).showDesktopApp(
- info.getTaskId(), remoteTransition));
+
+ if (areDesktopTasksVisible() && recents != null) {
+ TaskView taskView = recents.getTaskViewByTaskId(info.getTaskId());
+ if (taskView == null) return;
+ RunnableList runnableList = taskView.launchWithAnimation();
+ if (runnableList != null) {
+ runnableList.add(() ->
+ // wrapped it in runnable here since we need the post for DW to be
+ // ready. if we don't other DW will be gone and only the launched task
+ // will show.
+ UI_HELPER_EXECUTOR.execute(() ->
+ SystemUiProxy.INSTANCE.get(this).showDesktopApp(
+ info.getTaskId(), remoteTransition)));
+ }
+ } else {
+ UI_HELPER_EXECUTOR.execute(() ->
+ SystemUiProxy.INSTANCE.get(this).showDesktopApp(
+ info.getTaskId(), remoteTransition));
+ }
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(
/* stash= */ true);
} else if (tag instanceof WorkspaceItemInfo) {
@@ -1531,7 +1583,17 @@
.launchAppPair((AppPairIcon) launchingIconView,
-1 /*cuj*/)));
} else {
- startItemInfoActivity(itemInfos.get(0), foundTask);
+ if (areDesktopTasksVisible()) {
+ RunnableList runnableList = recents.launchDesktopTaskView();
+ // Wrapping it in runnable so we post after DW is ready for the app
+ // launch.
+ if (runnableList != null) {
+ runnableList.add(() -> UI_HELPER_EXECUTOR.execute(
+ () -> startItemInfoActivity(itemInfos.get(0), foundTask)));
+ }
+ } else {
+ startItemInfoActivity(itemInfos.get(0), foundTask);
+ }
}
}
);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java
index bdc7f92..444c356 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java
@@ -49,6 +49,8 @@
public static final int FLAG_AUTOHIDE_SUSPEND_HOVERING_ICONS = 1 << 6;
// User has multi instance window open.
public static final int FLAG_AUTOHIDE_SUSPEND_MULTI_INSTANCE_MENU_OPEN = 1 << 7;
+ // User has taskbar overflow open.
+ public static final int FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW = 1 << 8;
@IntDef(flag = true, value = {
FLAG_AUTOHIDE_SUSPEND_FULLSCREEN,
@@ -59,6 +61,7 @@
FLAG_AUTOHIDE_SUSPEND_TRANSIENT_TASKBAR,
FLAG_AUTOHIDE_SUSPEND_HOVERING_ICONS,
FLAG_AUTOHIDE_SUSPEND_MULTI_INSTANCE_MENU_OPEN,
+ FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW,
})
@Retention(RetentionPolicy.SOURCE)
public @interface AutohideSuspendFlag {}
@@ -138,6 +141,8 @@
"FLAG_AUTOHIDE_SUSPEND_TRANSIENT_TASKBAR");
appendFlag(str, flags, FLAG_AUTOHIDE_SUSPEND_MULTI_INSTANCE_MENU_OPEN,
"FLAG_AUTOHIDE_SUSPEND_MULTI_INSTANCE_MENU_OPEN");
+ appendFlag(str, flags, FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW,
+ "FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW");
return str.toString();
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 2db7961..250e33a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -1018,7 +1018,12 @@
@Override
public void onRecentsAnimationFinished(RecentsAnimationController controller) {
- endGestureStateOverride(!controller.getFinishTargetIsLauncher(), false /*canceled*/);
+ endGestureStateOverride(!controller.getFinishTargetIsLauncher(),
+ controller.getLauncherIsVisibleAtFinish(), false /*canceled*/);
+ }
+
+ private void endGestureStateOverride(boolean finishedToApp, boolean canceled) {
+ endGestureStateOverride(finishedToApp, finishedToApp, canceled);
}
/**
@@ -1028,11 +1033,13 @@
*
* @param finishedToApp {@code true} if the recents animation finished to showing an app and
* not workspace or overview
+ * @param launcherIsVisible {code true} if launcher is visible at finish
* @param canceled {@code true} if the recents animation was canceled instead of
* finishing
* to completion
*/
- private void endGestureStateOverride(boolean finishedToApp, boolean canceled) {
+ private void endGestureStateOverride(boolean finishedToApp, boolean launcherIsVisible,
+ boolean canceled) {
mCallbacks.removeListener(this);
mTaskBarRecentsAnimationListener = null;
((RecentsView) mLauncher.getOverviewPanel()).setTaskLaunchListener(null);
@@ -1041,18 +1048,27 @@
mSkipNextRecentsAnimEnd = false;
return;
}
- updateStateForUserFinishedToApp(finishedToApp);
+ updateStateForUserFinishedToApp(finishedToApp, launcherIsVisible);
}
}
/**
+ * @see #updateStateForUserFinishedToApp(boolean, boolean)
+ */
+ private void updateStateForUserFinishedToApp(boolean finishedToApp) {
+ updateStateForUserFinishedToApp(finishedToApp, !finishedToApp);
+ }
+
+ /**
* Updates the visible state immediately to ensure a seamless handoff.
*
* @param finishedToApp True iff user is in an app.
+ * @param launcherIsVisible True iff launcher is still visible (ie. transparent app)
*/
- private void updateStateForUserFinishedToApp(boolean finishedToApp) {
+ private void updateStateForUserFinishedToApp(boolean finishedToApp,
+ boolean launcherIsVisible) {
// Update the visible state immediately to ensure a seamless handoff
- boolean launcherVisible = !finishedToApp;
+ boolean launcherVisible = !finishedToApp || launcherIsVisible;
updateStateForFlag(FLAG_TRANSITION_TO_VISIBLE, false);
updateStateForFlag(FLAG_VISIBLE, launcherVisible);
applyState();
@@ -1061,7 +1077,7 @@
if (DEBUG) {
Log.d(TAG, "endGestureStateOverride - FLAG_IN_APP: " + finishedToApp);
}
- controller.updateStateForFlag(FLAG_IN_APP, finishedToApp);
+ controller.updateStateForFlag(FLAG_IN_APP, finishedToApp && !launcherIsVisible);
controller.applyState();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index ff8e4a8..9407e73 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -113,7 +113,7 @@
private static final Uri NAV_BAR_KIDS_MODE = Settings.Secure.getUriFor(
Settings.Secure.NAV_BAR_KIDS_MODE);
- private final Context mContext;
+ private final Context mWindowContext;
private final @Nullable Context mNavigationBarPanelContext;
private WindowManager mWindowManager;
private boolean mAddedWindow;
@@ -231,7 +231,7 @@
@NonNull DesktopVisibilityController desktopVisibilityController) {
Display display =
context.getSystemService(DisplayManager.class).getDisplay(context.getDisplayId());
- mContext = context.createWindowContext(display,
+ mWindowContext = context.createWindowContext(display,
ENABLE_TASKBAR_NAVBAR_UNIFICATION ? TYPE_NAVIGATION_BAR : TYPE_NAVIGATION_BAR_PANEL,
null);
mAllAppsActionManager = allAppsActionManager;
@@ -240,30 +240,47 @@
: null;
mDesktopVisibilityController = desktopVisibilityController;
if (enableTaskbarNoRecreate()) {
- mWindowManager = mContext.getSystemService(WindowManager.class);
- FrameLayout taskbarRootLayout = new FrameLayout(mContext) {
- @Override
- public boolean dispatchTouchEvent(MotionEvent ev) {
- // The motion events can be outside the view bounds of task bar, and hence
- // manually dispatching them to the drag layer here.
- TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
- if (taskbar != null && taskbar.getDragLayer().isAttachedToWindow()) {
- return taskbar.getDragLayer().dispatchTouchEvent(ev);
- }
- return super.dispatchTouchEvent(ev);
- }
- };
- addTaskbarRootLayoutToMap(getDefaultDisplayId(), taskbarRootLayout);
+ mWindowManager = mWindowContext.getSystemService(WindowManager.class);
+ createTaskbarRootLayout(getDefaultDisplayId());
}
- mDefaultNavButtonController = new TaskbarNavButtonController(
+ mDefaultNavButtonController = createDefaultNavButtonController(context, navCallbacks);
+ mDefaultComponentCallbacks = createDefaultComponentCallbacks();
+ SettingsCache.INSTANCE.get(mWindowContext)
+ .register(USER_SETUP_COMPLETE_URI, mOnSettingsChangeListener);
+ SettingsCache.INSTANCE.get(mWindowContext)
+ .register(NAV_BAR_KIDS_MODE, mOnSettingsChangeListener);
+ Log.d(TASKBAR_NOT_DESTROYED_TAG, "registering component callbacks from constructor.");
+ mWindowContext.registerComponentCallbacks(mDefaultComponentCallbacks);
+ mShutdownReceiver.register(mWindowContext, Intent.ACTION_SHUTDOWN);
+ UI_HELPER_EXECUTOR.execute(() -> {
+ mSharedState.taskbarSystemActionPendingIntent = PendingIntent.getBroadcast(
+ mWindowContext,
+ SYSTEM_ACTION_ID_TASKBAR,
+ new Intent(ACTION_SHOW_TASKBAR).setPackage(mWindowContext.getPackageName()),
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
+ mTaskbarBroadcastReceiver.register(
+ mWindowContext, RECEIVER_NOT_EXPORTED, ACTION_SHOW_TASKBAR);
+ });
+
+ debugWhyTaskbarNotDestroyed("TaskbarManager created");
+ recreateTaskbar();
+ }
+
+ @NonNull
+ private TaskbarNavButtonController createDefaultNavButtonController(Context context,
+ TaskbarNavButtonCallbacks navCallbacks) {
+ return new TaskbarNavButtonController(
context,
navCallbacks,
- SystemUiProxy.INSTANCE.get(mContext),
- ContextualEduStatsManager.INSTANCE.get(mContext),
+ SystemUiProxy.INSTANCE.get(mWindowContext),
+ ContextualEduStatsManager.INSTANCE.get(mWindowContext),
new Handler(),
- new ContextualSearchInvoker(mContext));
- mDefaultComponentCallbacks = new ComponentCallbacks() {
- private Configuration mOldConfig = mContext.getResources().getConfiguration();
+ new ContextualSearchInvoker(mWindowContext));
+ }
+
+ private ComponentCallbacks createDefaultComponentCallbacks() {
+ return new ComponentCallbacks() {
+ private Configuration mOldConfig = mWindowContext.getResources().getConfiguration();
@Override
public void onConfigurationChanged(Configuration newConfig) {
@@ -273,7 +290,7 @@
"TaskbarManager#mComponentCallbacks.onConfigurationChanged: " + newConfig);
// TODO: adapt this logic to be specific to different displays.
DeviceProfile dp = mUserUnlocked
- ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext)
+ ? LauncherAppState.getIDP(mWindowContext).getDeviceProfile(mWindowContext)
: null;
int configDiff = mOldConfig.diff(newConfig) & ~SKIP_RECREATE_CONFIG_CHANGES;
@@ -317,25 +334,6 @@
@Override
public void onLowMemory() { }
};
- SettingsCache.INSTANCE.get(mContext)
- .register(USER_SETUP_COMPLETE_URI, mOnSettingsChangeListener);
- SettingsCache.INSTANCE.get(mContext)
- .register(NAV_BAR_KIDS_MODE, mOnSettingsChangeListener);
- Log.d(TASKBAR_NOT_DESTROYED_TAG, "registering component callbacks from constructor.");
- mContext.registerComponentCallbacks(mDefaultComponentCallbacks);
- mShutdownReceiver.register(mContext, Intent.ACTION_SHUTDOWN);
- UI_HELPER_EXECUTOR.execute(() -> {
- mSharedState.taskbarSystemActionPendingIntent = PendingIntent.getBroadcast(
- mContext,
- SYSTEM_ACTION_ID_TASKBAR,
- new Intent(ACTION_SHOW_TASKBAR).setPackage(mContext.getPackageName()),
- PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
- mTaskbarBroadcastReceiver.register(
- mContext, RECEIVER_NOT_EXPORTED, ACTION_SHOW_TASKBAR);
- });
-
- debugWhyTaskbarNotDestroyed("TaskbarManager created");
- recreateTaskbar();
}
private void destroyAllTaskbars() {
@@ -360,7 +358,7 @@
removeTaskbarFromMap(displayId);
}
DeviceProfile dp = mUserUnlocked ?
- LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null;
+ LauncherAppState.getIDP(mWindowContext).getDeviceProfile(mWindowContext) : null;
if (dp == null || !isTaskbarEnabled(dp)) {
removeTaskbarRootViewFromWindow(displayId);
}
@@ -407,7 +405,7 @@
*/
public void onUserUnlocked() {
mUserUnlocked = true;
- DisplayController.INSTANCE.get(mContext).addChangeListener(mRecreationListener);
+ DisplayController.INSTANCE.get(mWindowContext).addChangeListener(mRecreationListener);
recreateTaskbar();
addTaskbarRootViewToWindow(getDefaultDisplayId());
}
@@ -470,7 +468,7 @@
return ql.getUnfoldTransitionProgressProvider();
}
} else {
- return SystemUiProxy.INSTANCE.get(mContext).getUnfoldTransitionProvider();
+ return SystemUiProxy.INSTANCE.get(mWindowContext).getUnfoldTransitionProvider();
}
return null;
}
@@ -514,7 +512,7 @@
Trace.beginSection("recreateTaskbar");
try {
DeviceProfile dp = mUserUnlocked ?
- LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null;
+ LauncherAppState.getIDP(mWindowContext).getDeviceProfile(mWindowContext) : null;
// All Apps action is unrelated to navbar unification, so we only need to check DP.
final boolean isLargeScreenTaskbar = dp != null && dp.isTaskbarPresent;
@@ -528,7 +526,7 @@
+ " FLAG_HIDE_NAVBAR_WINDOW=" + ENABLE_TASKBAR_NAVBAR_UNIFICATION
+ " dp.isTaskbarPresent=" + (dp == null ? "null" : dp.isTaskbarPresent));
if (!isTaskbarEnabled || !isLargeScreenTaskbar) {
- SystemUiProxy.INSTANCE.get(mContext)
+ SystemUiProxy.INSTANCE.get(mWindowContext)
.notifyTaskbarStatus(/* visible */ false, /* stashed */ false);
if (!isTaskbarEnabled) {
return;
@@ -537,9 +535,7 @@
TaskbarActivityContext taskbar = getTaskbarForDisplay(displayId);
if (enableTaskbarNoRecreate() || taskbar == null) {
- taskbar = new TaskbarActivityContext(mContext,
- mNavigationBarPanelContext, dp, mDefaultNavButtonController,
- mUnfoldProgressProvider, mDesktopVisibilityController);
+ taskbar = createTaskbarActivityContext(dp, displayId);
} else {
taskbar.updateDeviceProfile(dp);
}
@@ -560,7 +556,6 @@
taskbarRootLayout.addView(taskbar.getDragLayer());
taskbar.notifyUpdateLayoutParams();
}
- addTaskbarToMap(displayId, taskbar);
} finally {
Trace.endSection();
}
@@ -716,22 +711,23 @@
mRecentsViewContainer = null;
debugWhyTaskbarNotDestroyed("TaskbarManager#destroy()");
removeActivityCallbacksAndListeners();
- mTaskbarBroadcastReceiver.unregisterReceiverSafely(mContext);
+ mTaskbarBroadcastReceiver.unregisterReceiverSafely(mWindowContext);
destroyAllTaskbars();
if (mUserUnlocked) {
- DisplayController.INSTANCE.get(mContext).removeChangeListener(mRecreationListener);
+ DisplayController.INSTANCE.get(mWindowContext).removeChangeListener(
+ mRecreationListener);
}
- SettingsCache.INSTANCE.get(mContext)
+ SettingsCache.INSTANCE.get(mWindowContext)
.unregister(USER_SETUP_COMPLETE_URI, mOnSettingsChangeListener);
- SettingsCache.INSTANCE.get(mContext)
+ SettingsCache.INSTANCE.get(mWindowContext)
.unregister(NAV_BAR_KIDS_MODE, mOnSettingsChangeListener);
Log.d(TASKBAR_NOT_DESTROYED_TAG, "unregistering component callbacks from destroy().");
- mContext.unregisterComponentCallbacks(mDefaultComponentCallbacks);
- mShutdownReceiver.unregisterReceiverSafely(mContext);
+ mWindowContext.unregisterComponentCallbacks(mDefaultComponentCallbacks);
+ mShutdownReceiver.unregisterReceiverSafely(mWindowContext);
}
public @Nullable TaskbarActivityContext getCurrentActivityContext() {
- return getTaskbarForDisplay(mContext.getDisplayId());
+ return getTaskbarForDisplay(mWindowContext.getDisplayId());
}
public void dumpLogs(String prefix, PrintWriter pw) {
@@ -773,6 +769,19 @@
return mTaskbars.get(displayId);
}
+
+ /**
+ * Creates a {@link TaskbarActivityContext} for the given display and adds it to the map.
+ */
+ private TaskbarActivityContext createTaskbarActivityContext(DeviceProfile dp, int displayId) {
+ TaskbarActivityContext newTaskbar = new TaskbarActivityContext(mWindowContext,
+ mNavigationBarPanelContext, dp, mDefaultNavButtonController,
+ mUnfoldProgressProvider, mDesktopVisibilityController);
+
+ addTaskbarToMap(displayId, newTaskbar);
+ return newTaskbar;
+ }
+
/**
* Adds the {@link TaskbarActivityContext} associated with the given display ID to taskbar
* map if there is not already a taskbar mapped to that displayId.
@@ -796,6 +805,26 @@
}
/**
+ * Creates {@link FrameLayout} for the taskbar on the specified display and adds it to map.
+ * @param displayId The ID of the display for which to create the taskbar root layout.
+ */
+ private void createTaskbarRootLayout(int displayId) {
+ FrameLayout newTaskbarRootLayout = new FrameLayout(mWindowContext) {
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ // The motion events can be outside the view bounds of task bar, and hence
+ // manually dispatching them to the drag layer here.
+ TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId());
+ if (taskbar != null && taskbar.getDragLayer().isAttachedToWindow()) {
+ return taskbar.getDragLayer().dispatchTouchEvent(ev);
+ }
+ return super.dispatchTouchEvent(ev);
+ }
+ };
+ addTaskbarRootLayoutToMap(displayId, newTaskbarRootLayout);
+ }
+
+ /**
* Retrieves the root layout of the taskbar for the specified display.
*
* @param displayId The ID of the display for which to retrieve the taskbar root layout.
@@ -812,7 +841,7 @@
* @param rootLayout The taskbar root layout {@link FrameLayout} to add to the map.
*/
private void addTaskbarRootLayoutToMap(int displayId, FrameLayout rootLayout) {
- if (!mRootLayouts.contains(displayId)) {
+ if (!mRootLayouts.contains(displayId) && rootLayout != null) {
mRootLayouts.put(displayId, rootLayout);
}
}
@@ -829,7 +858,7 @@
}
private int getDefaultDisplayId() {
- return mContext.getDisplayId();
+ return mWindowContext.getDisplayId();
}
/** Temp logs for b/254119092. */
@@ -839,15 +868,15 @@
boolean activityTaskbarPresent = mActivity != null
&& mActivity.getDeviceProfile().isTaskbarPresent;
- boolean contextTaskbarPresent = mUserUnlocked
- && LauncherAppState.getIDP(mContext).getDeviceProfile(mContext).isTaskbarPresent;
+ boolean contextTaskbarPresent = mUserUnlocked && LauncherAppState.getIDP(mWindowContext)
+ .getDeviceProfile(mWindowContext).isTaskbarPresent;
if (activityTaskbarPresent == contextTaskbarPresent) {
- log.add("mActivity and mContext agree taskbarIsPresent=" + contextTaskbarPresent);
+ log.add("mActivity and mWindowContext agree taskbarIsPresent=" + contextTaskbarPresent);
Log.d(TASKBAR_NOT_DESTROYED_TAG, log.toString());
return;
}
- log.add("mActivity and mContext device profiles have different values, add more logs.");
+ log.add("mActivity & mWindowContext device profiles have different values, add more logs.");
log.add("\tmActivity logs:");
log.add("\t\tmActivity=" + mActivity);
@@ -857,13 +886,13 @@
log.add("\t\tmActivity.getDeviceProfile().isTaskbarPresent="
+ activityTaskbarPresent);
}
- log.add("\tmContext logs:");
- log.add("\t\tmContext=" + mContext);
- log.add("\t\tmContext.getResources().getConfiguration()="
- + mContext.getResources().getConfiguration());
+ log.add("\tmWindowContext logs:");
+ log.add("\t\tmWindowContext=" + mWindowContext);
+ log.add("\t\tmWindowContext.getResources().getConfiguration()="
+ + mWindowContext.getResources().getConfiguration());
if (mUserUnlocked) {
- log.add("\t\tLauncherAppState.getIDP().getDeviceProfile(mContext).isTaskbarPresent="
- + contextTaskbarPresent);
+ log.add("\t\tLauncherAppState.getIDP().getDeviceProfile(mWindowContext)"
+ + ".isTaskbarPresent=" + contextTaskbarPresent);
} else {
log.add("\t\tCouldn't get DeviceProfile because !mUserUnlocked");
}
@@ -876,6 +905,6 @@
@VisibleForTesting
public Context getWindowContext() {
- return mContext;
+ return mWindowContext;
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
index 2e0bae5..abf35a2 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.taskbar;
+import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS;
import static com.android.launcher3.model.data.AppInfo.COMPONENT_KEY_COMPARATOR;
import static com.android.launcher3.util.SplitConfigurationOptions.getLogEventForPosition;
@@ -309,9 +310,7 @@
*/
SystemShortcut.Factory<BaseTaskbarContext> createNewWindowShortcutFactory() {
return (context, itemInfo, originalView) -> {
- ComponentKey key = itemInfo.getComponentKey();
- AppInfo app = getApp(key);
- if (app != null && app.supportsMultiInstance()) {
+ if (shouldShowMultiInstanceOptions(itemInfo)) {
return new NewWindowTaskbarShortcut<>(context, itemInfo, originalView);
}
return null;
@@ -325,9 +324,7 @@
*/
public SystemShortcut.Factory<BaseTaskbarContext> createManageWindowsShortcutFactory() {
return (context, itemInfo, originalView) -> {
- ComponentKey key = itemInfo.getComponentKey();
- AppInfo app = getApp(key);
- if (app != null && app.supportsMultiInstance()) {
+ if (shouldShowMultiInstanceOptions(itemInfo)) {
return new ManageWindowsTaskbarShortcut<>(context, itemInfo, originalView,
mControllers);
}
@@ -336,6 +333,16 @@
}
/**
+ * Determines whether to show multi-instance options for a given item.
+ */
+ private boolean shouldShowMultiInstanceOptions(ItemInfo itemInfo) {
+ ComponentKey key = itemInfo.getComponentKey();
+ AppInfo app = getApp(key);
+ return app != null && app.supportsMultiInstance()
+ && itemInfo.container != CONTAINER_ALL_APPS;
+ }
+
+ /**
* A single menu item ("Split left," "Split right," or "Split top") that executes a split
* from the taskbar, as if the user performed a drag and drop split.
* Includes an onClick method that initiates the actual split.
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java
index 4d77ab2..f2bd4d0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java
@@ -18,6 +18,7 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_ALLAPPS_BUTTON_LONG_PRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP;
+import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -180,6 +181,9 @@
if (mTaskbarView.getTaskbarOverflowView() != null) {
mTaskbarView.getTaskbarOverflowView().setIsActive(
!mTaskbarView.getTaskbarOverflowView().getIsActive());
+ mControllers.taskbarAutohideSuspendController
+ .updateFlag(FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW,
+ mTaskbarView.getTaskbarOverflowView().getIsActive());
}
mControllers.keyboardQuickSwitchController.toggleQuickSwitchViewForTaskbar(
mControllers.taskbarViewController.getTaskIdsForPinnedApps(),
@@ -190,6 +194,8 @@
if (mTaskbarView.getTaskbarOverflowView() != null) {
mTaskbarView.getTaskbarOverflowView().setIsActive(false);
}
+ mControllers.taskbarAutohideSuspendController.updateFlag(
+ FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW, false);
}
private float getDividerCenterX() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
index 987937e..5b3c233 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java
@@ -405,8 +405,12 @@
mBubbleBarViewController.showOverflow(true);
}
- // Adds and removals have happened, update visibility before any other visual changes.
- mBubbleBarViewController.setHiddenForBubbles(mBubbles.isEmpty());
+ // Update the visibility if this is the initial state or if there are no bubbles.
+ // If this is the initial bubble, the bubble bar will become visible as part of the
+ // animation.
+ if (update.initialState || mBubbles.isEmpty()) {
+ mBubbleBarViewController.setHiddenForBubbles(mBubbles.isEmpty());
+ }
mBubbleStashedHandleViewController.ifPresent(
controller -> controller.setHiddenForBubbles(mBubbles.isEmpty()));
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
index 67d7901..dd1b0ca 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java
@@ -170,7 +170,8 @@
mBubbleBarContainer, createFlyoutPositioner(), createFlyoutCallbacks());
mBubbleBarViewAnimator = new BubbleBarViewAnimator(
mBarView, mBubbleStashController, mBubbleBarFlyoutController,
- createBubbleBarParentViewController(), mBubbleBarController::showExpandedView);
+ createBubbleBarParentViewController(), mBubbleBarController::showExpandedView,
+ () -> setHiddenForBubbles(false));
mTaskbarViewPropertiesProvider = taskbarViewPropertiesProvider;
onBubbleBarConfigurationChanged(/* animate= */ false);
mActivity.addOnDeviceProfileChangeListener(
@@ -328,7 +329,7 @@
return new BubbleBarParentViewHeightUpdateNotifier() {
@Override
public void updateTopBoundary() {
- mActivity.setTaskbarWindowSize(mActivity.getDefaultTaskbarWindowSize());
+ mActivity.setTaskbarWindowForAnimatingBubble();
}
};
}
@@ -580,15 +581,23 @@
/** Returns maximum height of the bubble bar with the flyout view. */
public int getBubbleBarWithFlyoutMaximumHeight() {
- if (!isBubbleBarVisible()) return 0;
+ if (!isBubbleBarVisible() && !isAnimatingNewBubble()) return 0;
int bubbleBarTopOnHome = (int) (mBubbleStashController.getBubbleBarVerticalCenterForHome()
- + mBarView.getBubbleBarCollapsedHeight() / 2);
- int result = (int) (bubbleBarTopOnHome + mBarView.getArrowHeight());
+ + mBarView.getBubbleBarCollapsedHeight() / 2 + mBarView.getArrowHeight());
if (isAnimatingNewBubble()) {
- // when animating new bubble add the maximum height of the flyout view
- result += mBubbleBarFlyoutController.getMaximumFlyoutHeight();
+ if (mTaskbarStashController.isInApp() && mBubbleStashController.getHasHandleView()) {
+ // when animating a bubble in an app, the bubble bar will be higher than its
+ // position on home
+ float bubbleBarTopDistanceFromBottom =
+ -mBubbleStashController.getBubbleBarTranslationYForTaskbar()
+ + mBarView.getHeight();
+ return (int) bubbleBarTopDistanceFromBottom
+ + mBubbleBarFlyoutController.getMaximumFlyoutHeight();
+ }
+ return bubbleBarTopOnHome + mBubbleBarFlyoutController.getMaximumFlyoutHeight();
+ } else {
+ return bubbleBarTopOnHome;
}
- return result;
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt
index 6f8943f..3bff58b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimator.kt
@@ -42,6 +42,7 @@
private val bubbleBarFlyoutController: BubbleBarFlyoutController,
private val bubbleBarParentViewHeightUpdateNotifier: BubbleBarParentViewHeightUpdateNotifier,
private val onExpanded: Runnable,
+ private val onBubbleBarVisible: Runnable,
private val scheduler: Scheduler = HandlerScheduler(bubbleBarView),
) {
@@ -397,9 +398,12 @@
// prepare the bubble bar for the animation
bubbleBarView.translationY = bubbleBarView.height.toFloat()
bubbleBarView.visibility = VISIBLE
+ onBubbleBarVisible.run()
bubbleBarView.alpha = 1f
bubbleBarView.scaleX = 1f
bubbleBarView.scaleY = 1f
+ bubbleBarView.setBackgroundScaleX(1f)
+ bubbleBarView.setBackgroundScaleY(1f)
val translationTracker = TranslationTracker(bubbleBarView.translationY)
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutController.kt b/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutController.kt
index 63db012..7c718e5b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/flyout/BubbleBarFlyoutController.kt
@@ -63,8 +63,6 @@
return rect
}
- fun getFlyoutMaxHeight(): Int = BubbleBarFlyoutView.getMaximumViewHeight(container.context)
-
fun setUpAndShowFlyout(message: BubbleBarFlyoutMessage, onInit: () -> Unit, onEnd: () -> Unit) {
flyout?.let(container::removeView)
val flyout = BubbleBarFlyoutView(container.context, positioner, flyoutScheduler)
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 1970014..fbc8d6a 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -80,6 +80,8 @@
import android.os.SystemClock;
import android.util.Log;
import android.util.Pair;
+import android.util.TimeUtils;
+import android.view.Choreographer;
import android.view.MotionEvent;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
@@ -1734,13 +1736,30 @@
}
private void handOffAnimation(PointF velocityPxPerMs) {
- if (!TransitionAnimator.Companion.longLivedReturnAnimationsEnabled()
- || mRecentsAnimationController == null) {
+ if (!TransitionAnimator.Companion.longLivedReturnAnimationsEnabled()) {
+ return;
+ }
+
+ // This function is not guaranteed to be called inside a frame. We try to access the frame
+ // time immediately, but if we're not inside a frame we must post a callback to be run at
+ // the beginning of the next frame.
+ try {
+ handOffAnimationInternal(Choreographer.getInstance().getFrameTime(), velocityPxPerMs);
+ } catch (IllegalStateException e) {
+ Choreographer.getInstance().postFrameCallback(
+ frameTimeNanos -> handOffAnimationInternal(
+ frameTimeNanos / TimeUtils.NANOS_PER_MS, velocityPxPerMs));
+ }
+ }
+
+ private void handOffAnimationInternal(long timestamp, PointF velocityPxPerMs) {
+ if (mRecentsAnimationController == null) {
return;
}
Pair<RemoteAnimationTarget[], WindowAnimationState[]> targetsAndStates =
- extractTargetsAndStates(mRemoteTargetHandles, velocityPxPerMs);
+ extractTargetsAndStates(
+ mRemoteTargetHandles, timestamp, velocityPxPerMs);
mRecentsAnimationController.handOffAnimation(
targetsAndStates.first, targetsAndStates.second);
ActiveGestureProtoLogProxy.logHandOffAnimation();
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
index 461f963..c09bf3e 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
@@ -70,7 +70,7 @@
private val taskAnimationManager: TaskAnimationManager,
private val dispatcherProvider: DispatcherProvider = ProductionDispatchers,
) {
- private val coroutineScope = CoroutineScope(SupervisorJob() + dispatcherProvider.default)
+ private val coroutineScope = CoroutineScope(SupervisorJob() + dispatcherProvider.background)
private val commandQueue = ConcurrentLinkedDeque<CommandInfo>()
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationController.java b/quickstep/src/com/android/quickstep/RecentsAnimationController.java
index 055aadb..145773d 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationController.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationController.java
@@ -56,6 +56,8 @@
private boolean mFinishRequested = false;
// Only valid when mFinishRequested == true.
private boolean mFinishTargetIsLauncher;
+ // Only valid when mFinishRequested == true
+ private boolean mLauncherIsVisibleAtFinish;
private RunnableList mPendingFinishCallbacks = new RunnableList();
public RecentsAnimationController(RecentsAnimationControllerCompat controller,
@@ -130,13 +132,27 @@
}
@UiThread
+ public void finish(boolean toRecents, boolean launcherIsVisibleAtFinish,
+ Runnable onFinishComplete, boolean sendUserLeaveHint) {
+ Preconditions.assertUIThread();
+ finishController(toRecents, launcherIsVisibleAtFinish, onFinishComplete, sendUserLeaveHint,
+ false);
+ }
+
+ @UiThread
public void finishController(boolean toRecents, Runnable callback, boolean sendUserLeaveHint) {
- finishController(toRecents, callback, sendUserLeaveHint, false /* forceFinish */);
+ finishController(toRecents, false, callback, sendUserLeaveHint, false /* forceFinish */);
}
@UiThread
public void finishController(boolean toRecents, Runnable callback, boolean sendUserLeaveHint,
boolean forceFinish) {
+ finishController(toRecents, toRecents, callback, sendUserLeaveHint, forceFinish);
+ }
+
+ @UiThread
+ public void finishController(boolean toRecents, boolean launcherIsVisibleAtFinish,
+ Runnable callback, boolean sendUserLeaveHint, boolean forceFinish) {
mPendingFinishCallbacks.add(callback);
if (!forceFinish && mFinishRequested) {
// If finish has already been requested, then add the callback to the pending list.
@@ -148,6 +164,7 @@
// Finish not yet requested
mFinishRequested = true;
mFinishTargetIsLauncher = toRecents;
+ mLauncherIsVisibleAtFinish = launcherIsVisibleAtFinish;
mOnFinishedListener.accept(this);
Runnable finishCb = () -> {
mController.finish(toRecents, sendUserLeaveHint, new IResultReceiver.Stub() {
@@ -224,6 +241,14 @@
return mFinishTargetIsLauncher;
}
+ /**
+ * RecentsAnimationListeners can check this in onRecentsAnimationFinished() to determine whether
+ * the animation was finished to launcher vs an app.
+ */
+ public boolean getLauncherIsVisibleAtFinish() {
+ return mLauncherIsVisibleAtFinish;
+ }
+
public void dump(String prefix, PrintWriter pw) {
pw.println(prefix + "RecentsAnimationController:");
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index 783c87c..084cede 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -795,14 +795,15 @@
* second applies to the target in the same index of the first.
*
* @param handles The handles wrapping each target.
+ * @param timestamp The start time of the current frame.
* @param velocityPxPerMs The current velocity of the target animations.
*/
@NonNull
public static Pair<RemoteAnimationTarget[], WindowAnimationState[]> extractTargetsAndStates(
- @NonNull RemoteTargetHandle[] handles, @NonNull PointF velocityPxPerMs) {
+ @NonNull RemoteTargetHandle[] handles, long timestamp,
+ @NonNull PointF velocityPxPerMs) {
RemoteAnimationTarget[] targets = new RemoteAnimationTarget[handles.length];
WindowAnimationState[] animationStates = new WindowAnimationState[handles.length];
- long timestamp = System.currentTimeMillis();
for (int i = 0; i < handles.length; i++) {
targets[i] = handles[i].getTransformParams().getTargetSet().apps[i];
diff --git a/quickstep/src/com/android/quickstep/task/viewmodel/TaskThumbnailViewModelImpl.kt b/quickstep/src/com/android/quickstep/task/viewmodel/TaskThumbnailViewModelImpl.kt
index b6cb984..e5bad67 100644
--- a/quickstep/src/com/android/quickstep/task/viewmodel/TaskThumbnailViewModelImpl.kt
+++ b/quickstep/src/com/android/quickstep/task/viewmodel/TaskThumbnailViewModelImpl.kt
@@ -61,12 +61,14 @@
override val dimProgress: Flow<Float> =
combine(taskContainerData.taskMenuOpenProgress, recentsViewData.tintAmount) {
- taskMenuOpenProgress,
- tintAmount ->
- max(taskMenuOpenProgress * MAX_SCRIM_ALPHA, tintAmount)
- }
+ taskMenuOpenProgress,
+ tintAmount ->
+ max(taskMenuOpenProgress * MAX_SCRIM_ALPHA, tintAmount)
+ }
+ .flowOn(dispatcherProvider.background)
- override val splashAlpha = splashProgress.flatMapLatest { it }
+ override val splashAlpha =
+ splashProgress.flatMapLatest { it }.flowOn(dispatcherProvider.background)
private val isLiveTile =
combine(
@@ -77,7 +79,6 @@
runningTaskIds.contains(taskId) && !runningTaskShowScreenshot
}
.distinctUntilChanged()
- .flowOn(dispatcherProvider.default)
override val uiState: Flow<TaskThumbnailUiState> =
combine(task.flatMapLatest { it }, isLiveTile) { taskVal, isRunning ->
@@ -99,7 +100,7 @@
}
}
.distinctUntilChanged()
- .flowOn(dispatcherProvider.default)
+ .flowOn(dispatcherProvider.background)
override fun bind(taskId: Int) {
Log.d(TAG, "bind taskId: $taskId")
diff --git a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt
index c3b072d..908e9f9 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt
+++ b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt
@@ -48,16 +48,6 @@
return otherTasks + desktopTasks
}
- /** Returns the expected index of the focus task. */
- fun getFocusedTaskIndex(taskGroups: List<GroupTask>): Int {
- // The focused task index is placed after the desktop tasks views.
- return if (enableLargeDesktopWindowingTile()) {
- taskGroups.count { it.taskViewType == TaskViewType.DESKTOP }
- } else {
- 0
- }
- }
-
/** Counts [TaskView]s that are [DesktopTaskView] instances. */
fun getDesktopTaskViewCount(taskViews: Iterable<TaskView>): Int =
taskViews.count { it is DesktopTaskView }
@@ -81,6 +71,30 @@
): TaskView? =
taskViews.firstOrNull { it.isLargeTile && !(splitSelectActive && it is DesktopTaskView) }
+ /** Returns the expected focus task. */
+ fun getExpectedFocusedTask(taskViews: Iterable<TaskView>): TaskView? =
+ if (enableLargeDesktopWindowingTile()) taskViews.firstOrNull { it !is DesktopTaskView }
+ else taskViews.firstOrNull()
+
+ /**
+ * Returns the [TaskView] that should be the current page during task binding, in the following
+ * priorities:
+ * 1. Running task
+ * 2. Focused task
+ * 3. First non-desktop task
+ * 4. Last desktop task
+ * 5. null otherwise
+ */
+ fun getExpectedCurrentTask(
+ runningTaskView: TaskView?,
+ focusedTaskView: TaskView?,
+ taskViews: Iterable<TaskView>,
+ ): TaskView? =
+ runningTaskView
+ ?: focusedTaskView
+ ?: taskViews.firstOrNull { it !is DesktopTaskView }
+ ?: taskViews.lastOrNull()
+
/**
* Returns the first TaskView that is not large
*
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
index d35a36a..1eb91ae 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
@@ -106,6 +106,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Optional;
import java.util.function.Consumer;
/**
@@ -941,6 +942,10 @@
mLauncher, mLauncher.getDragLayer(),
null /* thumbnail */,
mAppIcon, new RectF());
+ floatingTaskView.setOnClickListener(view ->
+ getSplitAnimationController()
+ .playAnimPlaceholderToFullscreen(mContainer, view,
+ Optional.of(() -> resetState())));
floatingTaskView.setAlpha(1);
floatingTaskView.addStagingAnimation(anim, mTaskBounds, mTempRect,
false /* fadeWithThumbnail */, true /* isStagedTask */);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 6fc33dc..e7cb05e 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1510,6 +1510,19 @@
}
/**
+ * Launch DesktopTaskView if found.
+ * @return provides runnable list to attach runnable at end of Desktop Mode launch
+ */
+ public RunnableList launchDesktopTaskView() {
+ for (TaskView taskView : getTaskViews()) {
+ if (taskView instanceof DesktopTaskView) {
+ return taskView.launchWithAnimation();
+ }
+ }
+ return null;
+ }
+
+ /**
* Returns a {@link TaskView} that has taskId matching {@code taskId} or null if no match.
*/
@Nullable
@@ -1957,18 +1970,20 @@
}
// Keep same previous focused task
- TaskView newFocusedTaskView = getTaskViewByTaskIds(focusedTaskIds);
- if (enableLargeDesktopWindowingTile() && newFocusedTaskView instanceof DesktopTaskView) {
- newFocusedTaskView = null;
+ TaskView newFocusedTaskView = null;
+ if (!enableGridOnlyOverview()) {
+ newFocusedTaskView = getTaskViewByTaskIds(focusedTaskIds);
+ if (enableLargeDesktopWindowingTile()
+ && newFocusedTaskView instanceof DesktopTaskView) {
+ newFocusedTaskView = null;
+ }
+ // If the list changed, maybe the focused task doesn't exist anymore.
+ if (newFocusedTaskView == null) {
+ newFocusedTaskView = mUtils.getExpectedFocusedTask(getTaskViews());
+ }
}
- // If the list changed, maybe the focused task doesn't exist anymore
- int newFocusedTaskViewIndex = mUtils.getFocusedTaskIndex(taskGroups);
- if (newFocusedTaskView == null && getTaskViewCount() > newFocusedTaskViewIndex) {
- newFocusedTaskView = getTaskViewAt(newFocusedTaskViewIndex);
- }
-
- setFocusedTaskViewId(newFocusedTaskView != null && !enableGridOnlyOverview()
- ? newFocusedTaskView.getTaskViewId() : INVALID_TASK_ID);
+ setFocusedTaskViewId(
+ newFocusedTaskView != null ? newFocusedTaskView.getTaskViewId() : INVALID_TASK_ID);
updateTaskSize();
updateChildTaskOrientations();
@@ -1987,6 +2002,7 @@
// for cases where the running task isn't included in this load plan (e.g. if
// the current running task is excludedFromRecents.)
showCurrentTask(mActiveGestureRunningTasks, "applyLoadPlan");
+ newRunningTaskView = getRunningTaskView();
} else {
setRunningTaskViewId(INVALID_TASK_ID);
}
@@ -2006,12 +2022,9 @@
} else if (previousFocusedPage != INVALID_PAGE) {
targetPage = previousFocusedPage;
} else {
- // Set the current page to the running task, but not if settling on new task.
- if (hasAllValidTaskIds(runningTaskIds)) {
- targetPage = indexOfChild(newRunningTaskView);
- } else if (getTaskViewCount() > newFocusedTaskViewIndex) {
- targetPage = indexOfChild(requireTaskViewAt(newFocusedTaskViewIndex));
- }
+ targetPage = indexOfChild(
+ mUtils.getExpectedCurrentTask(newRunningTaskView, newFocusedTaskView,
+ getTaskViews()));
}
if (targetPage != -1 && mCurrentPage != targetPage) {
int finalTargetPage = targetPage;
@@ -5888,11 +5901,18 @@
}
/**
+ * Finish recents animation.
+ */
+ public void finishRecentsAnimation(boolean toRecents, boolean shouldPip,
+ @Nullable Runnable onFinishComplete) {
+ finishRecentsAnimation(toRecents, shouldPip, false, onFinishComplete);
+ }
+ /**
* NOTE: Whatever value gets passed through to the toRecents param may need to also be set on
* {@link #mRecentsAnimationController#setWillFinishToHome}.
*/
public void finishRecentsAnimation(boolean toRecents, boolean shouldPip,
- @Nullable Runnable onFinishComplete) {
+ boolean allAppTargetsAreTranslucent, @Nullable Runnable onFinishComplete) {
Log.d(TAG, "finishRecentsAnimation - mRecentsAnimationController: "
+ mRecentsAnimationController);
// TODO(b/197232424#comment#10) Move this back into onRecentsAnimationComplete(). Maybe?
@@ -5906,8 +5926,9 @@
}
final boolean sendUserLeaveHint = toRecents && shouldPip;
- if (sendUserLeaveHint) {
+ if (sendUserLeaveHint && !com.android.wm.shell.Flags.enablePip2()) {
// Notify the SysUI to use fade-in animation when entering PiP from live tile.
+ // Note: PiP2 handles entering differently, so skip if enable_pip2=true.
final SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.get(getContext());
systemUiProxy.setPipAnimationTypeToAlpha();
systemUiProxy.setShelfHeight(true, mContainer.getDeviceProfile().hotseatBarSizePx);
@@ -5924,7 +5945,7 @@
tx, null /* overlay */);
}
}
- mRecentsAnimationController.finish(toRecents, () -> {
+ mRecentsAnimationController.finish(toRecents, allAppTargetsAreTranslucent, () -> {
if (onFinishComplete != null) {
onFinishComplete.run();
}
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt
index 06227e2..44070cf 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt
@@ -23,6 +23,7 @@
import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import android.view.View
+import android.view.View.INVISIBLE
import android.view.View.VISIBLE
import android.widget.FrameLayout
import android.widget.TextView
@@ -78,7 +79,7 @@
private lateinit var flyoutContainer: FrameLayout
private lateinit var bubbleStashController: BubbleStashController
private lateinit var flyoutController: BubbleBarFlyoutController
- private val onExpandedNoOp = Runnable {}
+ private val emptyRunnable = Runnable {}
private val flyoutView: View?
get() = flyoutContainer.findViewById(R.id.bubble_bar_flyout_view)
@@ -106,7 +107,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -162,7 +164,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -219,7 +222,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -268,7 +272,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -320,7 +325,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -359,7 +365,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -405,7 +412,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -457,7 +465,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -508,17 +517,21 @@
val barAnimator = PhysicsAnimator.getInstance(bubbleBarView)
+ var notifiedBubbleBarVisible = false
+ val onBubbleBarVisible = Runnable { notifiedBubbleBarVisible = true }
val animator =
BubbleBarViewAnimator(
bubbleBarView,
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = onBubbleBarVisible,
animatorScheduler,
)
InstrumentationRegistry.getInstrumentation().runOnMainSync {
+ bubbleBarView.visibility = INVISIBLE
animator.animateToInitialState(bubble, isInApp = true, isExpanding = false)
}
@@ -546,6 +559,8 @@
assertThat(bubbleBarView.alpha).isEqualTo(0)
assertThat(handle.translationY).isEqualTo(0)
assertThat(handle.alpha).isEqualTo(1)
+ assertThat(bubbleBarView.visibility).isEqualTo(VISIBLE)
+ assertThat(notifiedBubbleBarVisible).isTrue()
verify(bubbleStashController).stashBubbleBarImmediate()
}
@@ -571,7 +586,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -607,7 +623,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -653,7 +670,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -703,7 +721,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -751,7 +770,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -807,7 +827,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -862,7 +883,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -927,7 +949,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpanded,
+ onExpanded = onExpanded,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -987,7 +1010,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -1057,7 +1081,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -1133,7 +1158,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -1220,7 +1246,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
@@ -1334,7 +1361,8 @@
bubbleStashController,
flyoutController,
bubbleBarParentViewController,
- onExpandedNoOp,
+ onExpanded = emptyRunnable,
+ onBubbleBarVisible = emptyRunnable,
animatorScheduler,
)
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f7069a6..cdfbefe 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -154,6 +154,10 @@
<!-- A widget category label for grouping widgets related to note taking. [CHAR_LIMIT=30] -->
<string name="widget_category_note_taking">Note-taking</string>
+ <!-- Accessibility label on the widget preview that on click (if add button is hidden) shows the button to add widget to the home screen. [CHAR_LIMIT=none] -->
+ <string name="widget_cell_tap_to_show_add_button_label">Show add button</string>
+ <!-- Accessibility label on the widget preview that on click (if add button is showing) hides the button to add widget to the home screen. [CHAR_LIMIT=none] -->
+ <string name="widget_cell_tap_to_hide_add_button_label">Hide add button</string>
<!-- Text on the button that adds a widget to the home screen. [CHAR_LIMIT=15] -->
<string name="widget_add_button_label">Add</string>
<!-- Accessibility content description for the button that adds a widget to the home screen. The
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 16d9525..f1274dc 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -425,7 +425,9 @@
&& WindowManagerProxy.INSTANCE.get(context).isTaskbarDrawnInProcess();
// Some more constants.
- context = getContext(context, info, isVerticalBarLayout() || (isTablet && isLandscape)
+ context = getContext(context, info, inv.isFixedLandscape
+ || isVerticalBarLayout()
+ || (isTablet && isLandscape)
? Configuration.ORIENTATION_LANDSCAPE
: Configuration.ORIENTATION_PORTRAIT,
windowBounds);
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 6be8098..b20d8a5 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -36,6 +36,7 @@
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
+import com.android.launcher3.celllayout.CellLayoutLayoutParams;
import com.android.launcher3.util.HorizontalInsettableView;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
@@ -201,13 +202,16 @@
AnimatorSet animatorSet = new AnimatorSet();
for (int i = 0; i < icons.getChildCount(); i++) {
View child = icons.getChildAt(i);
- float tx = shouldAdjustHotseat ? dp.getHotseatAdjustedTranslation(getContext(), i) : 0;
- if (child instanceof Reorderable) {
- MultiTranslateDelegate mtd = ((Reorderable) child).getTranslateDelegate();
- animatorSet.play(
- mtd.getTranslationX(INDEX_BUBBLE_ADJUSTMENT_ANIM).animateToValue(tx));
- } else {
- animatorSet.play(ObjectAnimator.ofFloat(child, VIEW_TRANSLATE_X, tx));
+ if (child.getLayoutParams() instanceof CellLayoutLayoutParams lp) {
+ float tx = shouldAdjustHotseat
+ ? dp.getHotseatAdjustedTranslation(getContext(), lp.getCellX()) : 0;
+ if (child instanceof Reorderable) {
+ MultiTranslateDelegate mtd = ((Reorderable) child).getTranslateDelegate();
+ animatorSet.play(
+ mtd.getTranslationX(INDEX_BUBBLE_ADJUSTMENT_ANIM).animateToValue(tx));
+ } else {
+ animatorSet.play(ObjectAnimator.ofFloat(child, VIEW_TRANSLATE_X, tx));
+ }
}
}
//TODO(b/381109832) refactor & simplify adjustment logic
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index dfbcf5c..5becdde 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -63,6 +63,7 @@
import com.android.launcher3.util.ResourceHelper;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.WindowBounds;
+import com.android.launcher3.util.window.CachedDisplayInfo;
import com.android.launcher3.util.window.WindowManagerProxy;
import org.xmlpull.v1.XmlPullParser;
@@ -240,10 +241,7 @@
@TargetApi(23)
private InvariantDeviceProfile(Context context) {
String gridName = getCurrentGridName(context);
- String newGridName = initGrid(context, gridName);
- if (!newGridName.equals(gridName)) {
- LauncherPrefs.get(context).put(GRID_NAME, newGridName);
- }
+ initGrid(context, gridName);
DisplayController.INSTANCE.get(context).setPriorityListener(
(displayContext, info, flags) -> {
@@ -367,6 +365,11 @@
? new ArrayList<>(allOptions)
: new ArrayList<>(allOptionsFilteredByColCount),
displayInfo.getDeviceType());
+
+ if (!displayOption.grid.name.equals(gridName)) {
+ LauncherPrefs.get(context).put(GRID_NAME, displayOption.grid.name);
+ }
+
initGrid(context, displayInfo, displayOption);
return displayOption.grid.name;
}
@@ -679,28 +682,15 @@
}
private static int[] findMinWidthAndHeightDpForDevice(Info displayInfo) {
- int minWidthPx = Integer.MAX_VALUE;
- int minHeightPx = Integer.MAX_VALUE;
- for (WindowBounds bounds : displayInfo.supportedBounds) {
- boolean isTablet = displayInfo.isTablet(bounds);
- if (isTablet && displayInfo.getDeviceType() == TYPE_MULTI_DISPLAY) {
- // For split displays, take half width per page.
- minWidthPx = Math.min(minWidthPx, bounds.availableSize.x / 2);
- minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
- } else if (!isTablet && bounds.isLandscape()) {
- // We will use transposed layout in this case.
- minWidthPx = Math.min(minWidthPx, bounds.availableSize.y);
- minHeightPx = Math.min(minHeightPx, bounds.availableSize.x);
- } else {
- minWidthPx = Math.min(minWidthPx, bounds.availableSize.x);
- minHeightPx = Math.min(minHeightPx, bounds.availableSize.y);
- }
+ int minDisplayWidthDp = Integer.MAX_VALUE;
+ int minDisplayHeightDp = Integer.MAX_VALUE;
+ for (CachedDisplayInfo display: displayInfo.getAllDisplays()) {
+ minDisplayWidthDp = Math.min(minDisplayWidthDp,
+ (int) dpiFromPx(display.size.x, DisplayMetrics.DENSITY_DEVICE_STABLE));
+ minDisplayHeightDp = Math.min(minDisplayHeightDp,
+ (int) dpiFromPx(display.size.y, DisplayMetrics.DENSITY_DEVICE_STABLE));
}
-
- int minWidthDp = (int) dpiFromPx(minWidthPx, DisplayMetrics.DENSITY_DEVICE_STABLE);
- int minHeightDp = (int) dpiFromPx(minHeightPx, DisplayMetrics.DENSITY_DEVICE_STABLE);
-
- return new int[]{minWidthDp, minHeightDp};
+ return new int[]{minDisplayWidthDp, minDisplayHeightDp};
}
/**
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 548bc35..68a6e62 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -48,6 +48,8 @@
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.ArrowPopup;
import com.android.launcher3.popup.PopupContainerWithArrow;
+import com.android.launcher3.shortcuts.DeepShortcutTextView;
+import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntSet;
@@ -104,11 +106,15 @@
R.string.action_deep_shortcut, KeyEvent.KEYCODE_S));
}
+ private static boolean isNotInShortcutMenu(@Nullable View view) {
+ return view == null || !(view.getParent() instanceof DeepShortcutView);
+ }
+
@Override
protected void getSupportedActions(View host, ItemInfo item, List<LauncherAction> out) {
// If the request came from keyboard, do not add custom shortcuts as that is already
// exposed as a direct shortcut
- if (ShortcutUtil.supportsShortcuts(item)) {
+ if (isNotInShortcutMenu(host) && ShortcutUtil.supportsShortcuts(item)) {
out.add(mActions.get(DEEP_SHORTCUTS));
}
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index 83eace8..f96e959 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -389,7 +389,7 @@
}
} catch (CancellationException e) {
// Loader stopped, ignore
- logASplit("Cancelled");
+ FileLog.w(TAG, "LoaderTask cancelled:", e);
} catch (Exception e) {
memoryLogger.printLogs();
throw e;
@@ -398,6 +398,7 @@
}
public synchronized void stopLocked() {
+ FileLog.w(TAG, "LoaderTask#stopLocked:", new Exception());
mStopped = true;
this.notify();
}
diff --git a/src/com/android/launcher3/util/coroutines/DispatcherProvider.kt b/src/com/android/launcher3/util/coroutines/DispatcherProvider.kt
index e9691a8..8877535 100644
--- a/src/com/android/launcher3/util/coroutines/DispatcherProvider.kt
+++ b/src/com/android/launcher3/util/coroutines/DispatcherProvider.kt
@@ -17,18 +17,44 @@
package com.android.launcher3.util.coroutines
import kotlinx.coroutines.CoroutineDispatcher
+import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.newFixedThreadPoolContext
interface DispatcherProvider {
val default: CoroutineDispatcher
- val io: CoroutineDispatcher
+ val background: CoroutineDispatcher
val main: CoroutineDispatcher
val unconfined: CoroutineDispatcher
}
object ProductionDispatchers : DispatcherProvider {
+ private val bgDispatcher = CoroutinesHelper.bgDispatcher()
+
override val default: CoroutineDispatcher = Dispatchers.Default
- override val io: CoroutineDispatcher = Dispatchers.IO
+ override val background: CoroutineDispatcher = bgDispatcher
override val main: CoroutineDispatcher = Dispatchers.Main
override val unconfined: CoroutineDispatcher = Dispatchers.Unconfined
}
+
+private object CoroutinesHelper {
+ /**
+ * Default Coroutine dispatcher for background operations.
+ *
+ * Note that this is explicitly limiting the number of threads. In the past, we used
+ * [Dispatchers.IO]. This caused >40 threads to be spawned, and a lot of thread list lock
+ * contention between then, eventually causing jank.
+ */
+ @OptIn(DelicateCoroutinesApi::class)
+ fun bgDispatcher(): CoroutineDispatcher {
+ // Why a new ThreadPool instead of just using Dispatchers.IO with
+ // CoroutineDispatcher.limitedParallelism? Because, if we were to use Dispatchers.IO, we
+ // would share those threads with other dependencies using Dispatchers.IO.
+ // Using a dedicated thread pool we have guarantees only Launcher is able to schedule
+ // code on those.
+ return newFixedThreadPoolContext(
+ nThreads = Runtime.getRuntime().availableProcessors(),
+ name = "LauncherBg",
+ )
+ }
+}
diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
index 44ab966..0cf1f2e 100644
--- a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java
@@ -68,6 +68,8 @@
private static final String TRACE_METHOD_NAME = "appwidget load-widget ";
+ private static final Integer NO_LAYOUT_ID = Integer.valueOf(0);
+
private final CheckLongPressHelper mLongPressHelper;
protected final ActivityContext mActivityContext;
@@ -164,6 +166,21 @@
return false;
}
+ private boolean isTaggedAsScrollable() {
+ // TODO: Introduce new api in AppWidgetHostView to indicate whether the widget is
+ // scrollable.
+ for (int i = 0; i < this.getChildCount(); i++) {
+ View child = this.getChildAt(i);
+ final Integer layoutId = (Integer) child.getTag(android.R.id.widget_frame);
+ if (layoutId != null) {
+ // The layout id is only set to 0 when RemoteViews is created from
+ // DrawInstructions.
+ return NO_LAYOUT_ID.equals(layoutId);
+ }
+ }
+ return false;
+ }
+
/**
* Returns true if the application of {@link RemoteViews} through {@link #updateAppWidget} are
* currently being deferred.
@@ -266,7 +283,7 @@
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
- mIsScrollable = checkScrollableRecursively(this);
+ mIsScrollable = isTaggedAsScrollable() || checkScrollableRecursively(this);
}
/**
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index b7ad95e..9e635a3 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -17,6 +17,7 @@
package com.android.launcher3.widget;
import static android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN;
+import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;
import static com.android.launcher3.Flags.enableWidgetTapToAdd;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
@@ -40,6 +41,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
@@ -154,7 +156,21 @@
mWidgetDescription = findViewById(R.id.widget_description);
mWidgetTextContainer = findViewById(R.id.widget_text_container);
mWidgetAddButton = findViewById(R.id.widget_add_button);
+
if (enableWidgetTapToAdd()) {
+
+ setAccessibilityDelegate(new AccessibilityDelegate() {
+ @Override
+ public void onInitializeAccessibilityNodeInfo(View host,
+ AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ String accessibilityLabel = getResources().getString(mWidgetAddButton.isShown()
+ ? R.string.widget_cell_tap_to_hide_add_button_label
+ : R.string.widget_cell_tap_to_show_add_button_label);
+ info.addAction(new AccessibilityNodeInfo.AccessibilityAction(ACTION_CLICK,
+ accessibilityLabel));
+ }
+ });
mWidgetAddButton.setVisibility(INVISIBLE);
}
}
diff --git a/tests/Launcher3Tests.xml b/tests/Launcher3Tests.xml
index 270a610..a876860 100644
--- a/tests/Launcher3Tests.xml
+++ b/tests/Launcher3Tests.xml
@@ -48,6 +48,8 @@
<option name="run-command" value="settings put system pointer_location 1" />
<option name="run-command" value="settings put system show_touches 1" />
+
+ <option name="run-command" value="setprop pixel_legal_joint_permission_v2 true" />
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
diff --git a/tests/multivalentTests/src/com/android/launcher3/util/TestDispatcherProvider.kt b/tests/multivalentTests/src/com/android/launcher3/util/TestDispatcherProvider.kt
index 39e1ec5..3319c53 100644
--- a/tests/multivalentTests/src/com/android/launcher3/util/TestDispatcherProvider.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/util/TestDispatcherProvider.kt
@@ -21,7 +21,7 @@
class TestDispatcherProvider(testDispatcher: CoroutineDispatcher) : DispatcherProvider {
override val default: CoroutineDispatcher = testDispatcher
- override val io: CoroutineDispatcher = testDispatcher
+ override val background: CoroutineDispatcher = testDispatcher
override val main: CoroutineDispatcher = testDispatcher
override val unconfined: CoroutineDispatcher = testDispatcher
}
diff --git a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
index bb645d7..64ad305 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddConfigWidgetTest.java
@@ -123,7 +123,7 @@
v instanceof WidgetCell
&& v.getTag() instanceof PendingAddWidgetInfo pawi
&& mWidgetInfo.provider.equals(pawi.componentName)));
- addToWorkspace(widgetView);
+ addWidgetToWorkspace(widgetView);
// Widget id for which the config activity was opened
mWidgetId = monitor.getWidgetId();
diff --git a/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt b/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt
index 61fa7d5..b5702c9 100644
--- a/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt
+++ b/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt
@@ -170,6 +170,18 @@
UiDevice.getInstance(getInstrumentation()).waitForIdle()
}
+ /**
+ * Match the behavior with how widget is added in reality with "tap to add" (even with screen
+ * readers).
+ */
+ fun addWidgetToWorkspace(view: View) {
+ executeOnLauncher {
+ view.performClick()
+ UiDevice.getInstance(getInstrumentation()).waitForIdle()
+ view.findViewById<View>(R.id.widget_add_button).performClick()
+ }
+ }
+
fun ViewGroup.searchView(filter: Predicate<View>): View? {
if (filter.test(this)) return this
for (child in children) {