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

Commit c4f3054c authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge "Add an empty activity to show the new screen record toolbar." into main

parents 36ef0423 8b5877a5
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -534,6 +534,13 @@
            android:singleUser="true"
            android:permission="android.permission.LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE" />

        <activity android:name=".screencapture.ui.ScreenCaptureActivity"
            android:excludeFromRecents="true"
            android:exported="false"
            android:finishOnCloseSystemDialogs="true"
            android:launchMode="singleInstance"
            android:theme="@style/ScreenCapture" />

        <service android:name=".screenrecord.service.ScreenRecordingService" />

        <service android:name=".screenrecord.RecordingService"
+10 −51
Original line number Diff line number Diff line
@@ -45,9 +45,11 @@ import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.Flags;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.SysuiTestCaseExtKt;
import com.android.systemui.animation.DialogTransitionAnimator;
import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.kosmos.Kosmos;
import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.qs.QSTile;
@@ -61,6 +63,7 @@ import com.android.systemui.qs.logging.QSLogger;
import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.res.R;
import com.android.systemui.screencapture.record.domain.interactor.ScreenCaptureRecordFeaturesInteractorKosmosKt;
import com.android.systemui.screenrecord.ScreenRecordUxController;
import com.android.systemui.settings.UserContextProvider;
import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
@@ -89,6 +92,8 @@ public class ScreenRecordTileTest extends SysuiTestCase {
        return allCombinationsOf(QSComposeFragment.FLAG_NAME, QsDetailedView.FLAG_NAME);
    }

    private final Kosmos mKosmos = SysuiTestCaseExtKt.testKosmos(this);

    @Mock
    private ScreenRecordUxController mController;
    @Mock
@@ -154,6 +159,8 @@ public class ScreenRecordTileTest extends SysuiTestCase {
                mDialogTransitionAnimator,
                mPanelInteractor,
                mMediaProjectionMetricsLogger,
                ScreenCaptureRecordFeaturesInteractorKosmosKt
                        .getScreenCaptureRecordFeaturesInteractor(mKosmos),
                mUserContextProvider
        );

