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

Commit ede829bd authored by Stefan Andonian's avatar Stefan Andonian
Browse files

Rename IssueRecordingServiceCommandHandler -> IssueRecordingServiceSession

Bug: N/A
Flag: EXEMPT rename class
Test: Verified compilation works fine.
Change-Id: I9058614ff4261739436d4f8fc56977c524ace3cb
parent 2f2178b7
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ import org.mockito.kotlin.verify
@SmallTest
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper(setAsMainLooper = true)
class IssueRecordingServiceCommandHandlerTest : SysuiTestCase() {
class IssueRecordingServiceSessionTest : SysuiTestCase() {

    private val kosmos = Kosmos().also { it.testCase = this }
    private val bgExecutor = kosmos.fakeExecutor
@@ -61,13 +61,13 @@ class IssueRecordingServiceCommandHandlerTest : SysuiTestCase() {
    private val notificationManager = mock<NotificationManager>()
    private val panelInteractor = mock<PanelInteractor>()

    private lateinit var underTest: IssueRecordingServiceCommandHandler
    private lateinit var underTest: IssueRecordingServiceSession

    @Before
    fun setup() {
        traceurMessageSender = mock<TraceurMessageSender>()
        underTest =
            IssueRecordingServiceCommandHandler(
            IssueRecordingServiceSession(
                bgExecutor,
                dialogTransitionAnimator,
                panelInteractor,
@@ -75,13 +75,13 @@ class IssueRecordingServiceCommandHandlerTest : SysuiTestCase() {
                issueRecordingState,
                iActivityManager,
                notificationManager,
                userContextProvider
                userContextProvider,
            )
    }

    @Test
    fun startsTracing_afterReceivingActionStartCommand() {
        underTest.handleStartCommand()
        underTest.start()
        bgExecutor.runAllReady()

        Truth.assertThat(issueRecordingState.isRecording).isTrue()
@@ -90,7 +90,7 @@ class IssueRecordingServiceCommandHandlerTest : SysuiTestCase() {

    @Test
    fun stopsTracing_afterReceivingStopTracingCommand() {
        underTest.handleStopCommand(mContext.contentResolver)
        underTest.stop(mContext.contentResolver)
        bgExecutor.runAllReady()

        Truth.assertThat(issueRecordingState.isRecording).isFalse()
@@ -99,7 +99,7 @@ class IssueRecordingServiceCommandHandlerTest : SysuiTestCase() {

    @Test
    fun cancelsNotification_afterReceivingShareCommand() {
        underTest.handleShareCommand(0, null, mContext)
        underTest.share(0, null, mContext)
        bgExecutor.runAllReady()

        verify(notificationManager).cancelAsUser(isNull(), anyInt(), any<UserHandle>())
@@ -110,7 +110,7 @@ class IssueRecordingServiceCommandHandlerTest : SysuiTestCase() {
        issueRecordingState.takeBugreport = true
        val uri = mock<Uri>()

        underTest.handleShareCommand(0, uri, mContext)
        underTest.share(0, uri, mContext)
        bgExecutor.runAllReady()

        verify(iActivityManager).requestBugReportWithExtraAttachment(uri)
@@ -121,7 +121,7 @@ class IssueRecordingServiceCommandHandlerTest : SysuiTestCase() {
        issueRecordingState.takeBugreport = false
        val uri = mock<Uri>()

        underTest.handleShareCommand(0, uri, mContext)
        underTest.share(0, uri, mContext)
        bgExecutor.runAllReady()

        verify(traceurMessageSender).shareTraces(mContext, uri)
@@ -131,7 +131,7 @@ class IssueRecordingServiceCommandHandlerTest : SysuiTestCase() {
    fun closesShade_afterReceivingShareCommand() {
        val uri = mock<Uri>()

        underTest.handleShareCommand(0, uri, mContext)
        underTest.share(0, uri, mContext)
        bgExecutor.runAllReady()

        verify(panelInteractor).collapsePanels()
+7 −7
Original line number Diff line number Diff line
@@ -61,11 +61,11 @@ constructor(
        uiEventLogger,
        notificationManager,
        userContextProvider,
        keyguardDismissUtil
        keyguardDismissUtil,
    ) {

    private val commandHandler =
        IssueRecordingServiceCommandHandler(
    private val session =
        IssueRecordingServiceSession(
            bgExecutor,
            dialogTransitionAnimator,
            panelInteractor,
@@ -86,7 +86,7 @@ constructor(
        Log.d(getTag(), "handling action: ${intent?.action}")
        when (intent?.action) {
            ACTION_START -> {
                commandHandler.handleStartCommand()
                session.start()
                if (!issueRecordingState.recordScreen) {
                    // If we don't want to record the screen, the ACTION_SHOW_START_NOTIF action
                    // will circumvent the RecordingService's screen recording start code.
@@ -94,12 +94,12 @@ constructor(
                }
            }
            ACTION_STOP,
            ACTION_STOP_NOTIF -> commandHandler.handleStopCommand(contentResolver)
            ACTION_STOP_NOTIF -> session.stop(contentResolver)
            ACTION_SHARE -> {
                commandHandler.handleShareCommand(
                session.share(
                    intent.getIntExtra(EXTRA_NOTIFICATION_ID, mNotificationId),
                    intent.getParcelableExtra(EXTRA_PATH, Uri::class.java),
                    this
                    this,
                )
                // Unlike all other actions, action_share has different behavior for the screen
                // recording qs tile than it does for the record issue qs tile. Return sticky to
+8 −6
Original line number Diff line number Diff line
@@ -34,9 +34,11 @@ private const val DISABLED = 0
/**
 * This class exists to unit test the business logic encapsulated in IssueRecordingService. Android
 * specifically calls out that there is no supported way to test IntentServices here:
 * https://developer.android.com/training/testing/other-components/services
 * https://developer.android.com/training/testing/other-components/services, and mentions that the
 * best way to add unit tests, is to introduce a separate class containing the business logic of
 * that service, and test the functionality via that class.
 */
class IssueRecordingServiceCommandHandler(
class IssueRecordingServiceSession(
    private val bgExecutor: Executor,
    private val dialogTransitionAnimator: DialogTransitionAnimator,
    private val panelInteractor: PanelInteractor,
@@ -47,12 +49,12 @@ class IssueRecordingServiceCommandHandler(
    private val userContextProvider: UserContextProvider,
) {

    fun handleStartCommand() {
    fun start() {
        bgExecutor.execute { traceurMessageSender.startTracing(issueRecordingState.traceConfig) }
        issueRecordingState.isRecording = true
    }

    fun handleStopCommand(contentResolver: ContentResolver) {
    fun stop(contentResolver: ContentResolver) {
        bgExecutor.execute {
            if (issueRecordingState.traceConfig.longTrace) {
                Settings.Global.putInt(contentResolver, NOTIFY_SESSION_ENDED_SETTING, DISABLED)
@@ -62,12 +64,12 @@ class IssueRecordingServiceCommandHandler(
        issueRecordingState.isRecording = false
    }

    fun handleShareCommand(notificationId: Int, screenRecording: Uri?, context: Context) {
    fun share(notificationId: Int, screenRecording: Uri?, context: Context) {
        bgExecutor.execute {
            notificationManager.cancelAsUser(
                null,
                notificationId,
                UserHandle(userContextProvider.userContext.userId)
                UserHandle(userContextProvider.userContext.userId),
            )

            if (issueRecordingState.takeBugreport) {