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

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

Explicitly state which user to start Record Issue interactions inside.

Also add a mechanism to handle tracuer requests that are made before the
service is bound. This can happen if the service is in a different tile
from the Record Issue Tile, and binding takes longer than expected.

Bug: 364824477
Test: Verified that this works on device (when combined with all other
changes in CL chain).
Flag: EXEMPT bug fix

Change-Id: Iba6f416d7d614f21f5cb1de5dba6aa577313a94b
parent b024e5e8
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ class IssueRecordingServiceSessionTest : SysuiTestCase() {

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

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

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

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

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

        verify(traceurConnection).shareTraces(mContext, uri)
        verify(traceurConnection).shareTraces(uri)
    }

    @Test
    fun closesShade_afterReceivingShareCommand() {
        val uri = mock<Uri>()

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

        verify(panelInteractor).collapsePanels()
+0 −1
Original line number Diff line number Diff line
@@ -99,7 +99,6 @@ constructor(
                session.share(
                    intent.getIntExtra(EXTRA_NOTIFICATION_ID, mNotificationId),
                    intent.getParcelableExtra(EXTRA_PATH, Uri::class.java),
                    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
+2 −3
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.systemui.recordissue
import android.app.IActivityManager
import android.app.NotificationManager
import android.content.ContentResolver
import android.content.Context
import android.net.Uri
import android.os.UserHandle
import android.provider.Settings
@@ -64,7 +63,7 @@ class IssueRecordingServiceSession(
        issueRecordingState.isRecording = false
    }

    fun share(notificationId: Int, screenRecording: Uri?, context: Context) {
    fun share(notificationId: Int, screenRecording: Uri?) {
        bgExecutor.execute {
            notificationManager.cancelAsUser(
                null,
@@ -75,7 +74,7 @@ class IssueRecordingServiceSession(
            if (issueRecordingState.takeBugreport) {
                iActivityManager.requestBugReportWithExtraAttachment(screenRecording)
            } else {
                traceurConnection.shareTraces(context, screenRecording)
                traceurConnection.shareTraces(screenRecording)
            }
        }

+9 −7
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.recordissue

import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
@@ -69,8 +68,8 @@ constructor(userContextProvider: UserContextProvider, @Background private val bg
    @WorkerThread fun stopTracing() = sendMessage(MessageConstants.STOP_WHAT)

    @WorkerThread
    fun shareTraces(context: Context, screenRecord: Uri?) {
        val replyHandler = Messenger(ShareFilesHandler(context, screenRecord, bgLooper))
    fun shareTraces(screenRecord: Uri?) {
        val replyHandler = Messenger(ShareFilesHandler(screenRecord, userContextProvider, bgLooper))
        sendMessage(MessageConstants.SHARE_WHAT, replyTo = replyHandler)
    }

@@ -87,15 +86,15 @@ constructor(userContextProvider: UserContextProvider, @Background private val bg
                    this.data = data
                    this.replyTo = replyTo
                }
            binder!!.send(msg)
            binder?.send(msg) ?: onBound.add { binder!!.send(msg) }
        } catch (e: Exception) {
            Log.e(TAG, "failed to notify Traceur", e)
        }
}

private class ShareFilesHandler(
    private val context: Context,
    private val screenRecord: Uri?,
    private val userContextProvider: UserContextProvider,
    looper: Looper,
) : Handler(looper) {

@@ -118,9 +117,12 @@ private class ShareFilesHandler(
                screenRecord?.let { add(it) }
            }
        val fileSharingIntent =
            FileSender.buildSendIntent(context, uris)
            FileSender.buildSendIntent(userContextProvider.userContext, uris)
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
        context.startActivity(fileSharingIntent)
        userContextProvider.userContext.startActivityAsUser(
            fileSharingIntent,
            userContextProvider.userContext.user,
        )
    }
}