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
This commit is contained in:
Ajinkya Chalke committed 2025-05-02 00:37:21 +00:00
1 parent d616551419
commit b7033ceb76
1 file changed
+26 -15
@@ -655,7 +655,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener {
}
recreateTaskbars();
for (Entry<Integer, TaskbarActivityContext> entry: mTaskbars.entrySet()) {
for (Entry<Integer, TaskbarActivityContext> 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);