From b7033ceb76d2b7ec1a13697fea50f5214f1e0e54 Mon Sep 17 00:00:00 2001 From: Ajinkya Chalke Date: Fri, 2 May 2025 00:37:21 +0000 Subject: [PATCH] Limit LauncherTaskbarUIController to primary - Only primary displays should use LauncherTaskbarUIController. - This change is required for overview on connected displays to work. Bug: 362720616 Test: m Flag: com.android.window.flags.enable_taskbar_connected_displays Change-Id: I6945107e6072561b1904dcafd6106d4317eaba1d --- .../launcher3/taskbar/TaskbarManagerImpl.java | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java index cb59ec42c0..0317fa5451 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java @@ -655,7 +655,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { } recreateTaskbars(); - for (Entry entry: mTaskbars.entrySet()) { + for (Entry entry : mTaskbars.entrySet()) { int displayId = entry.getKey(); debugTaskbarManager("onUserUnlocked: addTaskbarRootViewToWindow()", displayId); addTaskbarRootViewToWindow(entry.getValue()); @@ -706,7 +706,8 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { TaskbarActivityContext taskbar = getCurrentActivityContext(); if (taskbar != null) { taskbar.setUIController( - createTaskbarUIControllerForRecentsViewContainer(mRecentsViewContainer)); + createTaskbarUIControllerForRecentsViewContainer(mRecentsViewContainer, + mPrimaryDisplayId)); } } @@ -733,7 +734,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { RecentsViewContainer rvc = OverviewComponentObserver.INSTANCE.get( mBaseContext).getContainerInterface(displayId).getCreatedContainer(); if (rvc instanceof RecentsWindowManager) { - return createTaskbarUIControllerForRecentsViewContainer(rvc); + return createTaskbarUIControllerForRecentsViewContainer(rvc, displayId); } return new TaskbarUIController(); @@ -743,11 +744,15 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { * Creates a {@link TaskbarUIController} to use while the given StatefulActivity is active. */ private TaskbarUIController createTaskbarUIControllerForRecentsViewContainer( - RecentsViewContainer container) { - debugPrimaryTaskbar("createTaskbarUIControllerForRecentsViewContainer"); - if (mActivity instanceof QuickstepLauncher quickstepLauncher) { + RecentsViewContainer container, int displayId) { + debugTaskbarManager("createTaskbarUIControllerForRecentsViewContainer", displayId); + if (!isExternalDisplay(displayId) + && mActivity instanceof QuickstepLauncher quickstepLauncher) { // If 1P Launcher is default, always use LauncherTaskbarUIController, regardless of - // whether the recents container is NexusLauncherActivity or RecentsWindowManager. + // whether the recents container is NexusLauncherActivity or RecentsWindowManager. This + // is only applicable for primary displays. In case of foldables both displays have + // primary display ID and only one of them is primary at a given time, the other one is + // inactive or has limited functionality (has different display ID in that case). return new LauncherTaskbarUIController(quickstepLauncher); } // If a 3P Launcher is default, always use FallbackTaskbarUIController regardless of @@ -758,7 +763,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { if (container instanceof RecentsWindowManager recentsWindowManager) { return new FallbackTaskbarUIController<>(recentsWindowManager); } - return TaskbarUIController.DEFAULT; + return new TaskbarUIController(); } /** @@ -837,7 +842,8 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { taskbar.setUIController(createTaskbarUIControllerForNonDefaultDisplay(displayId)); } else if (mRecentsViewContainer != null) { taskbar.setUIController( - createTaskbarUIControllerForRecentsViewContainer(mRecentsViewContainer)); + createTaskbarUIControllerForRecentsViewContainer(mRecentsViewContainer, + mPrimaryDisplayId)); } if (enableTaskbarNoRecreate()) { @@ -923,7 +929,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { } public void transitionTo(int displayId, @BarTransitions.TransitionMode int barMode, - boolean animate) { + boolean animate) { TaskbarActivityContext taskbar = getTaskbarForDisplay(displayId); if (taskbar != null) { taskbar.transitionTo(barMode, animate); @@ -1306,6 +1312,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { /** * Creates a {@link DeviceProfile} for the given display and adds it to the map. + * * @param displayId The ID of the display. */ private void createExternalDeviceProfile(int displayId) { @@ -1330,6 +1337,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { /** * Gets a {@link DeviceProfile} for the given displayId. + * * @param displayId The ID of the display. */ private @Nullable DeviceProfile getDeviceProfile(int displayId) { @@ -1351,6 +1359,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { /** * Removes the {@link DeviceProfile} associated with the given display ID from the map. + * * @param displayId The ID of the display for which to remove the taskbar. */ private void removeDeviceProfileFromMap(int displayId) { @@ -1711,8 +1720,9 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { /** * Logs debug information about the TaskbarManager for primary display. + * * @param debugReason A string describing the reason for the debug log. - * @param displayId The ID of the display for which to log debug information. + * @param displayId The ID of the display for which to log debug information. */ public void debugTaskbarManager(String debugReason, int displayId) { StringJoiner log = new StringJoiner("\n"); @@ -1723,9 +1733,10 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { /** * Logs verbose debug information about the TaskbarManager for primary display. + * * @param debugReason A string describing the reason for the debug log. - * @param displayId The ID of the display for which to log debug information. - * @param verbose Indicates whether or not to debug with detail. + * @param displayId The ID of the display for which to log debug information. + * @param verbose Indicates whether or not to debug with detail. */ private void debugTaskbarManager(String debugReason, int displayId, boolean verbose) { StringJoiner log = new StringJoiner("\n"); @@ -1739,8 +1750,8 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { /** * Logs debug information about the TaskbarManager for primary display. - * @param debugReason A string describing the reason for the debug log. * + * @param debugReason A string describing the reason for the debug log. */ private void debugPrimaryTaskbar(String debugReason) { debugTaskbarManager(debugReason, mPrimaryDisplayId, false); @@ -1748,8 +1759,8 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { /** * Logs debug information about the TaskbarManager for primary display. - * @param debugReason A string describing the reason for the debug log. * + * @param debugReason A string describing the reason for the debug log. */ public void debugPrimaryTaskbar(String debugReason, boolean verbose) { debugTaskbarManager(debugReason, mPrimaryDisplayId, verbose);