Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +1 −1 Original line number Diff line number Diff line Loading @@ -1028,7 +1028,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, @Override public void onDeskActivated(int deskId, int displayId) { if (!mDesktopTilingDecorViewModel.onDeskActivated(deskId)) { if (mDesktopTilingDecorViewModel.tilingDeskActive(deskId)) { return; } final DesktopRepository repository = mDesktopUserRepositories.getCurrent(); Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt +28 −30 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.ActivityManager import android.app.ActivityManager.RunningTaskInfo import android.content.Context import android.graphics.Rect import android.util.ArraySet import android.util.SparseArray import android.window.DisplayAreaInfo import android.window.WindowContainerTransaction Loading Loading @@ -80,7 +79,6 @@ class DesktopTilingDecorViewModel( @VisibleForTesting var tilingHandlerByUserAndDeskId = SparseArray<SparseArray<DesktopTilingWindowDecoration>>() var currentUserId: Int = -1 val disconnectedDisplayDesks = ArraySet<Int>() init { // TODO(b/374309287): Move this interface implementation to Loading Loading @@ -200,7 +198,6 @@ class DesktopTilingDecorViewModel( if (disconnectedDisplayId == handler.displayId) { handler.resetTilingSession(shouldPersistTilingData = true) desksToRemove.add(desk) disconnectedDisplayDesks.add(desk) } } desksToRemove.forEach { desk -> userHandlerList.remove(desk) } Loading Loading @@ -279,9 +276,10 @@ class DesktopTilingDecorViewModel( tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId)?.hideDividerBar() } /** Removes [deskId] from the previously deactivated desks to mark it's activation. */ fun onDeskActivated(deskId: Int): Boolean = disconnectedDisplayDesks.remove(deskId) || !tilingHandlerByUserAndDeskId.contains(deskId) /** Returns whether [deskId] already exists and active or needs initialization. */ fun tilingDeskActive(deskId: Int): Boolean = tilingHandlerByUserAndDeskId[currentUserId]?.contains(deskId) ?: false /** Destroys a tiling session for a removed desk. */ fun onDeskRemoved(deskId: Int) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModelTest.kt +18 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.wm.shell.transition.Transitions import com.android.wm.shell.windowdecor.WindowDecorationWrapper import com.android.wm.shell.windowdecor.common.WindowDecorTaskResourceLoader import com.google.common.truth.Truth.assertThat import junit.framework.Assert.assertEquals import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.MainCoroutineDispatcher import org.junit.Before Loading Loading @@ -303,6 +304,23 @@ class DesktopTilingDecorViewModelTest : ShellTestCase() { verify(desktopTilingDecoration2, times(1)).resetTilingSession(true) } @Test fun onDeskActivated_ReturnsTrueIfDeskExistsFalseOtherwise() { desktopTilingDecorViewModel.onUserChange(1) val decorationByDeskId = SparseArray<DesktopTilingWindowDecoration>() decorationByDeskId.put(1, desktopTilingDecoration) whenever(desktopTilingDecoration.displayId).thenReturn(1) desktopTilingDecorViewModel.tilingHandlerByUserAndDeskId.put(1, decorationByDeskId) assertEquals(true, desktopTilingDecorViewModel.tilingDeskActive(1)) desktopTilingDecorViewModel.onDisplayDisconnected( disconnectedDisplayId = 1, ) assertEquals(desktopTilingDecorViewModel.tilingDeskActive(1), false) } @Test fun moveTaskToFront_shouldRoute_toCorrectTilingDecoration() { val decorationByDisplayId = SparseArray<DesktopTilingWindowDecoration>() Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +1 −1 Original line number Diff line number Diff line Loading @@ -1028,7 +1028,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, @Override public void onDeskActivated(int deskId, int displayId) { if (!mDesktopTilingDecorViewModel.onDeskActivated(deskId)) { if (mDesktopTilingDecorViewModel.tilingDeskActive(deskId)) { return; } final DesktopRepository repository = mDesktopUserRepositories.getCurrent(); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModel.kt +28 −30 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.ActivityManager import android.app.ActivityManager.RunningTaskInfo import android.content.Context import android.graphics.Rect import android.util.ArraySet import android.util.SparseArray import android.window.DisplayAreaInfo import android.window.WindowContainerTransaction Loading Loading @@ -80,7 +79,6 @@ class DesktopTilingDecorViewModel( @VisibleForTesting var tilingHandlerByUserAndDeskId = SparseArray<SparseArray<DesktopTilingWindowDecoration>>() var currentUserId: Int = -1 val disconnectedDisplayDesks = ArraySet<Int>() init { // TODO(b/374309287): Move this interface implementation to Loading Loading @@ -200,7 +198,6 @@ class DesktopTilingDecorViewModel( if (disconnectedDisplayId == handler.displayId) { handler.resetTilingSession(shouldPersistTilingData = true) desksToRemove.add(desk) disconnectedDisplayDesks.add(desk) } } desksToRemove.forEach { desk -> userHandlerList.remove(desk) } Loading Loading @@ -279,9 +276,10 @@ class DesktopTilingDecorViewModel( tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId)?.hideDividerBar() } /** Removes [deskId] from the previously deactivated desks to mark it's activation. */ fun onDeskActivated(deskId: Int): Boolean = disconnectedDisplayDesks.remove(deskId) || !tilingHandlerByUserAndDeskId.contains(deskId) /** Returns whether [deskId] already exists and active or needs initialization. */ fun tilingDeskActive(deskId: Int): Boolean = tilingHandlerByUserAndDeskId[currentUserId]?.contains(deskId) ?: false /** Destroys a tiling session for a removed desk. */ fun onDeskRemoved(deskId: Int) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/tiling/DesktopTilingDecorViewModelTest.kt +18 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import com.android.wm.shell.transition.Transitions import com.android.wm.shell.windowdecor.WindowDecorationWrapper import com.android.wm.shell.windowdecor.common.WindowDecorTaskResourceLoader import com.google.common.truth.Truth.assertThat import junit.framework.Assert.assertEquals import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.MainCoroutineDispatcher import org.junit.Before Loading Loading @@ -303,6 +304,23 @@ class DesktopTilingDecorViewModelTest : ShellTestCase() { verify(desktopTilingDecoration2, times(1)).resetTilingSession(true) } @Test fun onDeskActivated_ReturnsTrueIfDeskExistsFalseOtherwise() { desktopTilingDecorViewModel.onUserChange(1) val decorationByDeskId = SparseArray<DesktopTilingWindowDecoration>() decorationByDeskId.put(1, desktopTilingDecoration) whenever(desktopTilingDecoration.displayId).thenReturn(1) desktopTilingDecorViewModel.tilingHandlerByUserAndDeskId.put(1, decorationByDeskId) assertEquals(true, desktopTilingDecorViewModel.tilingDeskActive(1)) desktopTilingDecorViewModel.onDisplayDisconnected( disconnectedDisplayId = 1, ) assertEquals(desktopTilingDecorViewModel.tilingDeskActive(1), false) } @Test fun moveTaskToFront_shouldRoute_toCorrectTilingDecoration() { val decorationByDisplayId = SparseArray<DesktopTilingWindowDecoration>() Loading