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
This commit is contained in:
Nick Kralevich 2012-04-25 13:38:45 -07:00 committed by Dmitry Shmidt
parent a9a05d73f5
commit 1e339878c1
1 changed files with 40 additions and 34 deletions

View File

@ -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;