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

Commit bcb384b9 authored by Abhijeet Kaur's avatar Abhijeet Kaur
Browse files

Use bugreport mode enums from BugreportParams

All callers of requestBugReport(enum) have been migrated to use
wrappers, so it's safe to switch the internal enum we use for bugreport
mode from ActivityManager constants to BugreportParams enum.

Note that in requestBugReport() we have been passing ActivityManager
constant enum for INTERACTIVE bugreport, when sending an intent to
Shell, where BugreportPramas enum was expected, but it worked fine
because they had the same value. We can stop relying on that.

Bug: 137825297
Bug: 141355059
Test: Interactive bugreports created successfully
Change-Id: I1ab5d471a6d5c70fcd201719eae90f820e17cb80
parent b1c0a256
Loading
Loading
Loading
Loading
+0 −51
Original line number Diff line number Diff line
@@ -187,57 +187,6 @@ public class ActivityManager {

    final ArrayMap<OnUidImportanceListener, UidObserver> mImportanceListeners = new ArrayMap<>();

    /**
     * Defines acceptable types of bugreports.
     * @hide
     */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = { "BUGREPORT_OPTION_" }, value = {
            BUGREPORT_OPTION_FULL,
            BUGREPORT_OPTION_INTERACTIVE,
            BUGREPORT_OPTION_REMOTE,
            BUGREPORT_OPTION_WEAR,
            BUGREPORT_OPTION_TELEPHONY,
            BUGREPORT_OPTION_WIFI
    })
    public @interface BugreportMode {}
    /**
     * Takes a bugreport without user interference (and hence causing less
     * interference to the system), but includes all sections.
     * @hide
     */
    public static final int BUGREPORT_OPTION_FULL = 0;
    /**
     * Allows user to monitor progress and enter additional data; might not include all
     * sections.
     * @hide
     */
    public static final int BUGREPORT_OPTION_INTERACTIVE = 1;
    /**
     * Takes a bugreport requested remotely by administrator of the Device Owner app,
     * not the device's user.
     * @hide
     */
    public static final int BUGREPORT_OPTION_REMOTE = 2;
    /**
     * Takes a bugreport on a wearable device.
     * @hide
     */
    public static final int BUGREPORT_OPTION_WEAR = 3;

    /**
     * Takes a lightweight version of bugreport that only includes a few, urgent sections
     * used to report telephony bugs.
     * @hide
     */
    public static final int BUGREPORT_OPTION_TELEPHONY = 4;

    /**
     * Takes a lightweight bugreport that only includes a few sections related to Wifi.
     * @hide
     */
    public static final int BUGREPORT_OPTION_WIFI = 5;

    /**
     * <a href="{@docRoot}guide/topics/manifest/meta-data-element.html">{@code
     * <meta-data>}</a> name for a 'home' Activity that declares a package that is to be
+14 −13
Original line number Diff line number Diff line
@@ -233,6 +233,7 @@ import android.os.AppZygote;
import android.os.BatteryStats;
import android.os.Binder;
import android.os.BinderProxy;
import android.os.BugreportParams;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
@@ -8255,22 +8256,22 @@ public class ActivityManagerService extends IActivityManager.Stub
            @Nullable String shareDescription, int bugreportType) {
        String type = null;
        switch (bugreportType) {
            case ActivityManager.BUGREPORT_OPTION_FULL:
            case BugreportParams.BUGREPORT_MODE_FULL:
                type = "bugreportfull";
                break;
            case ActivityManager.BUGREPORT_OPTION_INTERACTIVE:
            case BugreportParams.BUGREPORT_MODE_INTERACTIVE:
                type = "bugreportplus";
                break;
            case ActivityManager.BUGREPORT_OPTION_REMOTE:
            case BugreportParams.BUGREPORT_MODE_REMOTE:
                type = "bugreportremote";
                break;
            case ActivityManager.BUGREPORT_OPTION_WEAR:
            case BugreportParams.BUGREPORT_MODE_WEAR:
                type = "bugreportwear";
                break;
            case ActivityManager.BUGREPORT_OPTION_TELEPHONY:
            case BugreportParams.BUGREPORT_MODE_TELEPHONY:
                type = "bugreporttelephony";
                break;
            case ActivityManager.BUGREPORT_OPTION_WIFI:
            case BugreportParams.BUGREPORT_MODE_WIFI:
                type = "bugreportwifi";
                break;
            default:
@@ -8305,7 +8306,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        final boolean useApi = FeatureFlagUtils.isEnabled(mContext,
                FeatureFlagUtils.USE_BUGREPORT_API);
        if (useApi && bugreportType == ActivityManager.BUGREPORT_OPTION_INTERACTIVE) {
        if (useApi && bugreportType == BugreportParams.BUGREPORT_MODE_INTERACTIVE) {
            // Create intent to trigger Bugreport API via Shell
            Intent triggerShellBugreport = new Intent();
            triggerShellBugreport.setAction(INTENT_BUGREPORT_REQUESTED);
@@ -8341,7 +8342,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public void requestTelephonyBugReport(String shareTitle, String shareDescription) {
        requestBugReportWithDescription(shareTitle, shareDescription,
                ActivityManager.BUGREPORT_OPTION_TELEPHONY);
                BugreportParams.BUGREPORT_MODE_TELEPHONY);
    }
    /**
@@ -8353,7 +8354,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Override
    public void requestWifiBugReport(String shareTitle, String shareDescription) {
        requestBugReportWithDescription(shareTitle, shareDescription,
                ActivityManager.BUGREPORT_OPTION_WIFI);
                BugreportParams.BUGREPORT_MODE_WIFI);
    }
    /**
@@ -8361,7 +8362,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
    @Override
    public void requestInteractiveBugReport() {
        requestBugReportWithDescription(null, null, ActivityManager.BUGREPORT_OPTION_INTERACTIVE);
        requestBugReportWithDescription(null, null, BugreportParams.BUGREPORT_MODE_INTERACTIVE);
    }
    /**
@@ -8372,7 +8373,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    public void requestInteractiveBugReportWithDescription(String shareTitle,
            String shareDescription) {
        requestBugReportWithDescription(shareTitle, shareDescription,
                ActivityManager.BUGREPORT_OPTION_INTERACTIVE);
                BugreportParams.BUGREPORT_MODE_INTERACTIVE);
    }
    /**
@@ -8380,7 +8381,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
    @Override
    public void requestFullBugReport() {
        requestBugReportWithDescription(null, null, ActivityManager.BUGREPORT_OPTION_FULL);
        requestBugReportWithDescription(null, null,  BugreportParams.BUGREPORT_MODE_FULL);
    }
    /**
@@ -8388,7 +8389,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     */
    @Override
    public void requestRemoteBugReport() {
        requestBugReportWithDescription(null, null, ActivityManager.BUGREPORT_OPTION_REMOTE);
        requestBugReportWithDescription(null, null, BugreportParams.BUGREPORT_MODE_REMOTE);
    }
    public void registerProcessObserver(IProcessObserver observer) {