Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit faf025ec authored by Wes Okuhara's avatar Wes Okuhara Committed by Android (Google) Code Review
Browse files

Merge "Screen capture: Collapse QS menu after clicking tile" into main

parents 0ef409f3 31ae4d48
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -29,7 +29,9 @@ import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.animation.Expandable
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger
import com.android.systemui.plugins.ActivityStarter.OnDismissAction
import com.android.systemui.plugins.activityStarter
@@ -56,7 +58,7 @@ import org.mockito.kotlin.mock
@SmallTest
@RunWith(AndroidJUnit4::class)
class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    private val testScope = kosmos.testScope
    private val keyguardInteractor = kosmos.keyguardInteractor
    private val dialogTransitionAnimator = mock<DialogTransitionAnimator>()
@@ -75,6 +77,7 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
    private val underTest by lazy {
        ScreenRecordTileUserActionInteractor(
            testScope.testScheduler,
            kosmos.testDispatcher,
            testScope.testScheduler,
            screenRecordRepository,
            screenRecordUxController,
@@ -89,6 +92,7 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_LARGE_SCREEN_SCREENCAPTURE, Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClick_whenStarting_cancelCountdown() = runTest {
        val startingModel = ScreenRecordModel.Starting(0)

@@ -97,10 +101,10 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
        verify(screenRecordUxController).cancelCountdown()
    }

    // Test that clicking the tile is NOP if opened from large screen.
    @Test
    @EnableFlags(Flags.FLAG_LARGE_SCREEN_SCREENCAPTURE, Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClick_fromLargeScreen_flagEnabled_isNOP() = runTest {
    @EnableFlags(Flags.FLAG_LARGE_SCREEN_SCREENCAPTURE)
    @DisableFlags(Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClick_withLargeScreenCaptureFlagEnabled_doesNotOpenDialog() = runTest {
        val recordingModel = ScreenRecordModel.DoingNothing
        overrideResource(R.bool.config_enableLargeScreenScreencapture, true)

@@ -108,20 +112,20 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
        verify(screenRecordUxController, never()).createScreenRecordDialog(any())
    }

    // Test that clicking the tile not in large screen opens the recording dialog when the flag is
    // disabled.
    @Test
    @EnableFlags(Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    @DisableFlags(Flags.FLAG_LARGE_SCREEN_SCREENCAPTURE)
    fun handleClick_largeScreenFlagDisabled_opensRecordingDialog() = runTest {
    fun handleClick_withNewScreenRecordFlagEnabled_doesNotOpenDialog() = runTest {
        val recordingModel = ScreenRecordModel.DoingNothing
        overrideResource(R.bool.config_enableLargeScreenScreencapture, true)

        underTest.handleInput(QSTileInputTestKtx.click(recordingModel))
        verify(screenRecordUxController).createScreenRecordDialog(any())
        verify(screenRecordUxController, never()).createScreenRecordDialog(any())
    }

    @Test
    @DisableFlags(Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClick_newToolbarFlagDisabled_opensRecordingDialog() = runTest {
    @DisableFlags(Flags.FLAG_LARGE_SCREEN_SCREENCAPTURE, Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClick_newScreenRecordingFlagsDisabled_opensRecordingDialog() = runTest {
        val recordingModel = ScreenRecordModel.DoingNothing

        underTest.handleInput(QSTileInputTestKtx.click(recordingModel))
@@ -129,6 +133,7 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_LARGE_SCREEN_SCREENCAPTURE, Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClick_whenRecording_stopRecording() = runTest {
        val recordingModel = ScreenRecordModel.Recording

@@ -138,6 +143,7 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_LARGE_SCREEN_SCREENCAPTURE, Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClick_whenDoingNothing_createDialogDismissPanelShowDialog() = runTest {
        val recordingModel = ScreenRecordModel.DoingNothing

@@ -162,6 +168,7 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
     * When the input view is not null and keyguard is not showing, dialog should animate and show
     */
    @Test
    @DisableFlags(Flags.FLAG_LARGE_SCREEN_SCREENCAPTURE, Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClickFromView_whenDoingNothing_whenKeyguardNotShowing_showDialogFromView() = runTest {
        val controller = mock<DialogTransitionAnimator.Controller>()
        val expandable =
+8 −2
Original line number Diff line number Diff line
@@ -133,7 +133,8 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState>
    protected void handleClick(@Nullable Expandable expandable) {
        if (ScreenCaptureRecordFeaturesInteractor.INSTANCE.getShouldShowNewToolbar()) {
            UserHandle userHandle = UserHandle.of(getCurrentTileUser());
            mActivityStarter.postQSRunnableDismissingKeyguard(

            mUiHandler.post(() -> mActivityStarter.executeRunnableDismissingKeyguard(
                    () -> mScreenCaptureUiInteractor.show(
                            new ScreenCaptureUiParameters(
                                    /* screenCaptureType= */ ScreenCaptureType.RECORD,
@@ -143,6 +144,11 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState>
                                    /* hostAppUserHandle= */ userHandle,
                                    /* hostAppUid= */ 0
                            )
                    ),
                    /* cancelAction= */ null,
                    /* dismissShade= */ true,
                    /* afterKeyguardGone= */ true,
                    /* deferred= */ false
            ));
        } else {
            // TODO(b/409330121): call mController.onScreenRecordQsTileClick() instead.
+21 −11
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.systemui.screenrecord.data.repository.ScreenRecordRepository
import com.android.systemui.statusbar.phone.KeyguardDismissUtil
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext

/** Handles screen recorder tile clicks. */
@@ -48,6 +49,7 @@ class ScreenRecordTileUserActionInteractor
@Inject
constructor(
    @Main private val mainContext: CoroutineContext,
    @Main private val mainDispatcher: CoroutineDispatcher,
    @Background private val backgroundContext: CoroutineContext,
    private val screenRecordRepository: ScreenRecordRepository,
    private val screenRecordUxController: ScreenRecordUxController,
@@ -64,8 +66,10 @@ constructor(
            when (action) {
                is QSTileUserAction.Click -> {
                    if (ScreenCaptureRecordFeaturesInteractor.shouldShowNewToolbar) {
                        withContext(mainDispatcher) {
                            // TODO(b/412723197): pass actual params here.
                        activityStarter.postQSRunnableDismissingKeyguard {
                            activityStarter.executeRunnableDismissingKeyguard(
                                {
                                    screenCaptureUiInteractor.show(
                                        ScreenCaptureUiParameters(
                                            ScreenCaptureType.RECORD,
@@ -76,6 +80,12 @@ constructor(
                                            hostAppUid = 0,
                                        )
                                    )
                                },
                                /* cancelAction= */ null,
                                /* dismissShade= */ true,
                                /* afterKeyguardGone= */ true,
                                /* deferred= */ false,
                            )
                        }
                    } else {
                        when (data) {