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

Commit 16207e33 authored by Abhijeet Kaur's avatar Abhijeet Kaur
Browse files

Remove enum logic from callers of requestbugreport()

Make callers use wrapper functions in ActivityManagerService.java.

requestTelephonyBugReport and requestWifiBugreports have already
existing wrapper functions which take 2 string parameters for title and
description. Passing empty strings in the cases where no title and
description is set.

Bug: 141355059
Bug: 137825297
Test: * builds
      * `adb shell am bug-report` takes full bugreport. Shows share
      notification
      * `adb shell am bug-report --progress` takes interactive
      bugreport. Shows progress notification and share notification
      * `adb shell am bug-report --telephony` takes telephony bugreport.
      Shows share notification.

Change-Id: Ibe479f4335613bfbddc65607ba89ad1805fcba9e
parent 70f1945f
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -665,8 +665,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
                        // Take an "interactive" bugreport.
                        MetricsLogger.action(mContext,
                                MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_INTERACTIVE);
                        ActivityManager.getService().requestBugReport(
                                ActivityManager.BUGREPORT_OPTION_INTERACTIVE);
                        ActivityManager.getService().requestInteractiveBugReport();
                    } catch (RemoteException e) {
                    }
                }
@@ -683,8 +682,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
            try {
                // Take a "full" bugreport.
                MetricsLogger.action(mContext, MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_FULL);
                ActivityManager.getService().requestBugReport(
                        ActivityManager.BUGREPORT_OPTION_FULL);
                ActivityManager.getService().requestFullBugReport();
            } catch (RemoteException e) {
            }
            return false;
+9 −4
Original line number Diff line number Diff line
@@ -1016,18 +1016,23 @@ final class ActivityManagerShellCommand extends ShellCommand {

    int runBugReport(PrintWriter pw) throws RemoteException {
        String opt;
        int bugreportType = ActivityManager.BUGREPORT_OPTION_FULL;
        boolean fullBugreport = true;
        while ((opt=getNextOption()) != null) {
            if (opt.equals("--progress")) {
                bugreportType = ActivityManager.BUGREPORT_OPTION_INTERACTIVE;
                fullBugreport = false;
                mInterface.requestInteractiveBugReport();
            } else if (opt.equals("--telephony")) {
                bugreportType = ActivityManager.BUGREPORT_OPTION_TELEPHONY;
                fullBugreport = false;
                // no title and description specified
                mInterface.requestTelephonyBugReport("" /* no title */, "" /* no descriptions */);
            } else {
                getErrPrintWriter().println("Error: Unknown option: " + opt);
                return -1;
            }
        }
        mInterface.requestBugReport(bugreportType);
        if (fullBugreport) {
            mInterface.requestFullBugReport();
        }
        pw.println("Your lovely bug report is being created; please be patient.");
        return 0;
    }
+2 −4
Original line number Diff line number Diff line
@@ -370,8 +370,7 @@ class LegacyGlobalActions implements DialogInterface.OnDismissListener, DialogIn
                        // Take an "interactive" bugreport.
                        MetricsLogger.action(mContext,
                                MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_INTERACTIVE);
                        ActivityManager.getService().requestBugReport(
                                ActivityManager.BUGREPORT_OPTION_INTERACTIVE);
                        ActivityManager.getService().requestInteractiveBugReport();
                    } catch (RemoteException e) {
                    }
                }
@@ -388,8 +387,7 @@ class LegacyGlobalActions implements DialogInterface.OnDismissListener, DialogIn
            try {
                // Take a "full" bugreport.
                MetricsLogger.action(mContext, MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_FULL);
                ActivityManager.getService().requestBugReport(
                        ActivityManager.BUGREPORT_OPTION_FULL);
                ActivityManager.getService().requestFullBugReport();
            } catch (RemoteException e) {
            }
            return false;
+1 −2
Original line number Diff line number Diff line
@@ -3120,8 +3120,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                || Settings.Global.getInt(mContext.getContentResolver(),
                        Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1) {
            try {
                ActivityManager.getService()
                        .requestBugReport(ActivityManager.BUGREPORT_OPTION_FULL);
                ActivityManager.getService().requestFullBugReport();
            } catch (RemoteException e) {
                Slog.e(TAG, "Error taking bugreport", e);
            }
+1 −2
Original line number Diff line number Diff line
@@ -7403,8 +7403,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        final long callingIdentity = mInjector.binderClearCallingIdentity();
        try {
            mInjector.getIActivityManager().requestBugReport(
                    ActivityManager.BUGREPORT_OPTION_REMOTE);
            mInjector.getIActivityManager().requestRemoteBugReport();
            mRemoteBugreportServiceIsActive.set(true);
            mRemoteBugreportSharingAccepted.set(false);