Add a desktop mode API to hide stashed apps

Allows launcher to cancel selecting desktop app to be launched and hide
the stashed apps.

Bug: 261234402
Test: atest DesktopTasksControllerTest
Change-Id: I2708267011aca5b1c933dbf0172547ba1936c2ab
This commit is contained in:
Ats Jenk
2023-05-16 15:45:33 -07:00
parent 7713260e9f
commit e0c5e57500
4 changed files with 38 additions and 0 deletions

View File

@@ -514,6 +514,11 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
// Stashing of desktop apps not needed. Apps always launch on desktop
}
@Override
public void hideStashedDesktopApps(int displayId) throws RemoteException {
// Stashing of desktop apps not needed. Apps always launch on desktop
}
@Override
public void setTaskListener(IDesktopTaskListener listener) throws RemoteException {
// TODO(b/261234402): move visibility from sysui state to listener

View File

@@ -131,6 +131,18 @@ class DesktopTasksController(
desktopModeTaskRepository.setStashed(displayId, true)
}
/**
* Clear the stashed state for the given display
*/
fun hideStashedDesktopApps(displayId: Int) {
KtProtoLog.v(
WM_SHELL_DESKTOP_MODE,
"DesktopTasksController: hideStashedApps displayId=%d",
displayId
)
desktopModeTaskRepository.setStashed(displayId, false)
}
/** Get number of tasks that are marked as visible */
fun getVisibleTaskCount(displayId: Int): Int {
return desktopModeTaskRepository.getVisibleTaskCount(displayId)
@@ -753,6 +765,13 @@ class DesktopTasksController(
) { c -> c.stashDesktopApps(displayId) }
}
override fun hideStashedDesktopApps(displayId: Int) {
ExecutorUtils.executeRemoteCallWithTaskPermission(
controller,
"hideStashedDesktopApps"
) { c -> c.hideStashedDesktopApps(displayId) }
}
override fun getVisibleTaskCount(displayId: Int): Int {
val result = IntArray(1)
ExecutorUtils.executeRemoteCallWithTaskPermission(

View File

@@ -29,6 +29,9 @@ interface IDesktopMode {
/** Stash apps on the desktop to allow launching another app from home screen */
void stashDesktopApps(int displayId);
/** Hide apps that may be stashed */
void hideStashedDesktopApps(int displayId);
/** Get count of visible desktop tasks on the given display */
int getVisibleTaskCount(int displayId);

View File

@@ -587,6 +587,17 @@ class DesktopTasksControllerTest : ShellTestCase() {
assertThat(desktopModeTaskRepository.isStashed(SECOND_DISPLAY)).isFalse()
}
@Test
fun hideStashedDesktopApps_stateUpdates() {
desktopModeTaskRepository.setStashed(DEFAULT_DISPLAY, true)
desktopModeTaskRepository.setStashed(SECOND_DISPLAY, true)
controller.hideStashedDesktopApps(DEFAULT_DISPLAY)
assertThat(desktopModeTaskRepository.isStashed(DEFAULT_DISPLAY)).isFalse()
// Check that second display is not affected
assertThat(desktopModeTaskRepository.isStashed(SECOND_DISPLAY)).isTrue()
}
private fun setUpFreeformTask(displayId: Int = DEFAULT_DISPLAY): RunningTaskInfo {
val task = createFreeformTask(displayId)
whenever(shellTaskOrganizer.getRunningTaskInfo(task.taskId)).thenReturn(task)