@@ -220,7 +227,7 @@ public class ScreenRecordTileTest extends SysuiTestCase {

    // Test that clicking the tile is NOP if opened from desktop.
    @Test
    @EnableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE)
    @EnableFlags({Flags.FLAG_DESKTOP_SCREEN_CAPTURE, Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR})
    public void testClickFromDesktop() {
        when(mController.isStarting()).thenReturn(false);
        when(mController.isRecording()).thenReturn(false);
@@ -228,9 +235,6 @@ public class ScreenRecordTileTest extends SysuiTestCase {
        mTile.refreshState();
        mTestableLooper.processAllMessages();

        // Override the resource to enable desktop features.
        overrideResource(R.bool.config_enableDesktopScreenCapture, true);

        mTile.handleClick(null /* view */);
        mTestableLooper.processAllMessages();
        verify(mController, never()).createScreenRecordDialog(null);
@@ -238,59 +242,14 @@ public class ScreenRecordTileTest extends SysuiTestCase {

    // Test that clicking the tile in desktop opens the recording dialog if flag is disabled.
    @Test
    @DisableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE)
    public void testClickFromDesktopFlagDisabled() {
        when(mController.isStarting()).thenReturn(false);
        when(mController.isRecording()).thenReturn(false);

        mTile.refreshState();
        mTestableLooper.processAllMessages();

        // Override the resource to enable desktop features.
        overrideResource(R.bool.config_enableDesktopScreenCapture, true);

        mTile.handleClick(null /* view */);
        mTestableLooper.processAllMessages();

        ArgumentCaptor<Runnable> onStartRecordingClicked = ArgumentCaptor.forClass(Runnable.class);
        verify(mController).createScreenRecordDialog(onStartRecordingClicked.capture());
    }

    // Test that clicking the tile not in desktop opens the recording dialog even if flag is
    // enabled.
    @Test
    @EnableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE)
    public void testClickNotFromDesktopFlagEnabled() {
    @DisableFlags(Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    public void testClickNewToolbarFlagDisabled() {
        when(mController.isStarting()).thenReturn(false);
        when(mController.isRecording()).thenReturn(false);

        mTile.refreshState();
        mTestableLooper.processAllMessages();

        // Override the resource to disable desktop features.
        overrideResource(R.bool.config_enableDesktopScreenCapture, false);

        mTile.handleClick(null /* view */);
        mTestableLooper.processAllMessages();

        ArgumentCaptor<Runnable> onStartRecordingClicked = ArgumentCaptor.forClass(Runnable.class);
        verify(mController).createScreenRecordDialog(onStartRecordingClicked.capture());
    }

    // Test that clicking the tile not in desktop opens the recording dialog when the flag is
    // disabled.
    @Test
    @DisableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE)
    public void testClickNotFromDesktopFlagDisabled() {
        when(mController.isStarting()).thenReturn(false);
        when(mController.isRecording()).thenReturn(false);

        mTile.refreshState();
        mTestableLooper.processAllMessages();

        // Override the resource to disable desktop features.
        overrideResource(R.bool.config_enableDesktopScreenCapture, false);

        mTile.handleClick(null /* view */);
        mTestableLooper.processAllMessages();

+12 −30
Original line number Diff line number Diff line
@@ -32,9 +32,11 @@ import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.kosmos.testScope
import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger
import com.android.systemui.plugins.ActivityStarter.OnDismissAction
import com.android.systemui.plugins.activityStarter
import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor
import com.android.systemui.qs.tiles.base.domain.model.QSTileInputTestKtx
import com.android.systemui.res.R
import com.android.systemui.screencapture.record.domain.interactor.screenCaptureRecordFeaturesInteractor
import com.android.systemui.screenrecord.ScreenRecordUxController
import com.android.systemui.screenrecord.data.model.ScreenRecordModel
import com.android.systemui.screenrecord.data.repository.ScreenRecordRepositoryImpl
@@ -70,7 +72,7 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
            screenRecordUxController = screenRecordUxController,
        )

    private val underTest =
    private val underTest by lazy {
        ScreenRecordTileUserActionInteractor(
            context,
            testScope.testScheduler,
@@ -78,11 +80,14 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
            screenRecordRepository,
            screenRecordUxController,
            keyguardInteractor,
            kosmos.activityStarter,
            keyguardDismissUtil,
            dialogTransitionAnimator,
            panelInteractor,
            kosmos.screenCaptureRecordFeaturesInteractor,
            mock<MediaProjectionMetricsLogger>(),
        )
    }

    @Test
    fun handleClick_whenStarting_cancelCountdown() = runTest {
@@ -95,7 +100,7 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {

    // Test that clicking the tile is NOP if opened from desktop.
    @Test
    @EnableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE)
    @EnableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE, Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClick_fromDesktop_flagEnabled_isNOP() = runTest {
        val recordingModel = ScreenRecordModel.DoingNothing

@@ -108,47 +113,24 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
            .createScreenRecordDialog(onStartRecordingClickedCaptor.capture())
    }

    // Test that clicking the tile in desktop opens the recording dialog if flag is disabled.
    // Test that clicking the tile not in desktop opens the recording dialog when the flag is
    // disabled.
    @Test
    @DisableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE)
    fun handleClick_fromDesktop_flagDisabled_opensRecordingDialog() = runTest {
        val recordingModel = ScreenRecordModel.DoingNothing

        // Override the resource to enable desktop features.
        underTest.apply { overrideResource(R.bool.config_enableDesktopScreenCapture, true) }

        underTest.handleInput(QSTileInputTestKtx.click(recordingModel))
        val onStartRecordingClickedCaptor = argumentCaptor<Runnable>()
        verify(screenRecordUxController)
            .createScreenRecordDialog(onStartRecordingClickedCaptor.capture())
    }

    // Test that clicking the tile not in desktop opens the recording dialog even if flag is
    // enabled.
    @Test
    @EnableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE)
    fun handleClick_notFromDesktop_flagEnabled_opensRecordingDialog() = runTest {
    fun handleClick_desktopFlagDisabled_opensRecordingDialog() = runTest {
        val recordingModel = ScreenRecordModel.DoingNothing

        // Override the resource to disable desktop features.
        underTest.apply { overrideResource(R.bool.config_enableDesktopScreenCapture, false) }

        underTest.handleInput(QSTileInputTestKtx.click(recordingModel))
        val onStartRecordingClickedCaptor = argumentCaptor<Runnable>()
        verify(screenRecordUxController)
            .createScreenRecordDialog(onStartRecordingClickedCaptor.capture())
    }

    // Test that clicking the tile not in desktop opens the recording dialog when the flag is
    // disabled.
    @Test
    @DisableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE)
    fun handleClick_notFromDesktop_flagDisabled_opensRecordingDialog() = runTest {
    @DisableFlags(Flags.FLAG_NEW_SCREEN_RECORD_TOOLBAR)
    fun handleClick_newToolbarFlagDisabled_opensRecordingDialog() = runTest {
        val recordingModel = ScreenRecordModel.DoingNothing

        // Override the resource to disable desktop features.
        underTest.apply { overrideResource(R.bool.config_enableDesktopScreenCapture, false) }

        underTest.handleInput(QSTileInputTestKtx.click(recordingModel))
        val onStartRecordingClickedCaptor = argumentCaptor<Runnable>()
        verify(screenRecordUxController)
+60 −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.common.shared.model

import android.content.Intent
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.kosmos.runTest
import com.android.systemui.testKosmosNew
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
class ScreenCaptureActivityIntentParametersTest : SysuiTestCase() {

    private val kosmos = testKosmosNew()

    @Test
    fun testCastParameters() =
        kosmos.runTest {
            assertThat(castScreenCaptureActivityIntentParameters.passThroughIntent())
                .isEqualTo(castScreenCaptureActivityIntentParameters)
        }

    @Test
    fun testRecordParameters() =
        kosmos.runTest {
            assertThat(recordScreenCaptureActivityIntentParameters.passThroughIntent())
                .isEqualTo(recordScreenCaptureActivityIntentParameters)
        }

    @Test
    fun testShareParameters() =
        kosmos.runTest {
            assertThat(shareScreenCaptureActivityIntentParameters.passThroughIntent())
                .isEqualTo(shareScreenCaptureActivityIntentParameters)
        }

    private fun ScreenCaptureActivityIntentParameters.passThroughIntent():
        ScreenCaptureActivityIntentParameters {
        return ScreenCaptureActivityIntentParameters.fromIntent(Intent().apply(::fillIntent))
    }
}
+0 −3
Original line number Diff line number Diff line
@@ -17,11 +17,9 @@
package com.android.systemui.screencapture.record.domain.interactor

import android.content.testableContext
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.kosmos.collectLastValue
import com.android.systemui.kosmos.runTest
@@ -44,7 +42,6 @@ class ScreenCaptureRecordFeaturesInteractorTest : SysuiTestCase() {
    private val underTest by lazy { kosmos.screenCaptureRecordFeaturesInteractor }

    @Test
    @EnableFlags(Flags.FLAG_DESKTOP_SCREEN_CAPTURE)
    fun isLargeScreenReturnsConfigValue() =
        kosmos.runTest {
            val isLargeScreen by collectLastValue(underTest.isLargeScreen)
Loading