Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/multiinstance/ManageWindowsViewContainer.kt +6 −4 Original line number Diff line number Diff line Loading @@ -48,11 +48,13 @@ abstract class ManageWindowsViewContainer( lateinit var menuView: ManageWindowsView /** Creates the base menu view and fills it with icon views. */ fun createMenu(snapshotList: List<Pair<Int, TaskSnapshot>>, fun createMenu(snapshotList: List<Pair<Int, TaskSnapshot?>>, onIconClickListener: ((Int) -> Unit), onOutsideClickListener: (() -> Unit)): ManageWindowsView { val bitmapList = snapshotList.map { (index, snapshot) -> index to Bitmap.wrapHardwareBuffer(snapshot.hardwareBuffer, snapshot.colorSpace) val bitmapList = snapshotList .filter { it.second != null } .map { (index, snapshot) -> index to Bitmap.wrapHardwareBuffer(snapshot!!.hardwareBuffer, snapshot.colorSpace) } return createAndShowMenuView( bitmapList, Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopHandleManageWindowsMenu.kt +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ class DesktopHandleManageWindowsMenu( private val captionWidth: Int, private val windowManagerWrapper: WindowManagerWrapper, context: Context, snapshotList: List<Pair<Int, TaskSnapshot>>, snapshotList: List<Pair<Int, TaskSnapshot?>>, onIconClickListener: ((Int) -> Unit), onOutsideClickListener: (() -> Unit) ) : ManageWindowsViewContainer( Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopHeaderManageWindowsMenu.kt +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ class DesktopHeaderManageWindowsMenu( private val desktopUserRepositories: DesktopUserRepositories, private val surfaceControlBuilderSupplier: Supplier<SurfaceControl.Builder>, private val surfaceControlTransactionSupplier: Supplier<SurfaceControl.Transaction>, snapshotList: List<Pair<Int, TaskSnapshot>>, snapshotList: List<Pair<Int, TaskSnapshot?>>, onIconClickListener: ((Int) -> Unit), onOutsideClickListener: (() -> Unit) ) : ManageWindowsViewContainer( Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopHeaderManageWindowsMenuTest.kt +26 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.platform.test.annotations.EnableFlags import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.view.SurfaceControl import android.window.TaskSnapshot import androidx.test.filters.SmallTest import com.android.window.flags.Flags import com.android.wm.shell.MockToken Loading @@ -33,6 +34,7 @@ import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalSystemViewContainer import com.google.common.truth.Truth.assertThat import org.junit.After import org.junit.Assert.fail import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -84,7 +86,29 @@ class DesktopHeaderManageWindowsMenuTest : ShellTestCase() { assertThat(menu.menuViewContainer).isInstanceOf(AdditionalSystemViewContainer::class.java) } private fun createMenu(task: RunningTaskInfo) = DesktopHeaderManageWindowsMenu( @Test @EnableFlags(Flags.FLAG_ENABLE_FULLY_IMMERSIVE_IN_DESKTOP) fun testShow_nullSnapshotDoesNotCauseNPE() { val task = createFreeformTask() val snapshotList = listOf(Pair(/* index = */ 1, /* snapshot = */ null)) // Set as immersive so that menu is created as system view container (simpler of the // options) userRepositories.getProfile(DEFAULT_USER_ID).setTaskInFullImmersiveState( displayId = task.displayId, taskId = task.taskId, immersive = true ) try { menu = createMenu(task, snapshotList) } catch (e: NullPointerException) { fail("Null snapshot should not have thrown null pointer exception") } } private fun createMenu( task: RunningTaskInfo, snapshotList: List<Pair<Int, TaskSnapshot?>> = emptyList() ) = DesktopHeaderManageWindowsMenu( callerTaskInfo = task, x = 0, y = 0, Loading @@ -94,7 +118,7 @@ class DesktopHeaderManageWindowsMenuTest : ShellTestCase() { desktopUserRepositories = userRepositories, surfaceControlBuilderSupplier = { SurfaceControl.Builder() }, surfaceControlTransactionSupplier = { SurfaceControl.Transaction() }, snapshotList = emptyList(), snapshotList = snapshotList, onIconClickListener = {}, onOutsideClickListener = {}, ) Loading Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/multiinstance/ManageWindowsViewContainer.kt +6 −4 Original line number Diff line number Diff line Loading @@ -48,11 +48,13 @@ abstract class ManageWindowsViewContainer( lateinit var menuView: ManageWindowsView /** Creates the base menu view and fills it with icon views. */ fun createMenu(snapshotList: List<Pair<Int, TaskSnapshot>>, fun createMenu(snapshotList: List<Pair<Int, TaskSnapshot?>>, onIconClickListener: ((Int) -> Unit), onOutsideClickListener: (() -> Unit)): ManageWindowsView { val bitmapList = snapshotList.map { (index, snapshot) -> index to Bitmap.wrapHardwareBuffer(snapshot.hardwareBuffer, snapshot.colorSpace) val bitmapList = snapshotList .filter { it.second != null } .map { (index, snapshot) -> index to Bitmap.wrapHardwareBuffer(snapshot!!.hardwareBuffer, snapshot.colorSpace) } return createAndShowMenuView( bitmapList, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopHandleManageWindowsMenu.kt +1 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ class DesktopHandleManageWindowsMenu( private val captionWidth: Int, private val windowManagerWrapper: WindowManagerWrapper, context: Context, snapshotList: List<Pair<Int, TaskSnapshot>>, snapshotList: List<Pair<Int, TaskSnapshot?>>, onIconClickListener: ((Int) -> Unit), onOutsideClickListener: (() -> Unit) ) : ManageWindowsViewContainer( Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopHeaderManageWindowsMenu.kt +1 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ class DesktopHeaderManageWindowsMenu( private val desktopUserRepositories: DesktopUserRepositories, private val surfaceControlBuilderSupplier: Supplier<SurfaceControl.Builder>, private val surfaceControlTransactionSupplier: Supplier<SurfaceControl.Transaction>, snapshotList: List<Pair<Int, TaskSnapshot>>, snapshotList: List<Pair<Int, TaskSnapshot?>>, onIconClickListener: ((Int) -> Unit), onOutsideClickListener: (() -> Unit) ) : ManageWindowsViewContainer( Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopHeaderManageWindowsMenuTest.kt +26 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.platform.test.annotations.EnableFlags import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.view.SurfaceControl import android.window.TaskSnapshot import androidx.test.filters.SmallTest import com.android.window.flags.Flags import com.android.wm.shell.MockToken Loading @@ -33,6 +34,7 @@ import com.android.wm.shell.sysui.ShellInit import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalSystemViewContainer import com.google.common.truth.Truth.assertThat import org.junit.After import org.junit.Assert.fail import org.junit.Before import org.junit.Test import org.junit.runner.RunWith Loading Loading @@ -84,7 +86,29 @@ class DesktopHeaderManageWindowsMenuTest : ShellTestCase() { assertThat(menu.menuViewContainer).isInstanceOf(AdditionalSystemViewContainer::class.java) } private fun createMenu(task: RunningTaskInfo) = DesktopHeaderManageWindowsMenu( @Test @EnableFlags(Flags.FLAG_ENABLE_FULLY_IMMERSIVE_IN_DESKTOP) fun testShow_nullSnapshotDoesNotCauseNPE() { val task = createFreeformTask() val snapshotList = listOf(Pair(/* index = */ 1, /* snapshot = */ null)) // Set as immersive so that menu is created as system view container (simpler of the // options) userRepositories.getProfile(DEFAULT_USER_ID).setTaskInFullImmersiveState( displayId = task.displayId, taskId = task.taskId, immersive = true ) try { menu = createMenu(task, snapshotList) } catch (e: NullPointerException) { fail("Null snapshot should not have thrown null pointer exception") } } private fun createMenu( task: RunningTaskInfo, snapshotList: List<Pair<Int, TaskSnapshot?>> = emptyList() ) = DesktopHeaderManageWindowsMenu( callerTaskInfo = task, x = 0, y = 0, Loading @@ -94,7 +118,7 @@ class DesktopHeaderManageWindowsMenuTest : ShellTestCase() { desktopUserRepositories = userRepositories, surfaceControlBuilderSupplier = { SurfaceControl.Builder() }, surfaceControlTransactionSupplier = { SurfaceControl.Transaction() }, snapshotList = emptyList(), snapshotList = snapshotList, onIconClickListener = {}, onOutsideClickListener = {}, ) Loading