Loading packages/SystemUI/src/com/android/systemui/screenshot/TakeScreenshotExecutor.kt +3 −3 Original line number Diff line number Diff line Loading @@ -202,10 +202,10 @@ constructor( // Return the single display to be screenshot based upon the request. private suspend fun getDisplayToScreenshot(screenshotRequest: ScreenshotRequest): Display { return when (screenshotRequest.source) { // TODO(b/367394043): Overview requests should use a display ID provided in // ScreenshotRequest. ScreenshotSource.SCREENSHOT_OVERVIEW -> displayRepository.getDisplay(Display.DEFAULT_DISPLAY) // Show on the display where overview was shown if available. displayRepository.getDisplay(screenshotRequest.displayId) ?: displayRepository.getDisplay(Display.DEFAULT_DISPLAY) ?: error("Can't find default display") // Key chord and vendor gesture occur on the device itself, so screenshot the device's Loading packages/SystemUI/tests/src/com/android/systemui/screenshot/TakeScreenshotExecutorTest.kt +59 −2 Original line number Diff line number Diff line Loading @@ -256,6 +256,58 @@ class TakeScreenshotExecutorTest : SysuiTestCase() { screenshotExecutor.onDestroy() } @Test @EnableFlags(Flags.FLAG_SCREENSHOT_MULTIDISPLAY_FOCUS_CHANGE) fun executeScreenshots_fromOverview_honorsDisplay() = testScope.runTest { val displayId = 1 setDisplays(display(TYPE_INTERNAL, id = 0), display(TYPE_EXTERNAL, id = displayId)) val onSaved = { _: Uri? -> } screenshotExecutor.executeScreenshots( createScreenshotRequest( displayId = displayId, source = WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW, ), onSaved, callback, ) val dataCaptor = ArgumentCaptor<ScreenshotData>() verify(controller).handleScreenshot(dataCaptor.capture(), any(), any()) assertThat(dataCaptor.value.displayId).isEqualTo(displayId) screenshotExecutor.onDestroy() } @Test @EnableFlags(Flags.FLAG_SCREENSHOT_MULTIDISPLAY_FOCUS_CHANGE) fun executeScreenshots_fromOverviewInvalidDisplay_usesDefault() = testScope.runTest { setDisplays( display(TYPE_INTERNAL, id = Display.DEFAULT_DISPLAY), display(TYPE_EXTERNAL, id = 1), ) val onSaved = { _: Uri? -> } screenshotExecutor.executeScreenshots( createScreenshotRequest( displayId = 5, source = WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW, ), onSaved, callback, ) val dataCaptor = ArgumentCaptor<ScreenshotData>() verify(controller).handleScreenshot(dataCaptor.capture(), any(), any()) assertThat(dataCaptor.value.displayId).isEqualTo(Display.DEFAULT_DISPLAY) screenshotExecutor.onDestroy() } @Test fun onDestroy_propagatedToControllers() = testScope.runTest { Loading Loading @@ -527,9 +579,14 @@ class TakeScreenshotExecutorTest : SysuiTestCase() { runCurrent() } private fun createScreenshotRequest(type: Int = WindowManager.TAKE_SCREENSHOT_FULLSCREEN) = ScreenshotRequest.Builder(type, WindowManager.ScreenshotSource.SCREENSHOT_KEY_OTHER) private fun createScreenshotRequest( type: Int = WindowManager.TAKE_SCREENSHOT_FULLSCREEN, source: Int = WindowManager.ScreenshotSource.SCREENSHOT_KEY_OTHER, displayId: Int = Display.DEFAULT_DISPLAY, ) = ScreenshotRequest.Builder(type, source) .setTopComponent(topComponent) .setDisplayId(displayId) .also { if (type == TAKE_SCREENSHOT_PROVIDED_IMAGE) { it.setBitmap(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888)) Loading Loading
packages/SystemUI/src/com/android/systemui/screenshot/TakeScreenshotExecutor.kt +3 −3 Original line number Diff line number Diff line Loading @@ -202,10 +202,10 @@ constructor( // Return the single display to be screenshot based upon the request. private suspend fun getDisplayToScreenshot(screenshotRequest: ScreenshotRequest): Display { return when (screenshotRequest.source) { // TODO(b/367394043): Overview requests should use a display ID provided in // ScreenshotRequest. ScreenshotSource.SCREENSHOT_OVERVIEW -> displayRepository.getDisplay(Display.DEFAULT_DISPLAY) // Show on the display where overview was shown if available. displayRepository.getDisplay(screenshotRequest.displayId) ?: displayRepository.getDisplay(Display.DEFAULT_DISPLAY) ?: error("Can't find default display") // Key chord and vendor gesture occur on the device itself, so screenshot the device's Loading
packages/SystemUI/tests/src/com/android/systemui/screenshot/TakeScreenshotExecutorTest.kt +59 −2 Original line number Diff line number Diff line Loading @@ -256,6 +256,58 @@ class TakeScreenshotExecutorTest : SysuiTestCase() { screenshotExecutor.onDestroy() } @Test @EnableFlags(Flags.FLAG_SCREENSHOT_MULTIDISPLAY_FOCUS_CHANGE) fun executeScreenshots_fromOverview_honorsDisplay() = testScope.runTest { val displayId = 1 setDisplays(display(TYPE_INTERNAL, id = 0), display(TYPE_EXTERNAL, id = displayId)) val onSaved = { _: Uri? -> } screenshotExecutor.executeScreenshots( createScreenshotRequest( displayId = displayId, source = WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW, ), onSaved, callback, ) val dataCaptor = ArgumentCaptor<ScreenshotData>() verify(controller).handleScreenshot(dataCaptor.capture(), any(), any()) assertThat(dataCaptor.value.displayId).isEqualTo(displayId) screenshotExecutor.onDestroy() } @Test @EnableFlags(Flags.FLAG_SCREENSHOT_MULTIDISPLAY_FOCUS_CHANGE) fun executeScreenshots_fromOverviewInvalidDisplay_usesDefault() = testScope.runTest { setDisplays( display(TYPE_INTERNAL, id = Display.DEFAULT_DISPLAY), display(TYPE_EXTERNAL, id = 1), ) val onSaved = { _: Uri? -> } screenshotExecutor.executeScreenshots( createScreenshotRequest( displayId = 5, source = WindowManager.ScreenshotSource.SCREENSHOT_OVERVIEW, ), onSaved, callback, ) val dataCaptor = ArgumentCaptor<ScreenshotData>() verify(controller).handleScreenshot(dataCaptor.capture(), any(), any()) assertThat(dataCaptor.value.displayId).isEqualTo(Display.DEFAULT_DISPLAY) screenshotExecutor.onDestroy() } @Test fun onDestroy_propagatedToControllers() = testScope.runTest { Loading Loading @@ -527,9 +579,14 @@ class TakeScreenshotExecutorTest : SysuiTestCase() { runCurrent() } private fun createScreenshotRequest(type: Int = WindowManager.TAKE_SCREENSHOT_FULLSCREEN) = ScreenshotRequest.Builder(type, WindowManager.ScreenshotSource.SCREENSHOT_KEY_OTHER) private fun createScreenshotRequest( type: Int = WindowManager.TAKE_SCREENSHOT_FULLSCREEN, source: Int = WindowManager.ScreenshotSource.SCREENSHOT_KEY_OTHER, displayId: Int = Display.DEFAULT_DISPLAY, ) = ScreenshotRequest.Builder(type, source) .setTopComponent(topComponent) .setDisplayId(displayId) .also { if (type == TAKE_SCREENSHOT_PROVIDED_IMAGE) { it.setBitmap(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888)) Loading