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

Commit 73dc0f56 authored by Stefan Andonian's avatar Stefan Andonian Committed by Android (Google) Code Review
Browse files

Merge "[Record Issue QS Tile] Allow Bug report flow to also have screen...

Merge "[Record Issue QS Tile] Allow Bug report flow to also have screen recording metadata" into main
parents 066cfe96 0bd19ff7
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -501,7 +501,7 @@ interface IActivityManager {
            in String shareDescription);
            in String shareDescription);


    void requestInteractiveBugReport();
    void requestInteractiveBugReport();
    void requestBugReportWithExtraAttachment(in Uri extraAttachment);
    void requestBugReportWithExtraAttachments(in List<Uri> extraAttachment);
    void requestFullBugReport();
    void requestFullBugReport();
    void requestRemoteBugReport(long nonce);
    void requestRemoteBugReport(long nonce);
    boolean launchBugReportHandlerApp();
    boolean launchBugReportHandlerApp();
+17 −12
Original line number Original line Diff line number Diff line
@@ -90,10 +90,10 @@ import com.android.internal.app.ChooserActivity;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;


import libcore.io.Streams;

import com.google.android.collect.Lists;
import com.google.android.collect.Lists;


import libcore.io.Streams;

import java.io.BufferedOutputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.File;
@@ -171,8 +171,8 @@ public class BugreportProgressService extends Service {
    static final String EXTRA_DESCRIPTION = "android.intent.extra.DESCRIPTION";
    static final String EXTRA_DESCRIPTION = "android.intent.extra.DESCRIPTION";
    static final String EXTRA_ORIGINAL_INTENT = "android.intent.extra.ORIGINAL_INTENT";
    static final String EXTRA_ORIGINAL_INTENT = "android.intent.extra.ORIGINAL_INTENT";
    static final String EXTRA_INFO = "android.intent.extra.INFO";
    static final String EXTRA_INFO = "android.intent.extra.INFO";
    static final String EXTRA_EXTRA_ATTACHMENT_URI =
    static final String EXTRA_EXTRA_ATTACHMENT_URIS =
            "android.intent.extra.EXTRA_ATTACHMENT_URI";
            "android.intent.extra.EXTRA_ATTACHMENT_URIS";


    private static final int MSG_SERVICE_COMMAND = 1;
    private static final int MSG_SERVICE_COMMAND = 1;
    private static final int MSG_DELAYED_SCREENSHOT = 2;
    private static final int MSG_DELAYED_SCREENSHOT = 2;
@@ -682,10 +682,11 @@ public class BugreportProgressService extends Service {
        long nonce = intent.getLongExtra(EXTRA_BUGREPORT_NONCE, 0);
        long nonce = intent.getLongExtra(EXTRA_BUGREPORT_NONCE, 0);
        String baseName = getBugreportBaseName(bugreportType);
        String baseName = getBugreportBaseName(bugreportType);
        String name = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
        String name = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
        Uri extraAttachment = intent.getParcelableExtra(EXTRA_EXTRA_ATTACHMENT_URI, Uri.class);
        List<Uri> extraAttachments =
                intent.getParcelableArrayListExtra(EXTRA_EXTRA_ATTACHMENT_URIS, Uri.class);


        BugreportInfo info = new BugreportInfo(mContext, baseName, name, shareTitle,
        BugreportInfo info = new BugreportInfo(mContext, baseName, name, shareTitle,
                shareDescription, bugreportType, mBugreportsDir, nonce, extraAttachment);
                shareDescription, bugreportType, mBugreportsDir, nonce, extraAttachments);
        synchronized (mLock) {
        synchronized (mLock) {
            if (info.bugreportFile.exists()) {
            if (info.bugreportFile.exists()) {
                Log.e(TAG, "Failed to start bugreport generation, the requested bugreport file "
                Log.e(TAG, "Failed to start bugreport generation, the requested bugreport file "
@@ -1233,9 +1234,13 @@ public class BugreportProgressService extends Service {
            clipData.addItem(new ClipData.Item(null, null, null, screenshotUri));
            clipData.addItem(new ClipData.Item(null, null, null, screenshotUri));
            attachments.add(screenshotUri);
            attachments.add(screenshotUri);
        }
        }
        if (info.extraAttachment != null) {
        if (info.extraAttachments != null) {
            clipData.addItem(new ClipData.Item(null, null, null, info.extraAttachment));
            info.extraAttachments.forEach(it -> {
            attachments.add(info.extraAttachment);
                if (it != null) {
                    clipData.addItem(new ClipData.Item(null, null, null, it));
                    attachments.add(it);
                }
            });
        }
        }
        intent.setClipData(clipData);
        intent.setClipData(clipData);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
@@ -2096,7 +2101,7 @@ public class BugreportProgressService extends Service {
        final long nonce;
        final long nonce;


        @Nullable
        @Nullable
        public Uri extraAttachment = null;
        public List<Uri> extraAttachments = null;


        private final Object mLock = new Object();
        private final Object mLock = new Object();


@@ -2106,7 +2111,7 @@ public class BugreportProgressService extends Service {
        BugreportInfo(Context context, String baseName, String name,
        BugreportInfo(Context context, String baseName, String name,
                @Nullable String shareTitle, @Nullable String shareDescription,
                @Nullable String shareTitle, @Nullable String shareDescription,
                @BugreportParams.BugreportMode int type, File bugreportsDir, long nonce,
                @BugreportParams.BugreportMode int type, File bugreportsDir, long nonce,
                @Nullable Uri extraAttachment) {
                @Nullable List<Uri> extraAttachments) {
            this.context = context;
            this.context = context;
            this.name = this.initialName = name;
            this.name = this.initialName = name;
            this.shareTitle = shareTitle == null ? "" : shareTitle;
            this.shareTitle = shareTitle == null ? "" : shareTitle;
@@ -2115,7 +2120,7 @@ public class BugreportProgressService extends Service {
            this.nonce = nonce;
            this.nonce = nonce;
            this.baseName = baseName;
            this.baseName = baseName;
            this.bugreportFile = new File(bugreportsDir, getFileName(this, ".zip"));
            this.bugreportFile = new File(bugreportsDir, getFileName(this, ".zip"));
            this.extraAttachment = extraAttachment;
            this.extraAttachments = extraAttachments;
        }
        }


        void createBugreportFile() {
        void createBugreportFile() {
+1 −1
Original line number Original line Diff line number Diff line
@@ -115,7 +115,7 @@ class IssueRecordingServiceSessionTest : SysuiTestCase() {
        underTest.share(0, uri)
        underTest.share(0, uri)
        bgExecutor.runAllReady()
        bgExecutor.runAllReady()


        verify(iActivityManager).requestBugReportWithExtraAttachment(uri)
        verify(iActivityManager).requestBugReportWithExtraAttachments(any())
    }
    }


    @Test
    @Test
+10 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.recordissue


import android.app.IActivityManager
import android.app.IActivityManager
import android.app.NotificationManager
import android.app.NotificationManager
import android.content.Intent
import android.net.Uri
import android.net.Uri
import android.os.UserHandle
import android.os.UserHandle
import android.provider.Settings
import android.provider.Settings
@@ -27,6 +28,7 @@ import com.android.systemui.settings.UserContextProvider
import com.android.traceur.PresetTraceConfigs
import com.android.traceur.PresetTraceConfigs
import java.util.concurrent.Executor
import java.util.concurrent.Executor


private const val SHELL_PACKAGE = "com.android.shell"
private const val NOTIFY_SESSION_ENDED_SETTING = "should_notify_trace_session_ended"
private const val NOTIFY_SESSION_ENDED_SETTING = "should_notify_trace_session_ended"
private const val DISABLED = 0
private const val DISABLED = 0


@@ -86,7 +88,14 @@ class IssueRecordingServiceSession(
                    }
                    }
                }
                }
            if (takeBugReport) {
            if (takeBugReport) {
                iActivityManager.requestBugReportWithExtraAttachment(screenRecording)
                screenRecordingUris.forEach {
                    userContextProvider.userContext.grantUriPermission(
                        SHELL_PACKAGE,
                        it,
                        Intent.FLAG_GRANT_READ_URI_PERMISSION,
                    )
                }
                iActivityManager.requestBugReportWithExtraAttachments(screenRecordingUris)
            } else {
            } else {
                traceurConnection.shareTraces(screenRecordingUris)
                traceurConnection.shareTraces(screenRecordingUris)
            }
            }
+8 −7
Original line number Original line Diff line number Diff line
@@ -632,8 +632,8 @@ public class ActivityManagerService extends IActivityManager.Stub
    static final String EXTRA_DESCRIPTION = "android.intent.extra.DESCRIPTION";
    static final String EXTRA_DESCRIPTION = "android.intent.extra.DESCRIPTION";
    static final String EXTRA_BUGREPORT_TYPE = "android.intent.extra.BUGREPORT_TYPE";
    static final String EXTRA_BUGREPORT_TYPE = "android.intent.extra.BUGREPORT_TYPE";
    static final String EXTRA_BUGREPORT_NONCE = "android.intent.extra.BUGREPORT_NONCE";
    static final String EXTRA_BUGREPORT_NONCE = "android.intent.extra.BUGREPORT_NONCE";
    static final String EXTRA_EXTRA_ATTACHMENT_URI =
    static final String EXTRA_EXTRA_ATTACHMENT_URIS =
            "android.intent.extra.EXTRA_ATTACHMENT_URI";
            "android.intent.extra.EXTRA_ATTACHMENT_URIS";
    /**
    /**
     * The maximum number of bytes that {@link #setProcessStateSummary} accepts.
     * The maximum number of bytes that {@link #setProcessStateSummary} accepts.
@@ -7660,7 +7660,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
     */
    public void requestBugReportWithDescription(@Nullable String shareTitle,
    public void requestBugReportWithDescription(@Nullable String shareTitle,
            @Nullable String shareDescription, int bugreportType, long nonce,
            @Nullable String shareDescription, int bugreportType, long nonce,
            @Nullable Uri extraAttachment) {
            @Nullable List<Uri> extraAttachments) {
        String type = null;
        String type = null;
        switch (bugreportType) {
        switch (bugreportType) {
            case BugreportParams.BUGREPORT_MODE_FULL:
            case BugreportParams.BUGREPORT_MODE_FULL:
@@ -7715,8 +7715,9 @@ public class ActivityManagerService extends IActivityManager.Stub
        triggerShellBugreport.setPackage(SHELL_APP_PACKAGE);
        triggerShellBugreport.setPackage(SHELL_APP_PACKAGE);
        triggerShellBugreport.putExtra(EXTRA_BUGREPORT_TYPE, bugreportType);
        triggerShellBugreport.putExtra(EXTRA_BUGREPORT_TYPE, bugreportType);
        triggerShellBugreport.putExtra(EXTRA_BUGREPORT_NONCE, nonce);
        triggerShellBugreport.putExtra(EXTRA_BUGREPORT_NONCE, nonce);
        if (extraAttachment != null) {
        if (extraAttachments != null && !extraAttachments.isEmpty()) {
            triggerShellBugreport.putExtra(EXTRA_EXTRA_ATTACHMENT_URI, extraAttachment);
            triggerShellBugreport.putParcelableArrayListExtra(EXTRA_EXTRA_ATTACHMENT_URIS,
                    new ArrayList(extraAttachments));
            triggerShellBugreport.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            triggerShellBugreport.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
        }
        triggerShellBugreport.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        triggerShellBugreport.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
@@ -7775,9 +7776,9 @@ public class ActivityManagerService extends IActivityManager.Stub
     * Takes an interactive bugreport with a progress notification. Also attaches given file uri.
     * Takes an interactive bugreport with a progress notification. Also attaches given file uri.
     */
     */
    @Override
    @Override
    public void requestBugReportWithExtraAttachment(@NonNull Uri extraAttachment) {
    public void requestBugReportWithExtraAttachments(@NonNull List<Uri> extraAttachments) {
        requestBugReportWithDescription(null, null, BugreportParams.BUGREPORT_MODE_INTERACTIVE, 0L,
        requestBugReportWithDescription(null, null, BugreportParams.BUGREPORT_MODE_INTERACTIVE, 0L,
                extraAttachment);
                extraAttachments);
    }
    }
    /**
    /**