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

Commit ad728039 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I9d8c2997,I16cd74a6,Ic22cc8a6 into main

* changes:
  [SB][Screen Chips] Show a stop dialog for screen share and screen cast.
  [SB][Screen Chips] Show a stop dialog when tapping on screen record chip
  [SB][Screen Chips] Distinguish share-to-app and cast-to-other-device.
parents 0d028655 a76d61c9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor
import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx
import com.android.systemui.screenrecord.RecordingController
import com.android.systemui.screenrecord.data.model.ScreenRecordModel
import com.android.systemui.screenrecord.data.repository.ScreenRecordRepositoryImpl
import com.android.systemui.statusbar.phone.KeyguardDismissUtil
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.argumentCaptor
@@ -72,11 +73,18 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
                .thenReturn(dialog)
        }

    private val screenRecordRepository =
        ScreenRecordRepositoryImpl(
            bgCoroutineContext = testScope.testScheduler,
            recordingController = recordingController,
        )

    private val underTest =
        ScreenRecordTileUserActionInteractor(
            context,
            testScope.testScheduler,
            testScope.testScheduler,
            screenRecordRepository,
            recordingController,
            keyguardInteractor,
            keyguardDismissUtil,
+23 −0
Original line number Diff line number Diff line
@@ -319,6 +319,29 @@
    <string name="screenrecord_save_error">Error saving screen recording</string>
    <!-- A toast message shown when the screen recording cannot be started due to a generic error [CHAR LIMIT=NONE] -->
    <string name="screenrecord_start_error">Error starting screen recording</string>
    <!-- Title for a dialog shown to the user that will let them stop recording their screen [CHAR LIMIT=50] -->
    <string name="screenrecord_stop_dialog_title">Stop recording screen?</string>
    <!-- Text telling a user that they will stop recording their screen if they click the "Stop recording" button [CHAR LIMIT=100] -->
    <string name="screenrecord_stop_dialog_message">You will stop recording your screen</string>
    <!-- Button to stop a screen recording [CHAR LIMIT=35] -->
    <string name="screenrecord_stop_dialog_button">Stop recording</string>

    <!-- Title for a dialog shown to the user that will let them stop sharing their screen to another app on the device [CHAR LIMIT=50] -->
    <string name="share_to_app_stop_dialog_title">Stop sharing screen?</string>
    <!-- Text telling a user that they will stop sharing their screen if they click the "Stop sharing" button [CHAR LIMIT=100] -->
    <string name="share_to_app_stop_dialog_message">You will stop sharing your screen</string>
    <!-- Button to stop screen sharing [CHAR LIMIT=35] -->
    <string name="share_to_app_stop_dialog_button">Stop sharing</string>

    <!-- Title for a dialog shown to the user that will let them stop casting their screen to a different device [CHAR LIMIT=50] -->
    <string name="cast_to_other_device_stop_dialog_title">Stop casting screen?</string>
    <!-- Text telling a user that they will stop casting their screen to a different device if they click the "Stop casting" button [CHAR LIMIT=100] -->
    <string name="cast_to_other_device_stop_dialog_message">You will stop casting your screen</string>
    <!-- Button to stop screen casting to a different device [CHAR LIMIT=35] -->
    <string name="cast_to_other_device_stop_dialog_button">Stop casting</string>

    <!-- Button to close a dialog without doing any action [CHAR LIMIT=20] -->
    <string name="close_dialog_button">Close</string>

    <!-- Notification title displayed for issue recording [CHAR LIMIT=50]-->
    <string name="issuerecord_title">Issue Recorder</string>
+17 −3
Original line number Diff line number Diff line
@@ -20,7 +20,21 @@ import android.app.ActivityManager.RunningTaskInfo

/** Represents the state of media projection. */
sealed interface MediaProjectionState {
    object NotProjecting : MediaProjectionState
    object EntireScreen : MediaProjectionState
    data class SingleTask(val task: RunningTaskInfo) : MediaProjectionState
    /** There is no media being projected. */
    data object NotProjecting : MediaProjectionState

    /**
     * Media is currently being projected.
     *
     * @property hostPackage the package name of the app that is receiving the content of the media
     *   projection (aka which app the phone screen contents are being sent to).
     */
    sealed class Projecting(open val hostPackage: String) : MediaProjectionState {
        /** The entire screen is being projected. */
        data class EntireScreen(override val hostPackage: String) : Projecting(hostPackage)

        /** Only a single task is being projected. */
        data class SingleTask(override val hostPackage: String, val task: RunningTaskInfo) :
            Projecting(hostPackage)
    }
}
+16 −6
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ constructor(
        }
    }

    override suspend fun stopProjecting() {
        withContext(backgroundDispatcher) { mediaProjectionManager.stopActiveProjection() }
    }

    override val mediaProjectionState: Flow<MediaProjectionState> =
        conflatedCallbackFlow {
                val callback =
@@ -83,7 +87,9 @@ constructor(
                            session: ContentRecordingSession?
                        ) {
                            Log.d(TAG, "MediaProjectionManager.Callback#onSessionStarted: $session")
                            launch { trySendWithFailureLogging(stateForSession(session), TAG) }
                            launch {
                                trySendWithFailureLogging(stateForSession(info, session), TAG)
                            }
                        }
                    }
                mediaProjectionManager.addCallback(callback, handler)
@@ -95,19 +101,23 @@ constructor(
                initialValue = MediaProjectionState.NotProjecting,
            )

    private suspend fun stateForSession(session: ContentRecordingSession?): MediaProjectionState {
    private suspend fun stateForSession(
        info: MediaProjectionInfo,
        session: ContentRecordingSession?
    ): MediaProjectionState {
        if (session == null) {
            return MediaProjectionState.NotProjecting
        }

        val hostPackage = info.packageName
        if (session.contentToRecord == RECORD_CONTENT_DISPLAY || session.tokenToRecord == null) {
            return MediaProjectionState.EntireScreen
            return MediaProjectionState.Projecting.EntireScreen(hostPackage)
        }
        val matchingTask =
            tasksRepository.findRunningTaskFromWindowContainerToken(
                checkNotNull(session.tokenToRecord)
            )
                ?: return MediaProjectionState.EntireScreen
        return MediaProjectionState.SingleTask(matchingTask)
            ) ?: return MediaProjectionState.Projecting.EntireScreen(hostPackage)
        return MediaProjectionState.Projecting.SingleTask(hostPackage, matchingTask)
    }

    companion object {
+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@ interface MediaProjectionRepository {
    /** Switches the task that should be projected. */
    suspend fun switchProjectedTask(task: RunningTaskInfo)

    /** Stops the currently active projection. */
    suspend fun stopProjecting()

    /** Represents the current [MediaProjectionState]. */
    val mediaProjectionState: Flow<MediaProjectionState>
}
Loading