From 450fb42e0ff67ed9c896773edc9ed6e3fde24c58 Mon Sep 17 00:00:00 2001 From: Matthew Mourgos Date: Fri, 8 Nov 2024 18:26:11 -0800 Subject: [PATCH 01/15] Close any open widget resize frames when changing pages. When a widget is added while talkback is enabled, the widget resize frame does not automatically close when subsequently changing workspace pages. This is because touch events which usually would cause the widget resize frame to close, get intercepted by talkback before they get to the resize frame. Bug: 374044529 Test: manual - activate talkback, add new widget, and change page Flag: EXEMPT bug fix Change-Id: I2b8db22fa237a188c6705e9c6e57b12c1a7cd2f6 --- src/com/android/launcher3/Workspace.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 0e9c8610e6..95dbf5f4ba 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -16,6 +16,7 @@ package com.android.launcher3; +import static com.android.launcher3.AbstractFloatingView.TYPE_WIDGET_RESIZE_FRAME; import static com.android.launcher3.BubbleTextView.DISPLAY_FOLDER; import static com.android.launcher3.Flags.enableSmartspaceRemovalToggle; import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY; @@ -1222,6 +1223,10 @@ public class Workspace extends PagedView } protected void onPageBeginTransition() { + // Widget resize frame doesn't receive events to close when talkback is enabled. For that + // case, close it here. + AbstractFloatingView.closeOpenViews(mLauncher, false, TYPE_WIDGET_RESIZE_FRAME); + super.onPageBeginTransition(); updateChildrenLayersEnabled(); } From 1c7122ff9ac6c4dfeadeeb05c1f458ef0575f126 Mon Sep 17 00:00:00 2001 From: Brandon Dayauon Date: Tue, 12 Nov 2024 11:30:01 -0800 Subject: [PATCH 02/15] Update height of predictionRow + 4dp to be aligned with NL app suggestions height. spec: https://screenshot.googleplex.com/9VsQXxmsuZvoj7Y Add 4dp to the existing height when using two lines. Need to do this for prediction row as well so that animation is smooth and doesn't show jumpiness. bug: 378472318 Test: photos: before: https://screenshot.googleplex.com/7F8FNdnrngpuSUe after: https://screenshot.googleplex.com/63vttsfptSqwE7c Flag: NONE increasing height Change-Id: I2076160efe3596cc8673d32b5066ec2103f71eb0 --- .../android/launcher3/appprediction/PredictionRowView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java index 92d9516836..8e80aa57a5 100644 --- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java +++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java @@ -57,7 +57,7 @@ public class PredictionRowView // Vertical padding of the icon that contributes to the expected cell height. private final int mVerticalPadding; // Extra padding that is used in the top app rows (prediction and search) that is not used in - // the regular A-Z list. This only applies to single line label. + // the regular A-Z list. private final int mTopRowExtraHeight; // Helper to drawing the focus indicator. @@ -140,7 +140,7 @@ public class PredictionRowView // is not enabled. Otherwise, the extra height will increase by just the textHeight. int extraHeight = (Flags.enableTwolineToggle() && LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE.get(getContext())) - ? textHeight : mTopRowExtraHeight; + ? (textHeight + mTopRowExtraHeight) : mTopRowExtraHeight; totalHeight += extraHeight; return getVisibility() == GONE ? 0 : totalHeight + getPaddingTop() + getPaddingBottom(); } From 0b01bf4117ac15f971b2a2ee13a8bb7f1b891387 Mon Sep 17 00:00:00 2001 From: Will Leshner Date: Tue, 12 Nov 2024 12:24:05 -0800 Subject: [PATCH 03/15] Fix permission issue with START_WIDGET_PICKER_ACTIVITY The permission for starting the widget picker activity didn't match its declaration, making it orphaned. Any other package/app could then spoof the permission and start the activity. Bug: 365082993 Test: Manually by creating an app that attempts to spoof the permission and testing that it was not able to show the activity. Flag: EXEMPT bugfix Change-Id: I1af4bc68329a30eb8d6a92c944f6c84b4992107a --- quickstep/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml index 57bfb4acba..8c39585bfe 100644 --- a/quickstep/AndroidManifest.xml +++ b/quickstep/AndroidManifest.xml @@ -152,7 +152,7 @@ android:showOnLockScreen="true" android:launchMode="singleTop" android:exported="true" - android:permission="android.permission.START_WIDGET_PICKER_ACTIVITY"> + android:permission="${applicationId}.permission.START_WIDGET_PICKER_ACTIVITY"> From 6863d6244b48293fea108c2e2608b36dee6e4993 Mon Sep 17 00:00:00 2001 From: Wen-Chien Wang Date: Tue, 12 Nov 2024 23:26:25 +0000 Subject: [PATCH 04/15] Add a flag for the context menu to pin/unpin apps on taskbar. Bug: 375648361 Flag: EXEMPT adding flag Test: EXEMPT adding flag Change-Id: I3a63a89b8e19cffe666f93fa98638d3d59d1ef1b --- aconfig/launcher.aconfig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig index 878aa6e5e9..1856b39372 100644 --- a/aconfig/launcher.aconfig +++ b/aconfig/launcher.aconfig @@ -526,4 +526,11 @@ flag { namespace: "launcher" description: "Enable Taskbar LayoutTransition for Recent Apps" bug: "343521765" +} + +flag { + name: "enable_pinning_app_with_context_menu" + namespace: "launcher" + description: "Add options to pin/unpin to taskbar to app context menus." + bug: "375648361" } \ No newline at end of file From dde53a10e3b5949124885d96e3c157acb2d76eb6 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 2 Oct 2024 22:43:04 +0000 Subject: [PATCH 05/15] 4b/ Migrate TopTaskTracker to use visible running tasks from Shell - When enable_shell_top_task_tracking is enabled, use the shell provided signals to keep an up-to-date running (visible) task list on the Launcher side, instead of managing the list via to-front signals from Core via TaskStackListener. In doing so, we also update CachedTaskInfo to use this visible task list in preparation for future refactoring to use the GroupedTaskInfos directly instead. Bug: 346588978 Flag: EXEMPT adding new flag enable_shell_top_task_tracking Test: Build SystemUI & Launcher Test: atest WMShellUnitTests Change-Id: I16d515243760a17258a727e2502e35387da87589 --- .../android/quickstep/AbsSwipeUpHandler.java | 2 +- .../com/android/quickstep/GestureState.java | 24 +- .../android/quickstep/RecentTasksList.java | 14 +- .../RecentsAnimationDeviceState.java | 6 +- .../com/android/quickstep/TopTaskTracker.java | 379 ++++++++++++++---- .../quickstep/TouchInteractionService.java | 21 +- .../quickstep/util/AppPairsController.java | 23 +- .../android/quickstep/views/RecentsView.java | 9 +- .../quickstep/util/AppPairsControllerTest.kt | 36 +- 9 files changed, 392 insertions(+), 122 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 97d71799fd..31aa489bd6 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -667,7 +667,7 @@ public abstract class AbsSwipeUpHandler< TopTaskTracker.CachedTaskInfo cachedTaskInfo = mGestureState.getRunningTask(); if (mIsSwipeForSplit) { int[] splitTaskIds = TopTaskTracker.INSTANCE.get(mContext).getRunningSplitTaskIds(); - runningTasks = cachedTaskInfo.getPlaceholderTasks(splitTaskIds); + runningTasks = cachedTaskInfo.getSplitPlaceholderTasks(splitTaskIds); } else { runningTasks = cachedTaskInfo.getPlaceholderTasks(); } diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index cff352cf16..5190ec8b7a 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -28,6 +28,7 @@ import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET_HOME; import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET_NEW_TASK; +import android.app.TaskInfo; import android.content.Intent; import android.os.SystemClock; import android.view.MotionEvent; @@ -45,6 +46,7 @@ import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.ActiveGestureProtoLogProxy; import com.android.quickstep.views.RecentsViewContainer; import com.android.systemui.shared.recents.model.ThumbnailData; +import com.android.wm.shell.shared.GroupedTaskInfo; import java.io.PrintWriter; import java.util.ArrayList; @@ -330,13 +332,23 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL if (mRunningTask == null) { return new int[]{INVALID_TASK_ID, INVALID_TASK_ID}; } else { - int cachedTasksSize = mRunningTask.mAllCachedTasks.size(); - int count = Math.min(cachedTasksSize, getMultipleTasks ? 2 : 1); - int[] runningTaskIds = new int[count]; - for (int i = 0; i < count; i++) { - runningTaskIds[i] = mRunningTask.mAllCachedTasks.get(i).taskId; + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + if (mRunningTask.getVisibleTasks().isEmpty()) { + return new int[0]; + } + GroupedTaskInfo topRunningTask = mRunningTask.getVisibleTasks().getFirst(); + List groupedTasks = topRunningTask.getTaskInfoList(); + return groupedTasks.stream().mapToInt( + groupedTask -> groupedTask.taskId).toArray(); + } else { + int cachedTasksSize = mRunningTask.mAllCachedTasks.size(); + int count = Math.min(cachedTasksSize, getMultipleTasks ? 2 : 1); + int[] runningTaskIds = new int[count]; + for (int i = 0; i < count; i++) { + runningTaskIds[i] = mRunningTask.mAllCachedTasks.get(i).taskId; + } + return runningTaskIds; } - return runningTaskIds; } } diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index 714838a468..85e2b6ebf0 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -114,12 +114,9 @@ public class RecentTasksList { } @Override - public void onTaskMovedToFront(GroupedTaskInfo[] visibleTasks) { + public void onTaskMovedToFront(GroupedTaskInfo taskToFront) { mMainThreadExecutor.execute(() -> { - // TODO(b/346588978): We currently are only sending a single task, but this will - // be updated once we send the full set of visible tasks - final TaskInfo info = visibleTasks[0].getTaskInfo1(); - topTaskTracker.handleTaskMovedToFront(info); + topTaskTracker.handleTaskMovedToFront(taskToFront.getTaskInfo1()); }); } @@ -127,6 +124,13 @@ public class RecentTasksList { public void onTaskInfoChanged(RunningTaskInfo taskInfo) { mMainThreadExecutor.execute(() -> topTaskTracker.onTaskChanged(taskInfo)); } + + @Override + public void onVisibleTasksChanged(GroupedTaskInfo[] visibleTasks) { + mMainThreadExecutor.execute(() -> { + topTaskTracker.onVisibleTasksChanged(visibleTasks); + }); + } }); // We may receive onRunningTaskAppeared events later for tasks which have already been // included in the list returned by mSysUiProxy.getRunningTasks(), or may receive diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java index de8be50541..e2964490f9 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java @@ -354,7 +354,11 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener, E * @return whether the given running task info matches the gesture-blocked task. */ public boolean isGestureBlockedTask(CachedTaskInfo taskInfo) { - return taskInfo != null && taskInfo.getTaskId() == mGestureBlockingTaskId; + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return taskInfo != null && taskInfo.topGroupedTaskContainsTask(mGestureBlockingTaskId); + } else { + return taskInfo != null && taskInfo.getTaskId() == mGestureBlockingTaskId; + } } /** diff --git a/quickstep/src/com/android/quickstep/TopTaskTracker.java b/quickstep/src/com/android/quickstep/TopTaskTracker.java index c9dfe6d19d..80d6137344 100644 --- a/quickstep/src/com/android/quickstep/TopTaskTracker.java +++ b/quickstep/src/com/android/quickstep/TopTaskTracker.java @@ -18,17 +18,18 @@ package com.android.quickstep; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; -import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.content.Intent.ACTION_CHOOSER; import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; import static android.view.Display.DEFAULT_DISPLAY; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT; +import static com.android.wm.shell.shared.GroupedTaskInfo.TYPE_SPLIT; -import android.annotation.UserIdInt; import android.app.ActivityManager.RunningTaskInfo; import android.app.TaskInfo; import android.content.Context; +import android.util.ArrayMap; +import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -46,8 +47,10 @@ import com.android.systemui.shared.recents.model.Task.TaskKey; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; +import com.android.wm.shell.shared.GroupedTaskInfo; import com.android.wm.shell.splitscreen.ISplitScreenListener; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -61,37 +64,58 @@ import java.util.List; */ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskStackChangeListener, SafeCloseable { - + private static final String TAG = "TopTaskTracker"; public static MainThreadInitializedObject INSTANCE = new MainThreadInitializedObject<>(TopTaskTracker::new); private static final int HISTORY_SIZE = 5; + private final Context mContext; + + // Only used when Flags.enableShellTopTaskTracking() is disabled // Ordered list with first item being the most recent task. private final LinkedList mOrderedTaskList = new LinkedList<>(); - - private final Context mContext; private final SplitStageInfo mMainStagePosition = new SplitStageInfo(); private final SplitStageInfo mSideStagePosition = new SplitStageInfo(); private int mPinnedTaskId = INVALID_TASK_ID; + // Only used when Flags.enableShellTopTaskTracking() is enabled + // Mapping of display id to running tasks. Running tasks are ordered from top most to + // bottom most. + private ArrayMap> mVisibleTasks = new ArrayMap<>(); + private TopTaskTracker(Context context) { mContext = context; - mMainStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_MAIN; - mSideStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_SIDE; - TaskStackChangeListeners.getInstance().registerTaskStackListener(this); - SystemUiProxy.INSTANCE.get(context).registerSplitScreenListener(this); + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // Just prepopulate a list for the default display tasks so we don't need to add null + // checks everywhere + mVisibleTasks.put(DEFAULT_DISPLAY, new ArrayList<>()); + } else { + mMainStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_MAIN; + mSideStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_SIDE; + + TaskStackChangeListeners.getInstance().registerTaskStackListener(this); + SystemUiProxy.INSTANCE.get(context).registerSplitScreenListener(this); + } } @Override public void close() { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + TaskStackChangeListeners.getInstance().unregisterTaskStackListener(this); SystemUiProxy.INSTANCE.get(mContext).unregisterSplitScreenListener(this); } @Override public void onTaskRemoved(int taskId) { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + mOrderedTaskList.removeIf(rto -> rto.taskId == taskId); } @@ -100,7 +124,11 @@ public class TopTaskTracker extends ISplitScreenListener.Stub handleTaskMovedToFront(taskInfo); } - public void handleTaskMovedToFront(TaskInfo taskInfo) { + void handleTaskMovedToFront(TaskInfo taskInfo) { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + mOrderedTaskList.removeIf(rto -> rto.taskId == taskInfo.taskId); mOrderedTaskList.addFirst(taskInfo); @@ -131,8 +159,39 @@ public class TopTaskTracker extends ISplitScreenListener.Stub } } + /** + * Called when the set of visible tasks have changed. + */ + public void onVisibleTasksChanged(GroupedTaskInfo[] visibleTasks) { + if (!com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + + // TODO(346588978): Per-display info, just have everything in order by display + + // Clear existing tasks for each display + mVisibleTasks.forEach((displayId, visibleTasksOnDisplay) -> visibleTasksOnDisplay.clear()); + + // Update the visible tasks on each display + for (int i = 0; i < visibleTasks.length; i++) { + final int displayId = visibleTasks[i].getTaskInfo1().getDisplayId(); + final ArrayList displayTasks; + if (mVisibleTasks.containsKey(displayId)) { + displayTasks = mVisibleTasks.get(displayId); + } else { + displayTasks = new ArrayList<>(); + mVisibleTasks.put(displayId, displayTasks); + } + displayTasks.add(visibleTasks[i]); + } + } + @Override public void onStagePositionChanged(@StageType int stage, @StagePosition int position) { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + if (stage == SplitConfigurationOptions.STAGE_TYPE_MAIN) { mMainStagePosition.stagePosition = position; } else { @@ -141,6 +200,10 @@ public class TopTaskTracker extends ISplitScreenListener.Stub } public void onTaskChanged(RunningTaskInfo taskInfo) { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + for (int i = 0; i < mOrderedTaskList.size(); i++) { if (mOrderedTaskList.get(i).taskId == taskInfo.taskId) { mOrderedTaskList.set(i, taskInfo); @@ -151,6 +214,10 @@ public class TopTaskTracker extends ISplitScreenListener.Stub @Override public void onTaskStageChanged(int taskId, @StageType int stage, boolean visible) { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + // If a task is not visible anymore or has been moved to undefined, stop tracking it. if (!visible || stage == SplitConfigurationOptions.STAGE_TYPE_UNDEFINED) { if (mMainStagePosition.taskId == taskId) { @@ -170,11 +237,19 @@ public class TopTaskTracker extends ISplitScreenListener.Stub @Override public void onActivityPinned(String packageName, int userId, int taskId, int stackId) { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + mPinnedTaskId = taskId; } @Override public void onActivityUnpinned() { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + mPinnedTaskId = INVALID_TASK_ID; } @@ -183,21 +258,59 @@ public class TopTaskTracker extends ISplitScreenListener.Stub * Will return empty array if device is not in staged split */ public int[] getRunningSplitTaskIds() { - if (mMainStagePosition.taskId == INVALID_TASK_ID - || mSideStagePosition.taskId == INVALID_TASK_ID) { - return new int[]{}; - } - int[] out = new int[2]; - if (mMainStagePosition.stagePosition == STAGE_POSITION_TOP_OR_LEFT) { - out[0] = mMainStagePosition.taskId; - out[1] = mSideStagePosition.taskId; + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // TODO(346588978): This assumes default display for now + final ArrayList visibleTasks = mVisibleTasks.get(DEFAULT_DISPLAY); + final GroupedTaskInfo splitTaskInfo = visibleTasks.stream() + .filter(taskInfo -> taskInfo.getType() == TYPE_SPLIT) + .findFirst().orElse(null); + if (splitTaskInfo != null && splitTaskInfo.getSplitBounds() != null) { + return new int[] { + splitTaskInfo.getSplitBounds().leftTopTaskId, + splitTaskInfo.getSplitBounds().rightBottomTaskId + }; + } + return new int[0]; } else { - out[1] = mMainStagePosition.taskId; - out[0] = mSideStagePosition.taskId; + if (mMainStagePosition.taskId == INVALID_TASK_ID + || mSideStagePosition.taskId == INVALID_TASK_ID) { + return new int[]{}; + } + int[] out = new int[2]; + if (mMainStagePosition.stagePosition == STAGE_POSITION_TOP_OR_LEFT) { + out[0] = mMainStagePosition.taskId; + out[1] = mSideStagePosition.taskId; + } else { + out[1] = mMainStagePosition.taskId; + out[0] = mSideStagePosition.taskId; + } + return out; } - return out; } + /** + * Dumps the list of tasks in top task tracker. + */ + public void dump(PrintWriter pw) { + if (!com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return; + } + + // TODO(346588978): This assumes default display for now + final ArrayList displayTasks = mVisibleTasks.get(DEFAULT_DISPLAY); + pw.println("TopTaskTracker:"); + pw.println(" tasks: ["); + for (GroupedTaskInfo taskInfo : displayTasks) { + final TaskInfo info = taskInfo.getTaskInfo1(); + final boolean isExcluded = (info.baseIntent.getFlags() + & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0; + pw.println(" " + info.taskId + ": excluded=" + isExcluded + + " visibleRequested=" + info.isVisibleRequested + + " visible=" + info.isVisible + + " " + info.baseIntent.getComponent()); + } + pw.println(" ]"); + } /** * Returns the CachedTaskInfo for the top most task @@ -205,25 +318,35 @@ public class TopTaskTracker extends ISplitScreenListener.Stub @NonNull @UiThread public CachedTaskInfo getCachedTopTask(boolean filterOnlyVisibleRecents) { - if (filterOnlyVisibleRecents) { - // Since we only know about the top most task, any filtering may not be applied on the - // cache. The second to top task may change while the top task is still the same. - RunningTaskInfo[] tasks = TraceHelper.allowIpcs("getCachedTopTask.true", () -> - ActivityManagerWrapper.getInstance().getRunningTasks(true)); - return new CachedTaskInfo(Arrays.asList(tasks)); - } + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // TODO(346588978): Currently ignore filterOnlyVisibleRecents, but perhaps make this an + // explicit filter For things to ignore (ie. PIP/Bubbles/Assistant/etc/so that this is + // explicit) + // TODO(346588978): This assumes default display for now (as does all of Launcher) + final ArrayList displayTasks = mVisibleTasks.get(DEFAULT_DISPLAY); + return new CachedTaskInfo(new ArrayList<>(displayTasks)); + } else { + if (filterOnlyVisibleRecents) { + // Since we only know about the top most task, any filtering may not be applied on + // the cache. The second to top task may change while the top task is still the + // same. + RunningTaskInfo[] tasks = TraceHelper.allowIpcs("getCachedTopTask.true", () -> + ActivityManagerWrapper.getInstance().getRunningTasks(true)); + return new CachedTaskInfo(Arrays.asList(tasks)); + } - if (mOrderedTaskList.isEmpty()) { - RunningTaskInfo[] tasks = TraceHelper.allowIpcs("getCachedTopTask.false", () -> - ActivityManagerWrapper.getInstance().getRunningTasks( - false /* filterOnlyVisibleRecents */)); - Collections.addAll(mOrderedTaskList, tasks); - } + if (mOrderedTaskList.isEmpty()) { + RunningTaskInfo[] tasks = TraceHelper.allowIpcs("getCachedTopTask.false", () -> + ActivityManagerWrapper.getInstance().getRunningTasks( + false /* filterOnlyVisibleRecents */)); + Collections.addAll(mOrderedTaskList, tasks); + } - ArrayList tasks = new ArrayList<>(mOrderedTaskList); - // Strip the pinned task and recents task - tasks.removeIf(t -> t.taskId == mPinnedTaskId || isRecentsTask(t)); - return new CachedTaskInfo(tasks); + ArrayList tasks = new ArrayList<>(mOrderedTaskList); + // Strip the pinned task and recents task + tasks.removeIf(t -> t.taskId == mPinnedTaskId || isRecentsTask(t)); + return new CachedTaskInfo(tasks); + } } private static boolean isRecentsTask(TaskInfo task) { @@ -237,24 +360,79 @@ public class TopTaskTracker extends ISplitScreenListener.Stub */ public static class CachedTaskInfo { + // Only used when enableShellTopTaskTracking() is disabled @Nullable private final TaskInfo mTopTask; + @Nullable public final List mAllCachedTasks; - CachedTaskInfo(List allCachedTasks) { + // Only used when enableShellTopTaskTracking() is enabled + @Nullable + private final GroupedTaskInfo mTopGroupedTask; + @Nullable + private final ArrayList mVisibleTasks; + + + // Only used when enableShellTopTaskTracking() is enabled + CachedTaskInfo(@NonNull ArrayList visibleTasks) { + mAllCachedTasks = null; + mTopTask = null; + mVisibleTasks = visibleTasks; + mTopGroupedTask = !mVisibleTasks.isEmpty() ? mVisibleTasks.getFirst() : null; + + } + + // Only used when enableShellTopTaskTracking() is disabled + CachedTaskInfo(@NonNull List allCachedTasks) { + mVisibleTasks = null; + mTopGroupedTask = null; mAllCachedTasks = allCachedTasks; mTopTask = allCachedTasks.isEmpty() ? null : allCachedTasks.get(0); } + /** + * @return The list of visible tasks + */ + public ArrayList getVisibleTasks() { + return mVisibleTasks; + } + + /** + * @return The top task id + */ public int getTaskId() { - return mTopTask == null ? INVALID_TASK_ID : mTopTask.taskId; + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // Callers should use topGroupedTaskContainsTask() instead + return INVALID_TASK_ID; + } else { + return mTopTask != null ? mTopTask.taskId : INVALID_TASK_ID; + } + } + + /** + * @return Whether the top grouped task contains the given {@param taskId} if + * Flags.enableShellTopTaskTracking() is true, otherwise it checks the top + * task as reported from TaskStackListener. + */ + public boolean topGroupedTaskContainsTask(int taskId) { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + return mTopGroupedTask != null && mTopGroupedTask.containsTask(taskId); + } else { + return mTopTask != null && mTopTask.taskId == taskId; + } } /** * Returns true if the root of the task chooser activity */ public boolean isRootChooseActivity() { - return mTopTask != null && ACTION_CHOOSER.equals(mTopTask.baseIntent.getAction()); + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // TODO(346588978): Update this to not make an assumption on a specific task info + return mTopGroupedTask != null && ACTION_CHOOSER.equals( + mTopGroupedTask.getTaskInfo1().baseIntent.getAction()); + } else { + return mTopTask != null && ACTION_CHOOSER.equals(mTopTask.baseIntent.getAction()); + } } /** @@ -262,6 +440,10 @@ public class TopTaskTracker extends ISplitScreenListener.Stub * is another running task that is not excluded from recents, returns that underlying task. */ public @Nullable CachedTaskInfo getVisibleNonExcludedTask() { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // Callers should not need this when the full set of visible tasks are provided + return null; + } if (mTopTask == null || (mTopTask.baseIntent.getFlags() & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0) { // Not an excluded task. @@ -278,24 +460,30 @@ public class TopTaskTracker extends ISplitScreenListener.Stub } /** - * Returns true if this represents the HOME task + * Returns true if this represents the HOME activity type task */ public boolean isHomeTask() { - return mTopTask != null && mTopTask.configuration.windowConfiguration - .getActivityType() == ACTIVITY_TYPE_HOME; - } - - public boolean isRecentsTask() { - return TopTaskTracker.isRecentsTask(mTopTask); + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // TODO(346588978): Update this to not make an assumption on a specific task info + return mTopGroupedTask != null + && mTopGroupedTask.getTaskInfo1().getActivityType() == ACTIVITY_TYPE_HOME; + } else { + return mTopTask != null && mTopTask.configuration.windowConfiguration + .getActivityType() == ACTIVITY_TYPE_HOME; + } } /** - * Returns {@code true} if this task windowing mode is set to {@link - * android.app.WindowConfiguration#WINDOWING_MODE_FREEFORM} + * Returns true if this represents the RECENTS activity type task */ - public boolean isFreeformTask() { - return mTopTask != null && mTopTask.configuration.windowConfiguration.getWindowingMode() - == WINDOWING_MODE_FREEFORM; + public boolean isRecentsTask() { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // TODO(346588978): Update this to not make an assumption on a specific task info + return mTopGroupedTask != null + && TopTaskTracker.isRecentsTask(mTopGroupedTask.getTaskInfo1()); + } else { + return TopTaskTracker.isRecentsTask(mTopTask); + } } /** @@ -303,43 +491,78 @@ public class TopTaskTracker extends ISplitScreenListener.Stub * is loaded by the model */ public Task[] getPlaceholderTasks() { - return mTopTask == null ? new Task[0] - : new Task[]{Task.from(new TaskKey(mTopTask), mTopTask, false)}; + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // TODO(346588978): Update this to return more than a single task once the callers + // are refactored + if (mVisibleTasks.isEmpty()) { + return new Task[0]; + } + final TaskInfo info = mVisibleTasks.getFirst().getTaskInfo1(); + return new Task[]{Task.from(new TaskKey(info), info, false)}; + } else { + return mTopTask == null ? new Task[0] + : new Task[]{Task.from(new TaskKey(mTopTask), mTopTask, false)}; + } } /** * Returns {@link Task} array corresponding to the provided task ids which can be used as a * placeholder until the true object is loaded by the model */ - public Task[] getPlaceholderTasks(int[] taskIds) { - if (mTopTask == null) { - return new Task[0]; - } - Task[] result = new Task[taskIds.length]; - for (int i = 0; i < taskIds.length; i++) { - final int index = i; - int taskId = taskIds[i]; - mAllCachedTasks.forEach(rti -> { - if (rti.taskId == taskId) { - result[index] = Task.from(new TaskKey(rti), rti, false); - } - }); - } - return result; - } + public Task[] getSplitPlaceholderTasks(int[] taskIds) { + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + if (mVisibleTasks.isEmpty() + || mVisibleTasks.getFirst().getType() != TYPE_SPLIT) { + return new Task[0]; + } - @UserIdInt - @Nullable - public Integer getUserId() { - return mTopTask == null ? null : mTopTask.userId; + GroupedTaskInfo splitTask = mVisibleTasks.getFirst(); + Task[] result = new Task[taskIds.length]; + for (int i = 0; i < taskIds.length; i++) { + TaskInfo info = splitTask.getTaskById(taskIds[i]); + if (info == null) { + Log.w(TAG, "Requested task (" + taskIds[i] + ") not found"); + return new Task[0]; + } + result[i] = Task.from(new TaskKey(info), info, false); + } + return result; + } else { + if (mTopTask == null) { + return new Task[0]; + } + Task[] result = new Task[taskIds.length]; + for (int i = 0; i < taskIds.length; i++) { + final int index = i; + int taskId = taskIds[i]; + mAllCachedTasks.forEach(rti -> { + if (rti.taskId == taskId) { + result[index] = Task.from(new TaskKey(rti), rti, false); + } + }); + } + return result; + } } @Nullable public String getPackageName() { - if (mTopTask == null || mTopTask.baseActivity == null) { - return null; + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // TODO(346588978): Update this to not make an assumption on a specific task info + if (mTopGroupedTask == null) { + return null; + } + final TaskInfo info = mTopGroupedTask.getTaskInfo1(); + if (info.baseActivity == null) { + return null; + } + return info.baseActivity.getPackageName(); + } else { + if (mTopTask == null || mTopTask.baseActivity == null) { + return null; + } + return mTopTask.baseActivity.getPackageName(); } - return mTopTask.baseActivity.getPackageName(); } } } diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index fcc512119f..0004005739 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -1353,15 +1353,17 @@ public class TouchInteractionService extends Service { && runningTask != null && runningTask.isRootChooseActivity(); - // In the case where we are in an excluded, translucent overlay, ignore it and treat the - // running activity as the task behind the overlay. - TopTaskTracker.CachedTaskInfo otherVisibleTask = runningTask == null - ? null - : runningTask.getVisibleNonExcludedTask(); - if (otherVisibleTask != null) { - ActiveGestureProtoLogProxy.logUpdateGestureStateRunningTask( - otherVisibleTask.getPackageName(), runningTask.getPackageName()); - gestureState.updateRunningTask(otherVisibleTask); + if (!com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + // In the case where we are in an excluded, translucent overlay, ignore it and treat the + // running activity as the task behind the overlay. + TopTaskTracker.CachedTaskInfo otherVisibleTask = runningTask == null + ? null + : runningTask.getVisibleNonExcludedTask(); + if (otherVisibleTask != null) { + ActiveGestureProtoLogProxy.logUpdateGestureStateRunningTask( + otherVisibleTask.getPackageName(), runningTask.getPackageName()); + gestureState.updateRunningTask(otherVisibleTask); + } } boolean previousGestureAnimatedToLauncher = @@ -1663,6 +1665,7 @@ public class TouchInteractionService extends Service { ContextualSearchStateManager.INSTANCE.get(this).dump("\t", pw); SystemUiProxy.INSTANCE.get(this).dump(pw); DeviceConfigWrapper.get().dump(" ", pw); + TopTaskTracker.INSTANCE.get(this).dump(pw); } private AbsSwipeUpHandler createLauncherSwipeHandler( diff --git a/quickstep/src/com/android/quickstep/util/AppPairsController.java b/quickstep/src/com/android/quickstep/util/AppPairsController.java index 7388d59995..1312aa4479 100644 --- a/quickstep/src/com/android/quickstep/util/AppPairsController.java +++ b/quickstep/src/com/android/quickstep/util/AppPairsController.java @@ -409,8 +409,8 @@ public class AppPairsController { ); } else { // Tapped an app pair while in a single app - int runningTaskId = topTaskTracker - .getCachedTopTask(false /* filterOnlyVisibleRecents */).getTaskId(); + final TopTaskTracker.CachedTaskInfo runningTask = topTaskTracker + .getCachedTopTask(false /* filterOnlyVisibleRecents */); mSplitSelectStateController.findLastActiveTasksAndRunCallback( componentKeys, @@ -418,10 +418,21 @@ public class AppPairsController { foundTasks -> { Task foundTask1 = foundTasks[0]; Task foundTask2 = foundTasks[1]; - boolean task1IsOnScreen = - foundTask1 != null && foundTask1.getKey().getId() == runningTaskId; - boolean task2IsOnScreen = - foundTask2 != null && foundTask2.getKey().getId() == runningTaskId; + boolean task1IsOnScreen; + boolean task2IsOnScreen; + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + task1IsOnScreen = foundTask1 != null + && runningTask.topGroupedTaskContainsTask( + foundTask1.getKey().getId()); + task2IsOnScreen = foundTask2 != null + && runningTask.topGroupedTaskContainsTask( + foundTask2.getKey().getId()); + } else { + task1IsOnScreen = foundTask1 != null && foundTask1.getKey().getId() + == runningTask.getTaskId(); + task2IsOnScreen = foundTask2 != null && foundTask2.getKey().getId() + == runningTask.getTaskId(); + } if (!task1IsOnScreen && !task2IsOnScreen) { // Neither App A nor App B are on-screen, launch the app pair normally. diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 9a8041becc..5f528d411b 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1966,7 +1966,7 @@ public abstract class RecentsView< // We try to avoid this because it can cause a scroll jump, but it is needed // for cases where the running task isn't included in this load plan (e.g. if // the current running task is excludedFromRecents.) - showCurrentTask(mActiveGestureRunningTasks); + showCurrentTask(mActiveGestureRunningTasks, "applyLoadPlan"); } else { setRunningTaskViewId(INVALID_TASK_ID); } @@ -2749,7 +2749,7 @@ public abstract class RecentsView< updateSizeAndPadding(); } - showCurrentTask(mActiveGestureRunningTasks); + showCurrentTask(mActiveGestureRunningTasks, "onGestureAnimationStart"); setEnableFreeScroll(false); setEnableDrawingLiveTile(false); setRunningTaskHidden(true); @@ -2930,8 +2930,9 @@ public abstract class RecentsView< * All subsequent calls to reload will keep the task as the first item until {@link #reset()} * is called. Also scrolls the view to this task. */ - private void showCurrentTask(Task[] runningTasks) { - Log.d(TAG, "showCurrentTask - runningTasks: " + Arrays.toString(runningTasks)); + private void showCurrentTask(Task[] runningTasks, String caller) { + Log.d(TAG, "showCurrentTask(" + caller + ") - runningTasks: " + + Arrays.toString(runningTasks)); if (runningTasks.length == 0) { return; } diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/AppPairsControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/AppPairsControllerTest.kt index 541a48d141..ee70e0a9d3 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/AppPairsControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/AppPairsControllerTest.kt @@ -202,7 +202,7 @@ class AppPairsControllerTest { // Trigger app pair launch, capture and run callback from findLastActiveTasksAndRunCallback spyAppPairsController.handleAppPairLaunchInApp( mockAppPairIcon, - listOf(mockItemInfo1, mockItemInfo2) + listOf(mockItemInfo1, mockItemInfo2), ) verify(splitSelectStateController) .findLastActiveTasksAndRunCallback(any(), any(), callbackCaptor.capture()) @@ -226,7 +226,7 @@ class AppPairsControllerTest { // Trigger app pair launch, capture and run callback from findLastActiveTasksAndRunCallback spyAppPairsController.handleAppPairLaunchInApp( mockAppPairIcon, - listOf(mockItemInfo1, mockItemInfo2) + listOf(mockItemInfo1, mockItemInfo2), ) verify(splitSelectStateController) .findLastActiveTasksAndRunCallback(any(), any(), callbackCaptor.capture()) @@ -250,7 +250,7 @@ class AppPairsControllerTest { // Trigger app pair launch, capture and run callback from findLastActiveTasksAndRunCallback spyAppPairsController.handleAppPairLaunchInApp( mockAppPairIcon, - listOf(mockItemInfo1, mockItemInfo2) + listOf(mockItemInfo1, mockItemInfo2), ) verify(splitSelectStateController) .findLastActiveTasksAndRunCallback(any(), any(), callbackCaptor.capture()) @@ -274,7 +274,7 @@ class AppPairsControllerTest { // Trigger app pair launch, capture and run callback from findLastActiveTasksAndRunCallback spyAppPairsController.handleAppPairLaunchInApp( mockAppPairIcon, - listOf(mockItemInfo1, mockItemInfo2) + listOf(mockItemInfo1, mockItemInfo2), ) verify(splitSelectStateController) .findLastActiveTasksAndRunCallback(any(), any(), callbackCaptor.capture()) @@ -298,7 +298,7 @@ class AppPairsControllerTest { // Trigger app pair launch, capture and run callback from findLastActiveTasksAndRunCallback spyAppPairsController.handleAppPairLaunchInApp( mockAppPairIcon, - listOf(mockItemInfo1, mockItemInfo2) + listOf(mockItemInfo1, mockItemInfo2), ) verify(splitSelectStateController) .findLastActiveTasksAndRunCallback(any(), any(), callbackCaptor.capture()) @@ -322,7 +322,7 @@ class AppPairsControllerTest { // Trigger app pair launch, capture and run callback from findLastActiveTasksAndRunCallback spyAppPairsController.handleAppPairLaunchInApp( mockAppPairIcon, - listOf(mockItemInfo1, mockItemInfo2) + listOf(mockItemInfo1, mockItemInfo2), ) verify(splitSelectStateController) .findLastActiveTasksAndRunCallback(any(), any(), callbackCaptor.capture()) @@ -341,12 +341,16 @@ class AppPairsControllerTest { whenever(mockTaskKey1.getId()).thenReturn(1) whenever(mockTaskKey2.getId()).thenReturn(2) // ... with app 1 already on screen - whenever(mockCachedTaskInfo.taskId).thenReturn(1) + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + whenever(mockCachedTaskInfo.topGroupedTaskContainsTask(eq(1))).thenReturn(true) + } else { + whenever(mockCachedTaskInfo.taskId).thenReturn(1) + } // Trigger app pair launch, capture and run callback from findLastActiveTasksAndRunCallback spyAppPairsController.handleAppPairLaunchInApp( mockAppPairIcon, - listOf(mockItemInfo1, mockItemInfo2) + listOf(mockItemInfo1, mockItemInfo2), ) verify(splitSelectStateController) .findLastActiveTasksAndRunCallback(any(), any(), callbackCaptor.capture()) @@ -365,12 +369,16 @@ class AppPairsControllerTest { whenever(mockTaskKey1.getId()).thenReturn(1) whenever(mockTaskKey2.getId()).thenReturn(2) // ... with app 2 already on screen - whenever(mockCachedTaskInfo.taskId).thenReturn(2) + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + whenever(mockCachedTaskInfo.topGroupedTaskContainsTask(eq(2))).thenReturn(true) + } else { + whenever(mockCachedTaskInfo.taskId).thenReturn(2) + } // Trigger app pair launch, capture and run callback from findLastActiveTasksAndRunCallback spyAppPairsController.handleAppPairLaunchInApp( mockAppPairIcon, - listOf(mockItemInfo1, mockItemInfo2) + listOf(mockItemInfo1, mockItemInfo2), ) verify(splitSelectStateController) .findLastActiveTasksAndRunCallback(any(), any(), callbackCaptor.capture()) @@ -389,12 +397,16 @@ class AppPairsControllerTest { whenever(mockTaskKey1.getId()).thenReturn(1) whenever(mockTaskKey2.getId()).thenReturn(2) // ... with app 3 already on screen - whenever(mockCachedTaskInfo.taskId).thenReturn(3) + if (com.android.wm.shell.Flags.enableShellTopTaskTracking()) { + whenever(mockCachedTaskInfo.topGroupedTaskContainsTask(eq(3))).thenReturn(true) + } else { + whenever(mockCachedTaskInfo.taskId).thenReturn(3) + } // Trigger app pair launch, capture and run callback from findLastActiveTasksAndRunCallback spyAppPairsController.handleAppPairLaunchInApp( mockAppPairIcon, - listOf(mockItemInfo1, mockItemInfo2) + listOf(mockItemInfo1, mockItemInfo2), ) verify(splitSelectStateController) .findLastActiveTasksAndRunCallback(any(), any(), callbackCaptor.capture()) From 8451f0fb1edd737794153902ab4520ef7617daae Mon Sep 17 00:00:00 2001 From: Schneider Victor-Tulias Date: Mon, 4 Nov 2024 15:02:02 -0500 Subject: [PATCH 06/15] Update RecentsWindowSwipeHandler to animate home->overview properly Update RecentsWindowSwipeHandler to animate home alpha properly Flag: com.android.launcher3.enable_fallback_overview_in_window Fixes: 366022874 Test: Attempted gesture from home and launched app Change-Id: Idf4ed071a843a129f1d39caa59e468f6c88e9e38 --- .../fallback/window/RecentsWindowSwipeHandler.java | 3 ++- .../src/com/android/quickstep/views/RecentsView.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java index 4f9d8371dc..c1d3f6e18e 100644 --- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java @@ -149,7 +149,8 @@ public class RecentsWindowSwipeHandler extends AbsSwipeUpHandler { final TransformParams params = remoteTargetHandle.getTransformParams(); + if (Flags.enableFallbackOverviewInWindow() || Flags.enableLauncherOverviewInWindow()) { + params.setHomeBuilderProxy((builder, app, transformParams) -> { + mTmpMatrix.setScale( + 1f, 1f, app.localBounds.exactCenterX(), app.localBounds.exactCenterY()); + builder.setMatrix(mTmpMatrix).setAlpha(1f).setShow(); + }); + } + if (mSyncTransactionApplier != null) { params.setSyncTransactionApplier(mSyncTransactionApplier); params.getTargetSet().addReleaseCheck(mSyncTransactionApplier); From 6c91ef91916d3de74bbd2b25c21911ac5a1fe156 Mon Sep 17 00:00:00 2001 From: fbaron Date: Tue, 12 Nov 2024 22:22:43 -0800 Subject: [PATCH 07/15] Add OldGrid field for GridOption so we can properly filter out the old grids when the flag is on Bug: 364711064 Flag: com.android.launcher3.one_grid_specs Test: NexusLauncherImageTests, DeviceProfileDumpTest Change-Id: I8e3ff70d2f3008d1de7c8419290ff44c18c72e70 --- res/values/attrs.xml | 3 ++- .../launcher3/InvariantDeviceProfile.java | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 77d789ff25..4ccdd53f61 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -312,9 +312,10 @@ - + + diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 04e4b570ed..e18862a493 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -1031,6 +1031,7 @@ public class InvariantDeviceProfile implements SafeCloseable { private final int mAllAppsCellSpecsTwoPanelId; private final int mRowCountSpecsId; private final boolean mIsFixedLandscape; + private final boolean mIsOldGrid; public GridOption(Context context, AttributeSet attrs, Info displayInfo) { TypedArray a = context.obtainStyledAttributes( @@ -1175,6 +1176,7 @@ public class InvariantDeviceProfile implements SafeCloseable { } mIsFixedLandscape = a.getBoolean(R.styleable.GridDisplayOption_isFixedLandscape, false); + mIsOldGrid = a.getBoolean(R.styleable.GridDisplayOption_isOldGrid, false); int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb, DONT_INLINE_QSB); @@ -1206,20 +1208,30 @@ public class InvariantDeviceProfile implements SafeCloseable { } } - public boolean isNewGridOption() { - return mRowCountSpecsId != INVALID_RESOURCE_HANDLE; - } - + /** + * Returns true if the grid option should be used given the flags that are toggled on/off. + */ public boolean filterByFlag(int deviceType, boolean isFixedLandscape) { if (deviceType == TYPE_TABLET) { return Flags.oneGridRotationHandling() == mIsDualGrid; } - if (isFixedLandscape) { - return Flags.oneGridSpecs() && mIsFixedLandscape; + // Here we return true if fixed landscape mode should be on. + if (mIsFixedLandscape || isFixedLandscape) { + return mIsFixedLandscape && isFixedLandscape && Flags.oneGridSpecs(); } - return ((Flags.oneGridSpecs() == isNewGridOption()) && !mIsFixedLandscape); + // Here we return true if we want to show the new grids. + if (mRowCountSpecsId != INVALID_RESOURCE_HANDLE) { + return Flags.oneGridSpecs(); + } + + // Here we return true if we want to show the old grids. + if (mIsOldGrid) { + return !Flags.oneGridSpecs(); + } + + return true; } } From 4c727e38fdc0779abd32d23a5f1a01baa75fcbd0 Mon Sep 17 00:00:00 2001 From: Shamali P Date: Wed, 13 Nov 2024 19:45:28 +0000 Subject: [PATCH 08/15] Don't bind scrollbar if current recycler view isn't changed. Bug: 378417297 Flag: EXEMPT BUGFIX Test: Installed app in bg with picker open and verified no scroll to top Change-Id: I9b3c6a22c9b971f4d11bc6a6e534d4b6e0ca60bf --- .../android/launcher3/widget/picker/WidgetsFullSheet.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index 2f64ab1079..6494d2e93b 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -295,8 +295,11 @@ public class WidgetsFullSheet extends BaseWidgetSheet } private void attachScrollbarToRecyclerView(WidgetsRecyclerView recyclerView) { - recyclerView.bindFastScrollbar(mFastScroller, WIDGET_SCROLLER); if (mCurrentWidgetsRecyclerView != recyclerView) { + // Bind scrollbar if changing the recycler view. If widgets list updates, since + // scrollbar is already attached to the recycler view, it will automatically adjust as + // needed with recycler view's onScrollListener. + recyclerView.bindFastScrollbar(mFastScroller, WIDGET_SCROLLER); // Only reset the scroll position & expanded apps if the currently shown recycler view // has been updated. reset(); From ca950044034005eab4341652929fc7696f8d0d71 Mon Sep 17 00:00:00 2001 From: Wen-Chien Wang Date: Tue, 5 Nov 2024 00:52:22 +0000 Subject: [PATCH 09/15] Updates layout when overflow button and alt-tab are both triggered. Before this cl, the KQS view is closed and reopened when the overflow button and alt-tab key are triggered one after the other. This cl changes the behavior so that instead of reopening, the list of task is updated and the KQS container layout is toggled between "wrap content" and "match parent". Bug: 368119679 Test: open KQS via taskbar and observe the layout change Flag: com.android.launcher3.taskbar_overflow Change-Id: I05ea4c66727daa206ff1d7906500dc8f9cc81982 --- .../res/layout/keyboard_quick_switch_view.xml | 1 + .../KeyboardQuickSwitchController.java | 63 ++++++++++++++----- .../taskbar/KeyboardQuickSwitchView.java | 10 ++- .../KeyboardQuickSwitchViewController.java | 31 +++++++++ 4 files changed, 87 insertions(+), 18 deletions(-) diff --git a/quickstep/res/layout/keyboard_quick_switch_view.xml b/quickstep/res/layout/keyboard_quick_switch_view.xml index 2420a4624e..4118500656 100644 --- a/quickstep/res/layout/keyboard_quick_switch_view.xml +++ b/quickstep/res/layout/keyboard_quick_switch_view.xml @@ -22,6 +22,7 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/keyboard_quick_switch_margin_top" android:layout_marginHorizontal="@dimen/keyboard_quick_switch_margin_ends" + android:layout_gravity="center_horizontal" android:background="@drawable/keyboard_quick_switch_view_background" android:clipToOutline="true" android:alpha="0" diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index 23a5a27984..3b7ad3e618 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -139,18 +139,42 @@ public final class KeyboardQuickSwitchController implements @NonNull Set taskIdsToExclude, boolean wasOpenedFromTaskbar) { if (mQuickSwitchViewController != null) { - if (!mQuickSwitchViewController.isCloseAnimationRunning() - && mQuickSwitchViewController.wasOpenedFromTaskbar() == wasOpenedFromTaskbar) { - return; - } + if (!mQuickSwitchViewController.isCloseAnimationRunning()) { + if (mQuickSwitchViewController.wasOpenedFromTaskbar() == wasOpenedFromTaskbar) { + return; + } - // Allow the KQS to be reopened during the close animation to make it more responsive. - // Similarly, if KQS was opened in different mode (from taskbar vs. keyboard event), - // close it so it can be reopened in the correct mode. - // TODO(b/368119679) Consider updating list of shown tasks in place, or at least reopen - // the view in the same vertical location. - closeQuickSwitchView(false); + // Relayout the KQS view instead of recreating a new one if it is the current + // trigger surface is different than the previous one. + final int currentFocusIndexOverride = + currentFocusedIndex == -1 && !mControllerCallbacks.isFirstTaskRunning() + ? 0 : currentFocusedIndex; + + // Skip the task reload if the list is not changed. + if (!mModel.isTaskListValid(mTaskListChangeId) || !taskIdsToExclude.equals( + mExcludedTaskIds)) { + mExcludedTaskIds = taskIdsToExclude; + mTaskListChangeId = mModel.getTasks((tasks) -> { + processLoadedTasks(tasks, taskIdsToExclude); + mQuickSwitchViewController.updateQuickSwitchView( + mTasks, + mNumHiddenTasks, + currentFocusIndexOverride, + mHasDesktopTask, + mWasDesktopTaskFilteredOut); + }); + } + + mQuickSwitchViewController.updateLayoutForSurface(wasOpenedFromTaskbar, + currentFocusIndexOverride); + return; + } else { + // Allow the KQS to be reopened during the close animation to make it more + // responsive. + closeQuickSwitchView(false); + } } + mOverlayContext = mControllers.taskbarOverlayController.requestWindow(); if (Flags.taskbarOverflow()) { mOverlayContext.getDragLayer().addTouchController(this); @@ -186,13 +210,7 @@ public final class KeyboardQuickSwitchController implements mExcludedTaskIds = taskIdsToExclude; mTaskListChangeId = mModel.getTasks((tasks) -> { - mHasDesktopTask = false; - mWasDesktopTaskFilteredOut = false; - if (onDesktop) { - processLoadedTasksOnDesktop(tasks, taskIdsToExclude); - } else { - processLoadedTasks(tasks, taskIdsToExclude); - } + processLoadedTasks(tasks, taskIdsToExclude); // Check if the first task is running after the recents model has updated so that we use // the correct index. mQuickSwitchViewController.openQuickSwitchView( @@ -213,6 +231,17 @@ public final class KeyboardQuickSwitchController implements } private void processLoadedTasks(List tasks, Set taskIdsToExclude) { + mHasDesktopTask = false; + mWasDesktopTaskFilteredOut = false; + if (mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) { + processLoadedTasksOnDesktop(tasks, taskIdsToExclude); + } else { + processLoadedTasksOutsideDesktop(tasks, taskIdsToExclude); + } + } + + private void processLoadedTasksOutsideDesktop(List tasks, + Set taskIdsToExclude) { // Only store MAX_TASK tasks, from most to least recent Collections.reverse(tasks); mTasks = tasks.stream() diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java index 05d34b5cb7..1967dfd980 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java @@ -201,6 +201,8 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { int currentFocusIndexOverride, @NonNull KeyboardQuickSwitchViewController.ViewCallbacks viewCallbacks, boolean useDesktopTaskView) { + mContent.removeAllViews(); + mViewCallbacks = viewCallbacks; Resources resources = context.getResources(); Resources.Theme theme = context.getTheme(); @@ -333,11 +335,17 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { return closeAnimation; } - private void animateOpen(int currentFocusIndexOverride) { + protected void animateOpen(int currentFocusIndexOverride) { if (mOpenAnimation != null) { // Restart animation since currentFocusIndexOverride can change the initial scroll. mOpenAnimation.cancel(); } + + // Reset the alpha for the case where the KQS view is opened before. + setAlpha(0); + mScrollView.setAlpha(0); + mNoRecentItemsPane.setAlpha(0); + mOpenAnimation = new AnimatorSet(); Animator outlineAnimation = mOutlineAnimationProgress.animateToValue(1f); diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java index 390112e676..985cc26d8e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java @@ -128,6 +128,23 @@ public class KeyboardQuickSwitchViewController { /* useDesktopTaskView= */ !onDesktop && hasDesktopTask); } + protected void updateQuickSwitchView( + @NonNull List tasks, + int numHiddenTasks, + int currentFocusIndexOverride, + boolean hasDesktopTask, + boolean wasDesktopTaskFilteredOut) { + mWasDesktopTaskFilteredOut = wasDesktopTaskFilteredOut; + mKeyboardQuickSwitchView.applyLoadPlan( + mOverlayContext, + tasks, + numHiddenTasks, + /* updateTasks= */ true, + currentFocusIndexOverride, + mViewCallbacks, + /* useDesktopTaskView= */ !mOnDesktop && hasDesktopTask); + } + protected void positionView(boolean wasOpenedFromTaskbar, boolean isTransientTaskbar) { if (!wasOpenedFromTaskbar) { // Keep the default positioning. @@ -155,6 +172,20 @@ public class KeyboardQuickSwitchViewController { mKeyboardQuickSwitchView.setLayoutParams(lp); } + protected void updateLayoutForSurface(boolean updateLayoutFromTaskbar, + int currentFocusIndexOverride) { + BaseDragLayer.LayoutParams lp = + (BaseDragLayer.LayoutParams) mKeyboardQuickSwitchView.getLayoutParams(); + + if (updateLayoutFromTaskbar) { + lp.width = BaseDragLayer.LayoutParams.WRAP_CONTENT; + } else { + lp.width = BaseDragLayer.LayoutParams.MATCH_PARENT; + } + + mKeyboardQuickSwitchView.animateOpen(currentFocusIndexOverride); + } + boolean isCloseAnimationRunning() { return mCloseAnimation != null; } From e50d5ded7752bf12c36875b714a5794c214bc9aa Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Wed, 13 Nov 2024 19:10:45 +0000 Subject: [PATCH 10/15] Remove noises during a11y drag in Launcher. Bug: 374642145 Bug: 374656225 Bug: 374658319 Change-Id: I842415f689c992f64d863743f019455701da22e9 Test: manual Flag: EXEMPT bugfix --- .../android/launcher3/dragndrop/LauncherDragController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/android/launcher3/dragndrop/LauncherDragController.java b/src/com/android/launcher3/dragndrop/LauncherDragController.java index 29fc6139f7..4aa3673586 100644 --- a/src/com/android/launcher3/dragndrop/LauncherDragController.java +++ b/src/com/android/launcher3/dragndrop/LauncherDragController.java @@ -119,6 +119,9 @@ public class LauncherDragController extends DragController { initialDragViewScale, dragViewScaleOnDrop, scalePx); + // During a drag, we don't want to expose the descendendants of drag view to a11y users, + // since those decendents are not a valid position in the workspace. + dragView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); dragView.setItemInfo(dragInfo); mDragObject.dragComplete = false; From 121f6880ddd8a12c9f47d378de895d3580961d52 Mon Sep 17 00:00:00 2001 From: Toni Barzic Date: Fri, 18 Oct 2024 23:46:59 +0000 Subject: [PATCH 11/15] Test KQS gets dismissed in certain situations Adds tests that verify the KQS gets properly dismissed when user swipes home while Keyboard Quick Switch UI is shown. Bug: None Test: atest TaplTestsKeyboardQuickSwitch Flag: EXEMPT tests Change-Id: I6da053f297eedb297c0d40a7414883fbd69b94e5 --- .../TaplTestsKeyboardQuickSwitch.java | 9 +++++++ .../launcher3/tapl/KeyboardQuickSwitch.java | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java b/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java index 43ebb1752a..3c4f1d9c6c 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java @@ -49,6 +49,7 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest { DISMISS(0), LAUNCH_LAST_APP(0), LAUNCH_SELECTED_APP(1), + DISMISS_WHEN_GOING_HOME(1), LAUNCH_OVERVIEW(KeyboardQuickSwitchController.MAX_TASKS - 1); private final int mNumAdditionalRunningTasks; @@ -156,6 +157,11 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest { mLauncher.goHome().showQuickSwitchView().launchFocusedAppTask(CALCULATOR_APP_PACKAGE); } + @Test + public void testDismissedWhenGoingHome() { + runTest(TestSurface.LAUNCHED_APP, TestCase.DISMISS_WHEN_GOING_HOME); + } + private void runTest(@NonNull TestSurface testSurface, @NonNull TestCase testCase) { for (int i = 0; i < testCase.mNumAdditionalRunningTasks; i++) { startTestActivity(3 + i); @@ -197,6 +203,9 @@ public class TaplTestsKeyboardQuickSwitch extends AbstractQuickStepTest { } kqs.launchFocusedAppTask(CALCULATOR_APP_PACKAGE); break; + case DISMISS_WHEN_GOING_HOME: + kqs.dismissByGoingHome(); + break; case LAUNCH_OVERVIEW: kqs.moveFocusBackward(); if (!testSurface.mInitialFocusAtZero) { diff --git a/tests/tapl/com/android/launcher3/tapl/KeyboardQuickSwitch.java b/tests/tapl/com/android/launcher3/tapl/KeyboardQuickSwitch.java index 7ff55fe5cf..7cb26142a5 100644 --- a/tests/tapl/com/android/launcher3/tapl/KeyboardQuickSwitch.java +++ b/tests/tapl/com/android/launcher3/tapl/KeyboardQuickSwitch.java @@ -162,6 +162,32 @@ public final class KeyboardQuickSwitch { } } + /** + * Dismisses the Keyboard Quick Switch view by going home. After the Keyboard Quick Switch view + * gets hidden, it unpresses ALT key, which is generally used to keep the view visible. + */ + public Workspace dismissByGoingHome() { + try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( + "verifying keyboard quick switch view is shown")) { + mLauncher.waitForLauncherObject(KEYBOARD_QUICK_SWITCH_RES_ID); + } + + mLauncher.goHome(); + + try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( + "waiting for keyboard quick switch dismissal"); + LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { + mLauncher.waitUntilLauncherObjectGone(KEYBOARD_QUICK_SWITCH_RES_ID); + } + + try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer( + "get workspace after releasing ALT key")) { + mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, EVENT_HOME_ALT_LEFT_UP); + mLauncher.unpressKeyCode(KeyEvent.KEYCODE_ALT_LEFT, 0); + return mLauncher.getWorkspace(); + } + } + /** * Launches the currently-focused app task. *

From 39dee43e12e27171cd13cbb6a7c397fd96fc2da2 Mon Sep 17 00:00:00 2001 From: Olivier Nshimiye Date: Tue, 10 Sep 2024 19:20:42 +0000 Subject: [PATCH 12/15] Listen to LauncherUserInfo config changes and hide/unhide private space entrypoint accordingly Flag: android.multiuser.add_launcher_user_config Bug: 346553745 Test: Manual - verified on device Test: atest LauncherAppsTests Change-Id: I202c4c76af4f96d5b3226daffcfebc2f9b9703b1 --- Android.bp | 1 + .../launcher3/uioverrides/SystemApiWrapper.kt | 28 ++++++++++------ .../android/launcher3/LauncherAppState.java | 4 ++- .../allapps/PrivateProfileManager.java | 19 +++++++++-- .../launcher3/model/ModelLauncherCallbacks.kt | 14 ++++++++ src/com/android/launcher3/pm/UserCache.java | 5 ++- .../android/launcher3/util/ApiWrapper.java | 33 ++++++++++++++----- 7 files changed, 80 insertions(+), 24 deletions(-) diff --git a/Android.bp b/Android.bp index 73d0fce260..df9615631f 100644 --- a/Android.bp +++ b/Android.bp @@ -25,6 +25,7 @@ java_defaults { name: "launcher-non-platform-apis-defaults", static_libs: [ "android.os.flags-aconfig-java", + "android.multiuser.flags-aconfig-java", "android.appwidget.flags-aconfig-java", "com.android.window.flags.window-aconfig-java", ], diff --git a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt index 374db6ae6f..2946242ac7 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt +++ b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt @@ -27,6 +27,7 @@ import android.content.pm.ApplicationInfo import android.content.pm.LauncherActivityInfo import android.content.pm.LauncherApps import android.content.pm.ShortcutInfo +import android.multiuser.Flags.addLauncherUserConfig import android.os.Bundle import android.os.Flags.allowPrivateProfile import android.os.IBinder @@ -74,16 +75,14 @@ open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Con mContext.getSystemService(UserManager::class.java)!!.userProfiles?.forEach { user -> mContext.getSystemService(LauncherApps::class.java)!!.getLauncherUserInfo(user)?.apply { users[user] = - UserIconInfo( - user, - when (userType) { - UserManager.USER_TYPE_PROFILE_MANAGED -> UserIconInfo.TYPE_WORK - UserManager.USER_TYPE_PROFILE_CLONE -> UserIconInfo.TYPE_CLONED - UserManager.USER_TYPE_PROFILE_PRIVATE -> UserIconInfo.TYPE_PRIVATE - else -> UserIconInfo.TYPE_MAIN - }, - userSerialNumber.toLong(), - ) + if (addLauncherUserConfig()) + UserIconInfo( + user, + getUserIconType(userType), + userSerialNumber.toLong(), + userConfig, + ) + else UserIconInfo(user, getUserIconType(userType), userSerialNumber.toLong()) } } return users @@ -192,4 +191,13 @@ open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Con override fun getApplicationInfoHash(appInfo: ApplicationInfo): String = (appInfo.sourceDir?.hashCode() ?: 0).toString() + " " + appInfo.longVersionCode + + fun getUserIconType(userType: String): Int { + return when (userType) { + UserManager.USER_TYPE_PROFILE_MANAGED -> UserIconInfo.TYPE_WORK + UserManager.USER_TYPE_PROFILE_CLONE -> UserIconInfo.TYPE_CLONED + UserManager.USER_TYPE_PROFILE_PRIVATE -> UserIconInfo.TYPE_PRIVATE + else -> UserIconInfo.TYPE_MAIN + } + } } diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index 01d0a740d7..3936fe6564 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -188,7 +188,9 @@ public class LauncherAppState implements SafeCloseable { mOnTerminateCallback.add(() -> settingsCache.unregister(NOTIFICATION_BADGING_URI, notificationLister)); // Register an observer to notify Launcher about Private Space settings toggle. - registerPrivateSpaceHideWhenLockListener(settingsCache); + if (!android.multiuser.Flags.addLauncherUserConfig()) { + registerPrivateSpaceHideWhenLockListener(settingsCache); + } } public LauncherAppState(Context context, @Nullable String iconCacheFileName) { diff --git a/src/com/android/launcher3/allapps/PrivateProfileManager.java b/src/com/android/launcher3/allapps/PrivateProfileManager.java index 21dce14bbf..e1c1b39493 100644 --- a/src/com/android/launcher3/allapps/PrivateProfileManager.java +++ b/src/com/android/launcher3/allapps/PrivateProfileManager.java @@ -16,6 +16,7 @@ package com.android.launcher3.allapps; +import static android.content.pm.LauncherUserInfo.PRIVATE_SPACE_ENTRYPOINT_HIDDEN; import static android.view.View.GONE; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; @@ -43,6 +44,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.os.UserHandle; @@ -78,11 +80,13 @@ import com.android.launcher3.pm.UserCache; import com.android.launcher3.util.ApiWrapper; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.SettingsCache; +import com.android.launcher3.util.UserIconInfo; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.RecyclerViewFastScroller; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.function.Predicate; /** @@ -209,9 +213,20 @@ public class PrivateProfileManager extends UserProfileManager { } /** Whether private profile should be hidden on Launcher. */ + @SuppressLint("NewApi") public boolean isPrivateSpaceHidden() { - return getCurrentState() == STATE_DISABLED && SettingsCache.INSTANCE - .get(mAllApps.getContext()).getValue(PRIVATE_SPACE_HIDE_WHEN_LOCKED_URI, 0); + UserHandle profileHandle = getProfileUser(); + if (android.multiuser.Flags.addLauncherUserConfig() && !Objects.isNull(profileHandle)) { + UserIconInfo userInconInfo = UserCache.INSTANCE.get(mAllApps.getContext()).getUserInfo( + profileHandle); + + return getCurrentState() == STATE_DISABLED && userInconInfo.getUserConfig().getBoolean( + PRIVATE_SPACE_ENTRYPOINT_HIDDEN, false); + } + + return getCurrentState() == STATE_DISABLED && SettingsCache.INSTANCE.get( + mAllApps.getContext()).getValue(PRIVATE_SPACE_HIDE_WHEN_LOCKED_URI, 0); + } /** diff --git a/src/com/android/launcher3/model/ModelLauncherCallbacks.kt b/src/com/android/launcher3/model/ModelLauncherCallbacks.kt index 7ba2dad553..ba4908ca8a 100644 --- a/src/com/android/launcher3/model/ModelLauncherCallbacks.kt +++ b/src/com/android/launcher3/model/ModelLauncherCallbacks.kt @@ -16,7 +16,9 @@ package com.android.launcher3.model +import android.annotation.SuppressLint import android.content.pm.LauncherApps +import android.content.pm.LauncherUserInfo import android.content.pm.PackageInstaller.SessionInfo import android.content.pm.ShortcutInfo import android.os.UserHandle @@ -32,6 +34,7 @@ import com.android.launcher3.model.PackageUpdatedTask.OP_UNSUSPEND import com.android.launcher3.model.PackageUpdatedTask.OP_UPDATE import com.android.launcher3.pm.InstallSessionTracker import com.android.launcher3.pm.PackageInstallInfo +import com.android.launcher3.pm.UserCache import com.android.launcher3.util.PackageUserKey import java.util.function.Consumer @@ -134,6 +137,17 @@ class ModelLauncherCallbacks(private var taskExecutor: Consumer } } + @SuppressLint("NewApi") + override fun onUserConfigChanged(launcherUserInfo: LauncherUserInfo) { + FileLog.d(TAG, "onUserConfigChanged for user ${launcherUserInfo.userType}") + if (android.multiuser.Flags.addLauncherUserConfig()) { + taskExecutor.accept { taskController, _, _ -> + UserCache.INSTANCE.get(taskController.app.context).updateCache() + taskController.app.model.forceReload() + } + } + } + companion object { private const val TAG = "LauncherAppsCallbackImpl" } diff --git a/src/com/android/launcher3/pm/UserCache.java b/src/com/android/launcher3/pm/UserCache.java index e8619610a8..69f4469e02 100644 --- a/src/com/android/launcher3/pm/UserCache.java +++ b/src/com/android/launcher3/pm/UserCache.java @@ -26,7 +26,6 @@ import android.os.UserHandle; import android.os.UserManager; import android.util.ArrayMap; -import androidx.annotation.AnyThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -111,7 +110,7 @@ public class UserCache implements SafeCloseable { updateCache(); } - @AnyThread + @WorkerThread private void onUsersChanged(Intent intent) { MODEL_EXECUTOR.execute(this::updateCache); UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER); @@ -123,7 +122,7 @@ public class UserCache implements SafeCloseable { } @WorkerThread - private void updateCache() { + public void updateCache() { mUserToSerialMap = ApiWrapper.INSTANCE.get(mContext).queryAllUsers(); mUserToPreInstallAppMap = fetchPreInstallApps(); } diff --git a/src/com/android/launcher3/util/ApiWrapper.java b/src/com/android/launcher3/util/ApiWrapper.java index 467a7ec54f..35fc9f5d80 100644 --- a/src/com/android/launcher3/util/ApiWrapper.java +++ b/src/com/android/launcher3/util/ApiWrapper.java @@ -16,8 +16,11 @@ package com.android.launcher3.util; +import static android.multiuser.Flags.addLauncherUserConfig; + import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_HOME_ROLE; +import android.annotation.SuppressLint; import android.app.ActivityOptions; import android.app.Person; import android.app.role.RoleManager; @@ -25,9 +28,12 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; +import android.content.pm.LauncherApps; +import android.content.pm.LauncherUserInfo; import android.content.pm.ShortcutInfo; import android.graphics.drawable.ColorDrawable; import android.net.Uri; +import android.os.Build; import android.os.UserHandle; import android.os.UserManager; import android.util.ArrayMap; @@ -45,6 +51,7 @@ import com.android.launcher3.dagger.LauncherAppSingleton; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; import javax.inject.Inject; @@ -85,22 +92,32 @@ public class ApiWrapper { /** * Returns a map of all users on the device to their corresponding UI properties */ + @SuppressLint("NewApi") public Map queryAllUsers() { UserManager um = mContext.getSystemService(UserManager.class); Map users = new ArrayMap<>(); List usersActual = um.getUserProfiles(); if (usersActual != null) { for (UserHandle user : usersActual) { - long serial = um.getSerialNumberForUser(user); - - // Simple check to check if the provided user is work profile - // TODO: Migrate to a better platform API NoopDrawable d = new NoopDrawable(); boolean isWork = (d != mContext.getPackageManager().getUserBadgedIcon(d, user)); - UserIconInfo info = new UserIconInfo( - user, - isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN, - serial); + UserIconInfo info; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { + LauncherUserInfo userInfo = Objects.requireNonNull( + mContext.getSystemService(LauncherApps.class)).getLauncherUserInfo( + user); + long serial = Objects.requireNonNull(userInfo).getUserSerialNumber(); + info = addLauncherUserConfig() ? new UserIconInfo(user, + isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN, serial, + userInfo.getUserConfig()) : new UserIconInfo(user, + isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN, serial); + } else { + long serial = um.getSerialNumberForUser(user); + // Simple check to check if the provided user is work profile + // TODO: Migrate to a better platform API + info = new UserIconInfo(user, + isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN, serial); + } users.put(user, info); } } From b83ea0203bafe721c8c7a617a7986b269bb39a5b Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Wed, 13 Nov 2024 17:27:55 -0800 Subject: [PATCH 13/15] Dissable fixed landscape on foldables until fixed b/378972567 Bug: 378972567 Flag: com.android.launcher3.one_grid_specs Test: IntegrationReorderWidgetsTest Change-Id: I1125d7d4a1dfba38fa8f05fe1cbc910ede24a1f5 --- src/com/android/launcher3/settings/SettingsActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java index 5851f625f2..5068b48fc8 100644 --- a/src/com/android/launcher3/settings/SettingsActivity.java +++ b/src/com/android/launcher3/settings/SettingsActivity.java @@ -22,6 +22,7 @@ import static androidx.preference.PreferenceFragmentCompat.ARG_PREFERENCE_ROOT; import static com.android.launcher3.BuildConfig.IS_DEBUG_DEVICE; import static com.android.launcher3.BuildConfig.IS_STUDIO_BUILD; +import static com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY; import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY; import android.app.Activity; @@ -52,6 +53,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.BuildConfig; import com.android.launcher3.Flags; +import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherFiles; import com.android.launcher3.R; import com.android.launcher3.states.RotationHelper; @@ -310,7 +312,10 @@ public class SettingsActivity extends FragmentActivity } return mDeveloperOptionsEnabled; case FIXED_LANDSCAPE_MODE: - if (!Flags.oneGridSpecs()) { + if (!Flags.oneGridSpecs() + // adding this condition until fixing b/378972567 + || InvariantDeviceProfile.INSTANCE.get(getContext()).deviceType + == TYPE_MULTI_DISPLAY) { return false; } // When the setting changes rotate the screen accordingly to showcase the result From 41743bd0c7e956784c21af67293f2dfee43f8635 Mon Sep 17 00:00:00 2001 From: "Pechetty Sravani (xWF)" Date: Thu, 14 Nov 2024 06:11:08 +0000 Subject: [PATCH 14/15] Revert "Listen to LauncherUserInfo config changes and hide/unhid..." Revert submission 29352757-update-usericoninfo Reason for revert: Reverted changes: /q/submissionid:29352757-update-usericoninfo Change-Id: I751536274ec9dcc4047bf9c76b3a5cab258da6e4 --- Android.bp | 1 - .../launcher3/uioverrides/SystemApiWrapper.kt | 28 ++++++---------- .../android/launcher3/LauncherAppState.java | 4 +-- .../allapps/PrivateProfileManager.java | 19 ++--------- .../launcher3/model/ModelLauncherCallbacks.kt | 14 -------- src/com/android/launcher3/pm/UserCache.java | 5 +-- .../android/launcher3/util/ApiWrapper.java | 33 +++++-------------- 7 files changed, 24 insertions(+), 80 deletions(-) diff --git a/Android.bp b/Android.bp index df9615631f..73d0fce260 100644 --- a/Android.bp +++ b/Android.bp @@ -25,7 +25,6 @@ java_defaults { name: "launcher-non-platform-apis-defaults", static_libs: [ "android.os.flags-aconfig-java", - "android.multiuser.flags-aconfig-java", "android.appwidget.flags-aconfig-java", "com.android.window.flags.window-aconfig-java", ], diff --git a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt index 2946242ac7..374db6ae6f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt +++ b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt @@ -27,7 +27,6 @@ import android.content.pm.ApplicationInfo import android.content.pm.LauncherActivityInfo import android.content.pm.LauncherApps import android.content.pm.ShortcutInfo -import android.multiuser.Flags.addLauncherUserConfig import android.os.Bundle import android.os.Flags.allowPrivateProfile import android.os.IBinder @@ -75,14 +74,16 @@ open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Con mContext.getSystemService(UserManager::class.java)!!.userProfiles?.forEach { user -> mContext.getSystemService(LauncherApps::class.java)!!.getLauncherUserInfo(user)?.apply { users[user] = - if (addLauncherUserConfig()) - UserIconInfo( - user, - getUserIconType(userType), - userSerialNumber.toLong(), - userConfig, - ) - else UserIconInfo(user, getUserIconType(userType), userSerialNumber.toLong()) + UserIconInfo( + user, + when (userType) { + UserManager.USER_TYPE_PROFILE_MANAGED -> UserIconInfo.TYPE_WORK + UserManager.USER_TYPE_PROFILE_CLONE -> UserIconInfo.TYPE_CLONED + UserManager.USER_TYPE_PROFILE_PRIVATE -> UserIconInfo.TYPE_PRIVATE + else -> UserIconInfo.TYPE_MAIN + }, + userSerialNumber.toLong(), + ) } } return users @@ -191,13 +192,4 @@ open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Con override fun getApplicationInfoHash(appInfo: ApplicationInfo): String = (appInfo.sourceDir?.hashCode() ?: 0).toString() + " " + appInfo.longVersionCode - - fun getUserIconType(userType: String): Int { - return when (userType) { - UserManager.USER_TYPE_PROFILE_MANAGED -> UserIconInfo.TYPE_WORK - UserManager.USER_TYPE_PROFILE_CLONE -> UserIconInfo.TYPE_CLONED - UserManager.USER_TYPE_PROFILE_PRIVATE -> UserIconInfo.TYPE_PRIVATE - else -> UserIconInfo.TYPE_MAIN - } - } } diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index 3936fe6564..01d0a740d7 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -188,9 +188,7 @@ public class LauncherAppState implements SafeCloseable { mOnTerminateCallback.add(() -> settingsCache.unregister(NOTIFICATION_BADGING_URI, notificationLister)); // Register an observer to notify Launcher about Private Space settings toggle. - if (!android.multiuser.Flags.addLauncherUserConfig()) { - registerPrivateSpaceHideWhenLockListener(settingsCache); - } + registerPrivateSpaceHideWhenLockListener(settingsCache); } public LauncherAppState(Context context, @Nullable String iconCacheFileName) { diff --git a/src/com/android/launcher3/allapps/PrivateProfileManager.java b/src/com/android/launcher3/allapps/PrivateProfileManager.java index e1c1b39493..21dce14bbf 100644 --- a/src/com/android/launcher3/allapps/PrivateProfileManager.java +++ b/src/com/android/launcher3/allapps/PrivateProfileManager.java @@ -16,7 +16,6 @@ package com.android.launcher3.allapps; -import static android.content.pm.LauncherUserInfo.PRIVATE_SPACE_ENTRYPOINT_HIDDEN; import static android.view.View.GONE; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; @@ -44,7 +43,6 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; -import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.os.UserHandle; @@ -80,13 +78,11 @@ import com.android.launcher3.pm.UserCache; import com.android.launcher3.util.ApiWrapper; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.SettingsCache; -import com.android.launcher3.util.UserIconInfo; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.RecyclerViewFastScroller; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import java.util.function.Predicate; /** @@ -213,20 +209,9 @@ public class PrivateProfileManager extends UserProfileManager { } /** Whether private profile should be hidden on Launcher. */ - @SuppressLint("NewApi") public boolean isPrivateSpaceHidden() { - UserHandle profileHandle = getProfileUser(); - if (android.multiuser.Flags.addLauncherUserConfig() && !Objects.isNull(profileHandle)) { - UserIconInfo userInconInfo = UserCache.INSTANCE.get(mAllApps.getContext()).getUserInfo( - profileHandle); - - return getCurrentState() == STATE_DISABLED && userInconInfo.getUserConfig().getBoolean( - PRIVATE_SPACE_ENTRYPOINT_HIDDEN, false); - } - - return getCurrentState() == STATE_DISABLED && SettingsCache.INSTANCE.get( - mAllApps.getContext()).getValue(PRIVATE_SPACE_HIDE_WHEN_LOCKED_URI, 0); - + return getCurrentState() == STATE_DISABLED && SettingsCache.INSTANCE + .get(mAllApps.getContext()).getValue(PRIVATE_SPACE_HIDE_WHEN_LOCKED_URI, 0); } /** diff --git a/src/com/android/launcher3/model/ModelLauncherCallbacks.kt b/src/com/android/launcher3/model/ModelLauncherCallbacks.kt index ba4908ca8a..7ba2dad553 100644 --- a/src/com/android/launcher3/model/ModelLauncherCallbacks.kt +++ b/src/com/android/launcher3/model/ModelLauncherCallbacks.kt @@ -16,9 +16,7 @@ package com.android.launcher3.model -import android.annotation.SuppressLint import android.content.pm.LauncherApps -import android.content.pm.LauncherUserInfo import android.content.pm.PackageInstaller.SessionInfo import android.content.pm.ShortcutInfo import android.os.UserHandle @@ -34,7 +32,6 @@ import com.android.launcher3.model.PackageUpdatedTask.OP_UNSUSPEND import com.android.launcher3.model.PackageUpdatedTask.OP_UPDATE import com.android.launcher3.pm.InstallSessionTracker import com.android.launcher3.pm.PackageInstallInfo -import com.android.launcher3.pm.UserCache import com.android.launcher3.util.PackageUserKey import java.util.function.Consumer @@ -137,17 +134,6 @@ class ModelLauncherCallbacks(private var taskExecutor: Consumer } } - @SuppressLint("NewApi") - override fun onUserConfigChanged(launcherUserInfo: LauncherUserInfo) { - FileLog.d(TAG, "onUserConfigChanged for user ${launcherUserInfo.userType}") - if (android.multiuser.Flags.addLauncherUserConfig()) { - taskExecutor.accept { taskController, _, _ -> - UserCache.INSTANCE.get(taskController.app.context).updateCache() - taskController.app.model.forceReload() - } - } - } - companion object { private const val TAG = "LauncherAppsCallbackImpl" } diff --git a/src/com/android/launcher3/pm/UserCache.java b/src/com/android/launcher3/pm/UserCache.java index 69f4469e02..e8619610a8 100644 --- a/src/com/android/launcher3/pm/UserCache.java +++ b/src/com/android/launcher3/pm/UserCache.java @@ -26,6 +26,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.util.ArrayMap; +import androidx.annotation.AnyThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -110,7 +111,7 @@ public class UserCache implements SafeCloseable { updateCache(); } - @WorkerThread + @AnyThread private void onUsersChanged(Intent intent) { MODEL_EXECUTOR.execute(this::updateCache); UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER); @@ -122,7 +123,7 @@ public class UserCache implements SafeCloseable { } @WorkerThread - public void updateCache() { + private void updateCache() { mUserToSerialMap = ApiWrapper.INSTANCE.get(mContext).queryAllUsers(); mUserToPreInstallAppMap = fetchPreInstallApps(); } diff --git a/src/com/android/launcher3/util/ApiWrapper.java b/src/com/android/launcher3/util/ApiWrapper.java index 35fc9f5d80..467a7ec54f 100644 --- a/src/com/android/launcher3/util/ApiWrapper.java +++ b/src/com/android/launcher3/util/ApiWrapper.java @@ -16,11 +16,8 @@ package com.android.launcher3.util; -import static android.multiuser.Flags.addLauncherUserConfig; - import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_HOME_ROLE; -import android.annotation.SuppressLint; import android.app.ActivityOptions; import android.app.Person; import android.app.role.RoleManager; @@ -28,12 +25,9 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; -import android.content.pm.LauncherApps; -import android.content.pm.LauncherUserInfo; import android.content.pm.ShortcutInfo; import android.graphics.drawable.ColorDrawable; import android.net.Uri; -import android.os.Build; import android.os.UserHandle; import android.os.UserManager; import android.util.ArrayMap; @@ -51,7 +45,6 @@ import com.android.launcher3.dagger.LauncherAppSingleton; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Objects; import javax.inject.Inject; @@ -92,32 +85,22 @@ public class ApiWrapper { /** * Returns a map of all users on the device to their corresponding UI properties */ - @SuppressLint("NewApi") public Map queryAllUsers() { UserManager um = mContext.getSystemService(UserManager.class); Map users = new ArrayMap<>(); List usersActual = um.getUserProfiles(); if (usersActual != null) { for (UserHandle user : usersActual) { + long serial = um.getSerialNumberForUser(user); + + // Simple check to check if the provided user is work profile + // TODO: Migrate to a better platform API NoopDrawable d = new NoopDrawable(); boolean isWork = (d != mContext.getPackageManager().getUserBadgedIcon(d, user)); - UserIconInfo info; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { - LauncherUserInfo userInfo = Objects.requireNonNull( - mContext.getSystemService(LauncherApps.class)).getLauncherUserInfo( - user); - long serial = Objects.requireNonNull(userInfo).getUserSerialNumber(); - info = addLauncherUserConfig() ? new UserIconInfo(user, - isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN, serial, - userInfo.getUserConfig()) : new UserIconInfo(user, - isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN, serial); - } else { - long serial = um.getSerialNumberForUser(user); - // Simple check to check if the provided user is work profile - // TODO: Migrate to a better platform API - info = new UserIconInfo(user, - isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN, serial); - } + UserIconInfo info = new UserIconInfo( + user, + isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN, + serial); users.put(user, info); } } From 8e4cae12584e899e25fd55945adb04114201eb73 Mon Sep 17 00:00:00 2001 From: Gustav Sennton Date: Thu, 14 Nov 2024 15:47:37 +0000 Subject: [PATCH 15/15] Change fallback closing animators for Desktop Mode. The main changes are: 1. the amount to move the window horizontally (much less for Desktop Mode), and 2. the timing for when the alpha animation is applied - we remove the 25ms delay for freeform windows. Bug: 378675987 Test: manual Flag: com.android.window.flags.enable_desktop_windowing_exit_transitions Change-Id: Ieeb6b827eee2e6314ea9c79213cdf401f48d3c85 --- quickstep/res/values/dimens.xml | 1 + .../launcher3/QuickstepTransitionManager.java | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index 782a705bfd..527ddf7d7c 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -118,6 +118,7 @@ 115dp + 36dp 100dp diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 18337d3991..3bf5f3b351 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -108,6 +108,7 @@ import android.view.WindowManager; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; +import android.window.DesktopModeFlags; import android.window.RemoteTransition; import android.window.TransitionFilter; import android.window.WindowAnimationState; @@ -166,11 +167,13 @@ import com.android.systemui.animation.RemoteAnimationRunnerCompat; import com.android.systemui.shared.system.BlurUtils; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.systemui.shared.system.QuickStepContract; +import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; import com.android.wm.shell.startingsurface.IStartingWindowListener; import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -233,6 +236,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener protected final Handler mHandler; private final float mClosingWindowTransY; + private final float mClosingFreeformWindowTransY; private final float mMaxShadowRadius; private final StartingWindowListener mStartingWindowListener = @@ -290,6 +294,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener Resources res = mLauncher.getResources(); mClosingWindowTransY = res.getDimensionPixelSize(R.dimen.closing_window_trans_y); + mClosingFreeformWindowTransY = + res.getDimensionPixelSize(R.dimen.closing_freeform_window_trans_y); mMaxShadowRadius = res.getDimensionPixelSize(R.dimen.max_shadow_radius); mLauncher.addOnDeviceProfileChangeListener(this); @@ -1480,10 +1486,16 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener ? 0 : getWindowCornerRadius(mLauncher); float startShadowRadius = areAllTargetsTranslucent(appTargets) ? 0 : mMaxShadowRadius; closingAnimator.setDuration(duration); + boolean isFreeform = isFreeformAnimation(appTargets); + float translateY = isFreeform ? mClosingFreeformWindowTransY : mClosingWindowTransY; + float endScale = isFreeform ? 0.95f : 1f; + Interpolator alphaInterpolator = isFreeform + ? clampToDuration(LINEAR, 0, 100, duration) + : clampToDuration(LINEAR, 25, 125, duration); closingAnimator.addUpdateListener(new MultiValueUpdateListener() { - FloatProp mDy = new FloatProp(0, mClosingWindowTransY, DECELERATE_1_7); - FloatProp mScale = new FloatProp(1f, 1f, DECELERATE_1_7); - FloatProp mAlpha = new FloatProp(1f, 0f, clampToDuration(LINEAR, 25, 125, duration)); + FloatProp mDy = new FloatProp(0, translateY, DECELERATE_1_7); + FloatProp mScale = new FloatProp(1f, endScale, DECELERATE_1_7); + FloatProp mAlpha = new FloatProp(1f, 0f, alphaInterpolator); FloatProp mShadowRadius = new FloatProp(startShadowRadius, 0, DECELERATE_1_7); @Override @@ -1532,6 +1544,13 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener return closingAnimator; } + private boolean isFreeformAnimation(RemoteAnimationTarget[] appTargets) { + return DesktopModeStatus.canEnterDesktopMode(mLauncher.getApplicationContext()) + && DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS.isTrue() + && Arrays.stream(appTargets) + .anyMatch(app -> app.taskInfo != null && app.taskInfo.isFreeform()); + } + private void addCujInstrumentation(Animator anim, int cuj) { anim.addListener(getCujAnimationSuccessListener(cuj)); }