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

Commit 1a83dede authored by Felipe Leme's avatar Felipe Leme
Browse files

Use a system property to call different bugreport types.

Currently, we define 4 hardcoded init services to launch dumpstate with
different command-line options (since dumpstate must be launched by
root):

- bugreport
- bugreportplus
- bugreportwear
- bugreportremote

This approach does not scale well; a better option is to have just one
service, and let the framework pass the extra arguments through a system
property.

BUG: 31649719

Test: manual
Change-Id: I1d627a73bfbdd9930c605fa4468c15282a23bb65
parent f97de8b1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ public class BugreportProgressService extends Service {
    /** System property (and value) used to stop dumpstate. */
    // TODO: should call ActiveManager API instead
    private static final String CTL_STOP = "ctl.stop";
    private static final String BUGREPORT_SERVICE = "bugreportplus";
    private static final String BUGREPORT_SERVICE = "bugreport";

    /**
     * Directory on Shell's data storage where screenshots will be stored.
+12 −10
Original line number Diff line number Diff line
@@ -12026,27 +12026,29 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    public void requestBugReport(int bugreportType) {
        String service = null;
        String extraOptions = null;
        switch (bugreportType) {
            case ActivityManager.BUGREPORT_OPTION_FULL:
                service = "bugreport";
                // Default options.
                break;
            case ActivityManager.BUGREPORT_OPTION_INTERACTIVE:
                service = "bugreportplus";
                extraOptions = "bugreportplus";
                break;
            case ActivityManager.BUGREPORT_OPTION_REMOTE:
                service = "bugreportremote";
                extraOptions = "bugreportremote";
                break;
            case ActivityManager.BUGREPORT_OPTION_WEAR:
                service = "bugreportwear";
                extraOptions = "bugreportwear";
                break;
        }
        if (service == null) {
            default:
                throw new IllegalArgumentException("Provided bugreport type is not correct, value: "
                        + bugreportType);
        }
        enforceCallingPermission(android.Manifest.permission.DUMP, "requestBugReport");
        SystemProperties.set("ctl.start", service);
        if (extraOptions != null) {
            SystemProperties.set("dumpstate.options", extraOptions);
        }
        SystemProperties.set("ctl.start", "bugreport");
    }
    public static long getInputDispatchingTimeoutLocked(ActivityRecord r) {