Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyevent/SysUIKeyGestureEventInitializerTest.kt +7 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_SCENE_CONTAINER import com.android.systemui.SysuiTestCase import com.android.systemui.res.R import com.android.systemui.screencapture.domain.interactor.ScreenCaptureKeyboardShortcutInteractor import com.android.systemui.shade.display.StatusBarTouchShadeDisplayPolicy import com.android.systemui.statusbar.CommandQueue import com.google.common.truth.Truth.assertThat Loading @@ -57,6 +58,9 @@ class SysUIKeyGestureEventInitializerTest : SysuiTestCase() { @Mock private lateinit var inputManager: InputManager @Mock private lateinit var commandQueue: CommandQueue @Mock private lateinit var shadeDisplayPolicy: StatusBarTouchShadeDisplayPolicy @Mock private lateinit var screenCaptureKeyboardShortcutInteractor: ScreenCaptureKeyboardShortcutInteractor @Mock private lateinit var resources: Resources @Captor private lateinit var keyGestureEventsCaptor: ArgumentCaptor<List<Int>> @Captor Loading @@ -75,6 +79,7 @@ class SysUIKeyGestureEventInitializerTest : SysuiTestCase() { inputManager, commandQueue, shadeDisplayPolicy, screenCaptureKeyboardShortcutInteractor, ) } Loading Loading @@ -148,7 +153,7 @@ class SysUIKeyGestureEventInitializerTest : SysuiTestCase() { @Test @EnableFlags(com.android.hardware.input.Flags.FLAG_ENABLE_PARTIAL_SCREENSHOT_KEYBOARD_SHORTCUT) fun handleKeyGestureEvent_eventTypeTakePartialScreenshot_opensScreenCaptureUi() { fun handleKeyGestureEvent_eventTypeTakePartialScreenshot_callsScreenCaptureInteractor() { underTest.start() verify(inputManager) .registerKeyGestureEventHandler(any(), keyGestureEventHandlerCaptor.capture()) Loading @@ -160,7 +165,7 @@ class SysUIKeyGestureEventInitializerTest : SysuiTestCase() { /* focusedToken= */ null, ) // TODO(b/420714826) Verify screen capture UI is launched. verify(screenCaptureKeyboardShortcutInteractor).attemptPartialRegionScreenshot() } @Test Loading packages/SystemUI/src/com/android/systemui/keyevent/SysUIKeyGestureEventInitializer.kt +3 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.res.R import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.screencapture.domain.interactor.ScreenCaptureKeyboardShortcutInteractor import com.android.systemui.shade.display.StatusBarTouchShadeDisplayPolicy import com.android.systemui.statusbar.CommandQueue import com.android.window.flags.Flags.enableKeyGestureHandlerForSysui Loading @@ -49,6 +50,7 @@ constructor( private val inputManager: InputManager, private val commandQueue: CommandQueue, private val shadeDisplayPolicy: StatusBarTouchShadeDisplayPolicy, private val screenCaptureKeyboardShortcutInteractor: ScreenCaptureKeyboardShortcutInteractor, ) : CoreStartable { override fun start() { registerKeyGestureEventHandlers() Loading @@ -74,7 +76,7 @@ constructor( inputManager.registerKeyGestureEventHandler(supportedGestures) { event, _ -> when (event.keyGestureType) { KEY_GESTURE_TYPE_TAKE_PARTIAL_SCREENSHOT -> { // TODO(b/420714826) Launch pre-capture UI for partial screenshots. screenCaptureKeyboardShortcutInteractor.attemptPartialRegionScreenshot() } KEY_GESTURE_TYPE_TOGGLE_NOTIFICATION_PANEL -> { shadeDisplayPolicy.onNotificationPanelKeyboardShortcut() Loading packages/SystemUI/src/com/android/systemui/screencapture/common/shared/model/ScreenCaptureUiParameters.kt +5 −5 Original line number Diff line number Diff line Loading @@ -22,9 +22,9 @@ import android.os.UserHandle data class ScreenCaptureUiParameters( val screenCaptureType: ScreenCaptureType, val isUserConsentRequired: Boolean, val resultReceiver: ResultReceiver?, val mediaProjection: IBinder?, val hostAppUserHandle: UserHandle, val hostAppUid: Int, val isUserConsentRequired: Boolean = false, val resultReceiver: ResultReceiver? = null, val mediaProjection: IBinder? = null, val hostAppUserHandle: UserHandle = UserHandle.CURRENT, val hostAppUid: Int = 0, ) packages/SystemUI/src/com/android/systemui/screencapture/domain/interactor/ScreenCaptureKeyboardShortcutInteractor.kt 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.screencapture.domain.interactor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.screencapture.common.shared.model.ScreenCaptureType import com.android.systemui.screencapture.common.shared.model.ScreenCaptureUiParameters import com.android.systemui.screencapture.record.domain.interactor.ScreenCaptureRecordFeaturesInteractor import javax.inject.Inject /** Handles the resulting actions of screen capture related keyboard shortcuts. */ @SysUISingleton class ScreenCaptureKeyboardShortcutInteractor @Inject constructor(private val screenCaptureUiInteractor: ScreenCaptureUiInteractor) { fun attemptPartialRegionScreenshot() { // TODO(b/420714826) Check if the large-screen screen capture UI is supported on this device // device's display (i.e. the focused display or external display). If not supported, // default to taking a fullscreen screenshot. if (ScreenCaptureRecordFeaturesInteractor.isLargeScreenScreencaptureEnabled) { screenCaptureUiInteractor.show( ScreenCaptureUiParameters(screenCaptureType = ScreenCaptureType.RECORD) ) } } } packages/SystemUI/src/com/android/systemui/screencapture/record/domain/interactor/ScreenCaptureRecordFeaturesInteractor.kt +5 −2 Original line number Diff line number Diff line Loading @@ -26,8 +26,11 @@ object ScreenCaptureRecordFeaturesInteractor { get() = Flags.newScreenRecordToolbar() val isLargeScreenScreencaptureEnabled: Boolean get() = Flags.largeScreenScreencapture() && Flags.largeScreenRecording() get() = Flags.largeScreenScreencapture() val isLargeScreenRecordingEnabled: Boolean get() = isLargeScreenScreencaptureEnabled && Flags.largeScreenRecording() val shouldShowNewToolbar: Boolean get() = isNewScreenRecordToolbarEnabled || isLargeScreenScreencaptureEnabled get() = isNewScreenRecordToolbarEnabled || isLargeScreenRecordingEnabled } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyevent/SysUIKeyGestureEventInitializerTest.kt +7 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.test.filters.SmallTest import com.android.systemui.Flags.FLAG_SCENE_CONTAINER import com.android.systemui.SysuiTestCase import com.android.systemui.res.R import com.android.systemui.screencapture.domain.interactor.ScreenCaptureKeyboardShortcutInteractor import com.android.systemui.shade.display.StatusBarTouchShadeDisplayPolicy import com.android.systemui.statusbar.CommandQueue import com.google.common.truth.Truth.assertThat Loading @@ -57,6 +58,9 @@ class SysUIKeyGestureEventInitializerTest : SysuiTestCase() { @Mock private lateinit var inputManager: InputManager @Mock private lateinit var commandQueue: CommandQueue @Mock private lateinit var shadeDisplayPolicy: StatusBarTouchShadeDisplayPolicy @Mock private lateinit var screenCaptureKeyboardShortcutInteractor: ScreenCaptureKeyboardShortcutInteractor @Mock private lateinit var resources: Resources @Captor private lateinit var keyGestureEventsCaptor: ArgumentCaptor<List<Int>> @Captor Loading @@ -75,6 +79,7 @@ class SysUIKeyGestureEventInitializerTest : SysuiTestCase() { inputManager, commandQueue, shadeDisplayPolicy, screenCaptureKeyboardShortcutInteractor, ) } Loading Loading @@ -148,7 +153,7 @@ class SysUIKeyGestureEventInitializerTest : SysuiTestCase() { @Test @EnableFlags(com.android.hardware.input.Flags.FLAG_ENABLE_PARTIAL_SCREENSHOT_KEYBOARD_SHORTCUT) fun handleKeyGestureEvent_eventTypeTakePartialScreenshot_opensScreenCaptureUi() { fun handleKeyGestureEvent_eventTypeTakePartialScreenshot_callsScreenCaptureInteractor() { underTest.start() verify(inputManager) .registerKeyGestureEventHandler(any(), keyGestureEventHandlerCaptor.capture()) Loading @@ -160,7 +165,7 @@ class SysUIKeyGestureEventInitializerTest : SysuiTestCase() { /* focusedToken= */ null, ) // TODO(b/420714826) Verify screen capture UI is launched. verify(screenCaptureKeyboardShortcutInteractor).attemptPartialRegionScreenshot() } @Test Loading
packages/SystemUI/src/com/android/systemui/keyevent/SysUIKeyGestureEventInitializer.kt +3 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.res.R import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.screencapture.domain.interactor.ScreenCaptureKeyboardShortcutInteractor import com.android.systemui.shade.display.StatusBarTouchShadeDisplayPolicy import com.android.systemui.statusbar.CommandQueue import com.android.window.flags.Flags.enableKeyGestureHandlerForSysui Loading @@ -49,6 +50,7 @@ constructor( private val inputManager: InputManager, private val commandQueue: CommandQueue, private val shadeDisplayPolicy: StatusBarTouchShadeDisplayPolicy, private val screenCaptureKeyboardShortcutInteractor: ScreenCaptureKeyboardShortcutInteractor, ) : CoreStartable { override fun start() { registerKeyGestureEventHandlers() Loading @@ -74,7 +76,7 @@ constructor( inputManager.registerKeyGestureEventHandler(supportedGestures) { event, _ -> when (event.keyGestureType) { KEY_GESTURE_TYPE_TAKE_PARTIAL_SCREENSHOT -> { // TODO(b/420714826) Launch pre-capture UI for partial screenshots. screenCaptureKeyboardShortcutInteractor.attemptPartialRegionScreenshot() } KEY_GESTURE_TYPE_TOGGLE_NOTIFICATION_PANEL -> { shadeDisplayPolicy.onNotificationPanelKeyboardShortcut() Loading
packages/SystemUI/src/com/android/systemui/screencapture/common/shared/model/ScreenCaptureUiParameters.kt +5 −5 Original line number Diff line number Diff line Loading @@ -22,9 +22,9 @@ import android.os.UserHandle data class ScreenCaptureUiParameters( val screenCaptureType: ScreenCaptureType, val isUserConsentRequired: Boolean, val resultReceiver: ResultReceiver?, val mediaProjection: IBinder?, val hostAppUserHandle: UserHandle, val hostAppUid: Int, val isUserConsentRequired: Boolean = false, val resultReceiver: ResultReceiver? = null, val mediaProjection: IBinder? = null, val hostAppUserHandle: UserHandle = UserHandle.CURRENT, val hostAppUid: Int = 0, )
packages/SystemUI/src/com/android/systemui/screencapture/domain/interactor/ScreenCaptureKeyboardShortcutInteractor.kt 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.screencapture.domain.interactor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.screencapture.common.shared.model.ScreenCaptureType import com.android.systemui.screencapture.common.shared.model.ScreenCaptureUiParameters import com.android.systemui.screencapture.record.domain.interactor.ScreenCaptureRecordFeaturesInteractor import javax.inject.Inject /** Handles the resulting actions of screen capture related keyboard shortcuts. */ @SysUISingleton class ScreenCaptureKeyboardShortcutInteractor @Inject constructor(private val screenCaptureUiInteractor: ScreenCaptureUiInteractor) { fun attemptPartialRegionScreenshot() { // TODO(b/420714826) Check if the large-screen screen capture UI is supported on this device // device's display (i.e. the focused display or external display). If not supported, // default to taking a fullscreen screenshot. if (ScreenCaptureRecordFeaturesInteractor.isLargeScreenScreencaptureEnabled) { screenCaptureUiInteractor.show( ScreenCaptureUiParameters(screenCaptureType = ScreenCaptureType.RECORD) ) } } }
packages/SystemUI/src/com/android/systemui/screencapture/record/domain/interactor/ScreenCaptureRecordFeaturesInteractor.kt +5 −2 Original line number Diff line number Diff line Loading @@ -26,8 +26,11 @@ object ScreenCaptureRecordFeaturesInteractor { get() = Flags.newScreenRecordToolbar() val isLargeScreenScreencaptureEnabled: Boolean get() = Flags.largeScreenScreencapture() && Flags.largeScreenRecording() get() = Flags.largeScreenScreencapture() val isLargeScreenRecordingEnabled: Boolean get() = isLargeScreenScreencaptureEnabled && Flags.largeScreenRecording() val shouldShowNewToolbar: Boolean get() = isNewScreenRecordToolbarEnabled || isLargeScreenScreencaptureEnabled get() = isNewScreenRecordToolbarEnabled || isLargeScreenRecordingEnabled }