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

Commit 1e339878 authored by Nick Kralevich's avatar Nick Kralevich Committed by Dmitry Shmidt
Browse files

dumpstate: handle old style "adb bugreport"

When "adb bugreport" was run on previous adb releases, it
called "adb shell dumpstate". In later versions of Android,
this was changed to "adb shell bugreport", which starts
the dumpstate service.

Modify the dumpstate command so that it calls bugreport
when it's not running as root. This allows both
"adb shell dumpstate" and "adb shell bugreport" to have
the exact same output.

Bug: 6391938
Change-Id: Ia32bb9ebc579db3bee7caa0fe66dc3f124d60a12
parent a9a05d73
Loading
Loading
Loading
Loading
+42 −36
Original line number Diff line number Diff line
@@ -313,6 +313,14 @@ int main(int argc, char *argv[]) {
    int use_socket = 0;
    int do_fb = 0;

    if (getuid() != 0) {
        // Old versions of the adb client would call the
        // dumpstate command directly. Newer clients
        // call /system/bin/bugreport instead. If we detect
        // we're being called incorrectly, then exec the
        // correct program.
        return execl("/system/bin/bugreport", "/system/bin/bugreport", NULL);
    }
    ALOGI("begin\n");

    signal(SIGPIPE, SIG_IGN);
@@ -357,7 +365,6 @@ int main(int argc, char *argv[]) {
        fclose(cmdline);
    }

    if (getuid() == 0) {
    if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
        ALOGE("prctl(PR_SET_KEEPCAPS) failed: %s\n", strerror(errno));
        return -1;
@@ -395,7 +402,6 @@ int main(int argc, char *argv[]) {
        ALOGE("capset failed: %s\n", strerror(errno));
        return -1;
    }
    }

    char path[PATH_MAX], tmp_path[PATH_MAX];
    pid_t gzip_pid = -1;