Loading packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandlerTest.kt→packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt +10 −10 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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, Loading @@ -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() Loading @@ -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() Loading @@ -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>()) Loading @@ -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) Loading @@ -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) Loading @@ -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() Loading packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt +7 −7 Original line number Diff line number Diff line Loading @@ -61,11 +61,11 @@ constructor( uiEventLogger, notificationManager, userContextProvider, keyguardDismissUtil keyguardDismissUtil, ) { private val commandHandler = IssueRecordingServiceCommandHandler( private val session = IssueRecordingServiceSession( bgExecutor, dialogTransitionAnimator, panelInteractor, Loading @@ -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. Loading @@ -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 Loading packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandler.kt→packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceSession.kt +8 −6 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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) Loading @@ -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) { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandlerTest.kt→packages/SystemUI/multivalentTests/src/com/android/systemui/recordissue/IssueRecordingServiceSessionTest.kt +10 −10 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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, Loading @@ -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() Loading @@ -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() Loading @@ -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>()) Loading @@ -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) Loading @@ -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) Loading @@ -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() Loading
packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt +7 −7 Original line number Diff line number Diff line Loading @@ -61,11 +61,11 @@ constructor( uiEventLogger, notificationManager, userContextProvider, keyguardDismissUtil keyguardDismissUtil, ) { private val commandHandler = IssueRecordingServiceCommandHandler( private val session = IssueRecordingServiceSession( bgExecutor, dialogTransitionAnimator, panelInteractor, Loading @@ -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. Loading @@ -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 Loading
packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceCommandHandler.kt→packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingServiceSession.kt +8 −6 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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) Loading @@ -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) { Loading