diff options
| author | 2020-12-07 21:08:28 +0000 | |
|---|---|---|
| committer | 2020-12-07 21:08:28 +0000 | |
| commit | 0cda9aa7ddf057ee50561357d76f93b96a20f69a (patch) | |
| tree | 839919cd2f7b7322bc36825683cfc87efaa98b01 | |
| parent | 6aca83735b47557181c512be853e818826548038 (diff) | |
| parent | bc37a46ff4438021a02d4c5409c89590c5fa5214 (diff) | |
Merge "Remove 'adb shell bugreport' command functionality" am: 89e8278090 am: 1b4a544500 am: bc37a46ff4
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1448616
Change-Id: Ie6d22d2617d551c7daa25991eddba255c6856d70
| -rw-r--r-- | cmds/bugreport/bugreport.cpp | 98 |
1 files changed, 13 insertions, 85 deletions
diff --git a/cmds/bugreport/bugreport.cpp b/cmds/bugreport/bugreport.cpp index e5c52d8dff..f81994b59e 100644 --- a/cmds/bugreport/bugreport.cpp +++ b/cmds/bugreport/bugreport.cpp @@ -14,91 +14,19 @@ * limitations under the License. */ -#include <errno.h> #include <stdio.h> -#include <sys/socket.h> -#include <sys/types.h> -#include <unistd.h> -#include <cutils/properties.h> -#include <cutils/sockets.h> - -// This program will trigger the dumpstate service to start a call to -// dumpstate, then connect to the dumpstate local client to read the -// output. All of the dumpstate output is written to stdout, including -// any errors encountered while reading/writing the output. -int main(int argc, char* /*argv*/[]) { - fprintf(stderr, "=============================================================================\n"); - fprintf(stderr, "WARNING: Flat (text file, non-zipped) bugreports are deprecated.\n"); - fprintf(stderr, "WARNING: Please generate zipped bugreports instead.\n"); - fprintf(stderr, "WARNING: On the host use: adb bugreport filename.zip\n"); - fprintf(stderr, "WARNING: On the device use: bugreportz\n"); - fprintf(stderr, "WARNING: bugreportz will output the filename to use with adb pull.\n"); - fprintf(stderr, "=============================================================================\n\n\n"); - - if (argc != 1) { - fprintf(stderr, "usage: bugreport\n"); - exit(1); - } - - // Start the dumpstate service. - property_set("ctl.start", "dumpstate"); - - // Socket will not be available until service starts. - int s = -1; - for (int i = 0; i < 20; i++) { - s = socket_local_client("dumpstate", ANDROID_SOCKET_NAMESPACE_RESERVED, - SOCK_STREAM); - if (s >= 0) - break; - // Try again in 1 second. - sleep(1); - } - - if (s == -1) { - printf("Failed to connect to dumpstate service: %s\n", strerror(errno)); - return 1; - } - - // Set a timeout so that if nothing is read in 3 minutes, we'll stop - // reading and quit. No timeout in dumpstate is longer than 60 seconds, - // so this gives lots of leeway in case of unforeseen time outs. - struct timeval tv; - tv.tv_sec = 3 * 60; - tv.tv_usec = 0; - if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) { - printf("WARNING: Cannot set socket timeout: %s\n", strerror(errno)); - } - - while (1) { - char buffer[65536]; - ssize_t bytes_read = TEMP_FAILURE_RETRY(read(s, buffer, sizeof(buffer))); - if (bytes_read == 0) { - break; - } else if (bytes_read == -1) { - // EAGAIN really means time out, so change the errno. - if (errno == EAGAIN) { - errno = ETIMEDOUT; - } - printf("\nBugreport read terminated abnormally (%s).\n", strerror(errno)); - break; - } - - ssize_t bytes_to_send = bytes_read; - ssize_t bytes_written; - do { - bytes_written = TEMP_FAILURE_RETRY(write(STDOUT_FILENO, - buffer + bytes_read - bytes_to_send, - bytes_to_send)); - if (bytes_written == -1) { - printf("Failed to write data to stdout: read %zd, trying to send %zd (%s)\n", - bytes_read, bytes_to_send, strerror(errno)); - return 1; - } - bytes_to_send -= bytes_written; - } while (bytes_written != 0 && bytes_to_send > 0); - } - - close(s); - return 0; +// Only prints a warning redirecting to bugreportz. +int main() { + fprintf(stderr, + "=============================================================================\n"); + fprintf(stderr, "WARNING: Flat (text file, non-zipped) bugreports are deprecated.\n"); + fprintf(stderr, "WARNING: Please generate zipped bugreports instead.\n"); + fprintf(stderr, "WARNING: On the host use: adb bugreport filename.zip\n"); + fprintf(stderr, "WARNING: On the device use: bugreportz\n"); + fprintf(stderr, "WARNING: bugreportz will output the filename to use with adb pull.\n"); + fprintf(stderr, + "=============================================================================\n\n\n"); + + return 0; } |