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

Commit 58296be2 authored by Stefan Andonian's avatar Stefan Andonian
Browse files

Allow SystemUI to trigger a bugreport and share with BetterBug from the Record Issue QS Tile.

On the UI side of things, I added a switch to allow users to choose between sharing traces directly, or via bugreport.

Bug: 305049544
Test: Locally verified that this worked on my device.
https://b.corp.google.com/issues/331268833#comment5 is an example of
this working properly.
Screenshot: https://photos.app.goo.gl/LmNFhuWLCPyEygDw6
Flag: ACONFIG record_issue_qs_tile DEVELOPMENT

Change-Id: I01547162989b7f909fe849aa21ffbb604905dfab
parent 3b44bd77
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -499,6 +499,7 @@ interface IActivityManager {
            in String shareDescription);

    void requestInteractiveBugReport();
    void requestBugReportWithExtraAttachment(in Uri extraAttachment);
    void requestFullBugReport();
    void requestRemoteBugReport(long nonce);
    boolean launchBugReportHandlerApp();
+15 −4
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ import android.os.AsyncTask;
import android.os.Binder;
import android.os.BugreportManager;
import android.os.BugreportManager.BugreportCallback;
import android.os.BugreportManager.BugreportCallback.BugreportErrorCode;
import android.os.BugreportParams;
import android.os.Bundle;
import android.os.FileUtils;
@@ -169,6 +168,8 @@ public class BugreportProgressService extends Service {
    static final String EXTRA_DESCRIPTION = "android.intent.extra.DESCRIPTION";
    static final String EXTRA_ORIGINAL_INTENT = "android.intent.extra.ORIGINAL_INTENT";
    static final String EXTRA_INFO = "android.intent.extra.INFO";
    static final String EXTRA_EXTRA_ATTACHMENT_URI =
            "android.intent.extra.EXTRA_ATTACHMENT_URI";

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

        BugreportInfo info = new BugreportInfo(mContext, baseName, name,
                shareTitle, shareDescription, bugreportType, mBugreportsDir, nonce);
        BugreportInfo info = new BugreportInfo(mContext, baseName, name, shareTitle,
                shareDescription, bugreportType, mBugreportsDir, nonce, extraAttachment);
        synchronized (mLock) {
            if (info.bugreportFile.exists()) {
                Log.e(TAG, "Failed to start bugreport generation, the requested bugreport file "
@@ -1184,6 +1186,10 @@ public class BugreportProgressService extends Service {
            clipData.addItem(new ClipData.Item(null, null, null, screenshotUri));
            attachments.add(screenshotUri);
        }
        if (info.extraAttachment != null) {
            clipData.addItem(new ClipData.Item(null, null, null, info.extraAttachment));
            attachments.add(info.extraAttachment);
        }
        intent.setClipData(clipData);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);

@@ -2042,6 +2048,9 @@ public class BugreportProgressService extends Service {
         */
        final long nonce;

        @Nullable
        public Uri extraAttachment = null;

        private final Object mLock = new Object();

        /**
@@ -2049,7 +2058,8 @@ public class BugreportProgressService extends Service {
         */
        BugreportInfo(Context context, String baseName, String name,
                @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) {
            this.context = context;
            this.name = this.initialName = name;
            this.shareTitle = shareTitle == null ? "" : shareTitle;
@@ -2058,6 +2068,7 @@ public class BugreportProgressService extends Service {
            this.nonce = nonce;
            this.baseName = baseName;
            this.bugreportFile = new File(bugreportsDir, getFileName(this, ".zip"));
            this.extraAttachment = extraAttachment;
        }

        void createBugreportFile() {
+32 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2024 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24.0dp"
    android:height="24.0dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0"
    android:tint="?attr/colorControlNormal">
    <path
        android:fillColor="#FF000000"
        android:pathData="M20,10V8h-2.81c-0.45,-0.78 -1.07,-1.46 -1.82,-1.96L17,4.41L15.59,3l-2.17,2.17c-0.03,-0.01 -0.05,-0.01 -0.08,-0.01c-0.16,-0.04 -0.32,-0.06 -0.49,-0.09c-0.06,-0.01 -0.11,-0.02 -0.17,-0.03C12.46,5.02 12.23,5 12,5h0c-0.49,0 -0.97,0.07 -1.42,0.18l0.02,-0.01L8.41,3L7,4.41l1.62,1.63l0.01,0C7.88,6.54 7.26,7.22 6.81,8H4v2h2.09C6.03,10.33 6,10.66 6,11v1H4v2h2v1c0,0.34 0.04,0.67 0.09,1H4v2h2.81c1.04,1.79 2.97,3 5.19,3h0c2.22,0 4.15,-1.21 5.19,-3H20v-2h-2.09l0,0c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1l0,0H20zM16,15c0,2.21 -1.79,4 -4,4c-2.21,0 -4,-1.79 -4,-4v-4c0,-2.21 1.79,-4 4,-4h0c2.21,0 4,1.79 4,4V15z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M10,14h4v2h-4z"/>
    <path
        android:fillColor="#FF000000"
        android:pathData="M10,10h4v2h-4z"/>
</vector>
 No newline at end of file
+41 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@
            android:layout_weight="0"
            android:src="@drawable/ic_screenrecord"
            app:tint="?androidprv:attr/materialColorOnSurface"
            android:importantForAccessibility="no"
            android:layout_gravity="center"
            android:layout_marginEnd="@dimen/screenrecord_option_padding" />

@@ -78,4 +79,44 @@
            android:layout_weight="0"
            android:contentDescription="@string/quick_settings_screen_record_label" />
    </LinearLayout>

    <!-- Bug Report Switch -->
    <LinearLayout
        android:id="@+id/bugreport_switch_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/qqs_layout_margin_top"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="@dimen/screenrecord_option_icon_size"
            android:layout_height="@dimen/screenrecord_option_icon_size"
            android:layout_weight="0"
            android:src="@drawable/ic_bugreport"
            app:tint="?androidprv:attr/materialColorOnSurface"
            android:importantForAccessibility="no"
            android:layout_gravity="center"
            android:layout_marginEnd="@dimen/screenrecord_option_padding" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:minHeight="@dimen/screenrecord_option_icon_size"
            android:layout_weight="1"
            android:layout_gravity="fill_vertical"
            android:gravity="center"
            android:text="@string/qs_record_issue_bug_report"
            android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
            android:importantForAccessibility="no"/>

        <Switch
            android:id="@+id/bugreport_switch"
            android:layout_width="wrap_content"
            android:minHeight="@dimen/screenrecord_option_icon_size"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_gravity="fill_vertical"
            android:layout_weight="0"
            android:contentDescription="@string/qs_record_issue_bug_report" />
    </LinearLayout>
</LinearLayout>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -872,6 +872,8 @@
    <string name="qs_record_issue_start">Start</string>
    <!-- QuickSettings: Text to prompt the user to stop an ongoing recording [CHAR LIMIT=20] -->
    <string name="qs_record_issue_stop">Stop</string>
    <!-- QuickSettings: Should user take a bugreport or only share trace files [CHAR LIMIT=20] -->
    <string name="qs_record_issue_bug_report">Bug Report</string>

    <!-- QuickSettings: Issue Type Drop down options in Record Issue Start Dialog [CHAR LIMIT=50] -->
    <string name="qs_record_issue_dropdown_header">What part of your device experience was affected?</string>
Loading