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

Commit 7875a421 authored by Abhijeet Kaur's avatar Abhijeet Kaur
Browse files

Turn on bugreport API workflow for all INTERACTIVE bugreports

Turn on API workflow in stages. Since, FULL bugreport type is more
widely used than INTERACTIVE bugreports, turn on the flag for a
smaller set first.

Test: build and flash. Interactive bugreport from power button uses API
workflow.
Bug:136548292

Change-Id: Ie4ff6c98d4b1cb89ae960c36605f4c0459d52c78
parent 725a25f7
Loading
Loading
Loading
Loading
+35 −34
Original line number Diff line number Diff line
@@ -8217,6 +8217,35 @@ public class ActivityManagerService extends IActivityManager.Stub
    @Deprecated
    public void requestBugReportWithDescription(@Nullable String shareTitle,
            @Nullable String shareDescription, int bugreportType) {
        String type = null;
        switch (bugreportType) {
            case ActivityManager.BUGREPORT_OPTION_FULL:
                type = "bugreportfull";
                break;
            case ActivityManager.BUGREPORT_OPTION_INTERACTIVE:
                type = "bugreportplus";
                break;
            case ActivityManager.BUGREPORT_OPTION_REMOTE:
                type = "bugreportremote";
                break;
            case ActivityManager.BUGREPORT_OPTION_WEAR:
                type = "bugreportwear";
                break;
            case ActivityManager.BUGREPORT_OPTION_TELEPHONY:
                type = "bugreporttelephony";
                break;
            case ActivityManager.BUGREPORT_OPTION_WIFI:
                type = "bugreportwifi";
                break;
            default:
                throw new IllegalArgumentException(
                    "Provided bugreport type is not correct, value: "
                        + bugreportType);
        }
        // Always log caller, even if it does not have permission to dump.
        Slog.i(TAG, type + " requested by UID " + Binder.getCallingUid());
        enforceCallingPermission(android.Manifest.permission.DUMP, "requestBugReport");
        if (!TextUtils.isEmpty(shareTitle)) {
            if (shareTitle.length() > MAX_BUGREPORT_TITLE_SIZE) {
                String errorStr = "shareTitle should be less than " +
@@ -8240,7 +8269,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        final boolean useApi = FeatureFlagUtils.isEnabled(mContext,
                FeatureFlagUtils.USE_BUGREPORT_API);
        if (useApi) {
        if (useApi && bugreportType == ActivityManager.BUGREPORT_OPTION_INTERACTIVE) {
            // Create intent to trigger Bugreport API via Shell
            Intent triggerShellBugreport = new Intent();
            triggerShellBugreport.setAction(INTENT_BUGREPORT_REQUESTED);
@@ -8252,41 +8281,13 @@ public class ActivityManagerService extends IActivityManager.Stub
            if (shareDescription != null) {
                triggerShellBugreport.putExtra(EXTRA_DESCRIPTION, shareDescription);
            }
        }
        String extraOptions = null;
        switch (bugreportType) {
            case ActivityManager.BUGREPORT_OPTION_FULL:
                extraOptions = "bugreportfull";
                break;
            case ActivityManager.BUGREPORT_OPTION_INTERACTIVE:
                extraOptions = "bugreportplus";
                break;
            case ActivityManager.BUGREPORT_OPTION_REMOTE:
                extraOptions = "bugreportremote";
                break;
            case ActivityManager.BUGREPORT_OPTION_WEAR:
                extraOptions = "bugreportwear";
                break;
            case ActivityManager.BUGREPORT_OPTION_TELEPHONY:
                extraOptions = "bugreporttelephony";
                break;
            case ActivityManager.BUGREPORT_OPTION_WIFI:
                extraOptions = "bugreportwifi";
                break;
            default:
                throw new IllegalArgumentException("Provided bugreport type is not correct, value: "
                        + bugreportType);
        }
        // Always log caller, even if it does not have permission to dump.
        String type = extraOptions == null ? "bugreport" : extraOptions;
        Slog.i(TAG, type + " requested by UID " + Binder.getCallingUid());
        enforceCallingPermission(android.Manifest.permission.DUMP, "requestBugReport");
        if (extraOptions != null) {
            SystemProperties.set("dumpstate.options", extraOptions);
        }
            // Send broadcast to shell to trigger bugreport using Bugreport API
            mContext.sendBroadcast(triggerShellBugreport);
        } else {
            SystemProperties.set("dumpstate.options", type);
            SystemProperties.set("ctl.start", "bugreport");
        }
    }
    /**
     * @deprecated This method is only used by a few internal components and it will soon be