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

Commit 4cc86333 authored by Felipe Leme's avatar Felipe Leme
Browse files

Changed ActivityManager.requestBugreport() to take a 'progress' parameter.

When progress is set to 'true', it calls the new, enhanced
'bugreportplus' service, while when 'false' it calls the regular
'bugreport' service.

'bugreportplus' is more user-friendly (it shows a system notification
with the progress, allow user to cancel, etc...), at the cost of
consuming more resources. As such, the "Take Bug Report" UI will be
changed to offer the user a combo with these 2 options, but for now it's
always going to be 'bugreportplus'

BUG: 26034608
Change-Id: I21a6b5b092a85614e91d523b8f4df1fb00e49b3b
parent 471c1adf
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ public class Am extends BaseCommand {
                "       am clear-debug-app\n" +
                "       am set-watch-heap <PROCESS> <MEM-LIMIT>\n" +
                "       am clear-watch-heap\n" +
                "       am bug-report [--progress]\n" +
                "       am monitor [--gdb <port>]\n" +
                "       am hang [--allow-restart]\n" +
                "       am restart\n" +
@@ -258,8 +259,9 @@ public class Am extends BaseCommand {
                "\n" +
                "am clear-watch-heap: clear the previously set-watch-heap.\n" +
                "\n" +
                "am bug-report: request bug report generation; will launch UI\n" +
                "    when done to select where it should be delivered.\n" +
                "am bug-report: request bug report generation; will launch a notification\n" +
                "    when done to select where it should be delivered. Options are: \n" +
                "   --progress: will launch a notification right away to show its progress.\n" +
                "\n" +
                "am monitor: start monitoring for crashes or ANRs.\n" +
                "    --gdb: start gdbserv on the given port at crash/ANR\n" +
@@ -1072,7 +1074,17 @@ public class Am extends BaseCommand {
    }

    private void runBugReport() throws Exception {
        mAm.requestBugReport();
        String opt;
        boolean progress = false;
        while ((opt=nextOption()) != null) {
            if (opt.equals("--progress")) {
                progress = true;
            } else {
                System.err.println("Error: Unknown option: " + opt);
                return;
            }
        }
        mAm.requestBugReport(progress);
        System.out.println("Your lovely bug report is being created; please be patient.");
    }

+4 −2
Original line number Diff line number Diff line
@@ -2228,7 +2228,8 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM

        case REQUEST_BUG_REPORT_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            requestBugReport();
            boolean progress = data.readInt() != 0;
            requestBugReport(progress);
            reply.writeNoException();
            return true;
        }
@@ -5600,10 +5601,11 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    public void requestBugReport() throws RemoteException {
    public void requestBugReport(boolean progress) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(progress ? 1 : 0);
        mRemote.transact(REQUEST_BUG_REPORT_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
+1 −1
Original line number Diff line number Diff line
@@ -437,7 +437,7 @@ public interface IActivityManager extends IInterface {
    public void registerUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException;
    public void unregisterUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException;

    public void requestBugReport() throws RemoteException;
    public void requestBugReport(boolean progress) throws RemoteException;

    public long inputDispatchingTimedOut(int pid, boolean aboveSystem, String reason)
            throws RemoteException;
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public class BugreportProgressService extends Service {

    /** System property (and value) used for stop dumpstate. */
    private static final String CTL_STOP = "ctl.stop";
    private static final String BUGREPORT_SERVICE = "bugreport";
    private static final String BUGREPORT_SERVICE = "bugreportplus";

    /** Managed dumpstate processes (keyed by pid) */
    private final SparseArray<BugreportInfo> mProcesses = new SparseArray<>();
+3 −2
Original line number Diff line number Diff line
@@ -11224,9 +11224,10 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    public void requestBugReport() {
    public void requestBugReport(boolean progress) {
        final String service = progress ? "bugreportplus" : "bugreport";
        enforceCallingPermission(android.Manifest.permission.DUMP, "requestBugReport");
        SystemProperties.set("ctl.start", "bugreport");
        SystemProperties.set("ctl.start", service);
    }
    public static long getInputDispatchingTimeoutLocked(ActivityRecord r) {
Loading