blob: db12bf2bc79355e57d974eaa4d40257847a59911 [file] [log] [blame]
Colin Crossf45fa6b2012-03-26 12:38:26 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Arve Hjønnevåg2db0f5f2014-10-15 18:08:37 -070017#include <dirent.h>
Colin Crossf45fa6b2012-03-26 12:38:26 -070018#include <errno.h>
19#include <fcntl.h>
20#include <limits.h>
Mark Salyzyn8f37aa52015-06-12 12:28:24 -070021#include <stdbool.h>
Colin Crossf45fa6b2012-03-26 12:38:26 -070022#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
Christopher Ferris7dc7f322014-07-22 16:08:19 -070025#include <sys/capability.h>
26#include <sys/prctl.h>
Colin Crossf45fa6b2012-03-26 12:38:26 -070027#include <sys/resource.h>
28#include <sys/stat.h>
29#include <sys/time.h>
30#include <sys/wait.h>
31#include <unistd.h>
Colin Crossf45fa6b2012-03-26 12:38:26 -070032
33#include <cutils/properties.h>
34
35#include "private/android_filesystem_config.h"
36
37#define LOG_TAG "dumpstate"
Alex Ray656a6b92013-07-23 13:44:34 -070038#include <cutils/log.h>
Colin Crossf45fa6b2012-03-26 12:38:26 -070039
40#include "dumpstate.h"
41
42/* read before root is shed */
43static char cmdline_buf[16384] = "(unknown)";
44static const char *dump_traces_path = NULL;
45
46static char screenshot_path[PATH_MAX] = "";
47
Todd Poynor2a83daa2013-11-22 15:44:22 -080048#define PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops"
49
Sharvil Nanavati8d4cb7f2015-07-24 02:01:13 -070050#define RAFT_DIR "/data/misc/raft/"
Christopher Ferris7dc7f322014-07-22 16:08:19 -070051#define TOMBSTONE_DIR "/data/tombstones"
52#define TOMBSTONE_FILE_PREFIX TOMBSTONE_DIR "/tombstone_"
53/* Can accomodate a tombstone number up to 9999. */
54#define TOMBSTONE_MAX_LEN (sizeof(TOMBSTONE_FILE_PREFIX) + 4)
55#define NUM_TOMBSTONES 10
56
57typedef struct {
58 char name[TOMBSTONE_MAX_LEN];
59 int fd;
60} tombstone_data_t;
61
62static tombstone_data_t tombstone_data[NUM_TOMBSTONES];
63
64/* Get the fds of any tombstone that was modified in the last half an hour. */
65static void get_tombstone_fds(tombstone_data_t data[NUM_TOMBSTONES]) {
66 time_t thirty_minutes_ago = time(NULL) - 60*30;
67 for (size_t i = 0; i < NUM_TOMBSTONES; i++) {
68 snprintf(data[i].name, sizeof(data[i].name), "%s%02zu", TOMBSTONE_FILE_PREFIX, i);
Christopher Ferris54bcc5f2015-02-10 12:15:01 -080069 int fd = TEMP_FAILURE_RETRY(open(data[i].name,
70 O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK));
Christopher Ferris7dc7f322014-07-22 16:08:19 -070071 struct stat st;
72 if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode) &&
73 (time_t) st.st_mtime >= thirty_minutes_ago) {
74 data[i].fd = fd;
75 } else {
76 close(fd);
77 data[i].fd = -1;
78 }
79 }
80}
81
Arve Hjønnevåg2db0f5f2014-10-15 18:08:37 -070082static void dump_dev_files(const char *title, const char *driverpath, const char *filename)
83{
84 DIR *d;
85 struct dirent *de;
86 char path[PATH_MAX];
87
88 d = opendir(driverpath);
89 if (d == NULL) {
90 return;
91 }
92
93 while ((de = readdir(d))) {
94 if (de->d_type != DT_LNK) {
95 continue;
96 }
97 snprintf(path, sizeof(path), "%s/%s/%s", driverpath, de->d_name, filename);
98 dump_file(title, path);
99 }
100
101 closedir(d);
102}
103
Mark Salyzyn326842f2015-04-30 09:49:41 -0700104static bool skip_not_stat(const char *path) {
105 static const char stat[] = "/stat";
106 size_t len = strlen(path);
107 if (path[len - 1] == '/') { /* Directory? */
108 return false;
109 }
110 return strcmp(path + len - sizeof(stat) + 1, stat); /* .../stat? */
111}
112
113static const char mmcblk0[] = "/sys/block/mmcblk0/";
Mark Salyzyn8f37aa52015-06-12 12:28:24 -0700114unsigned long worst_write_perf = 20000; /* in KB/s */
Mark Salyzyn326842f2015-04-30 09:49:41 -0700115
Mark Salyzyn01d6c392016-02-04 09:20:44 -0800116//
117// stat offsets
118// Name units description
119// ---- ----- -----------
120// read I/Os requests number of read I/Os processed
121#define __STAT_READ_IOS 0
122// read merges requests number of read I/Os merged with in-queue I/O
123#define __STAT_READ_MERGES 1
124// read sectors sectors number of sectors read
125#define __STAT_READ_SECTORS 2
126// read ticks milliseconds total wait time for read requests
127#define __STAT_READ_TICKS 3
128// write I/Os requests number of write I/Os processed
129#define __STAT_WRITE_IOS 4
130// write merges requests number of write I/Os merged with in-queue I/O
131#define __STAT_WRITE_MERGES 5
132// write sectors sectors number of sectors written
133#define __STAT_WRITE_SECTORS 6
134// write ticks milliseconds total wait time for write requests
135#define __STAT_WRITE_TICKS 7
136// in_flight requests number of I/Os currently in flight
137#define __STAT_IN_FLIGHT 8
138// io_ticks milliseconds total time this block device has been active
139#define __STAT_IO_TICKS 9
140// time_in_queue milliseconds total wait time for all requests
141#define __STAT_IN_QUEUE 10
142#define __STAT_NUMBER_FIELD 11
143//
144// read I/Os, write I/Os
145// =====================
146//
147// These values increment when an I/O request completes.
148//
149// read merges, write merges
150// =========================
151//
152// These values increment when an I/O request is merged with an
153// already-queued I/O request.
154//
155// read sectors, write sectors
156// ===========================
157//
158// These values count the number of sectors read from or written to this
159// block device. The "sectors" in question are the standard UNIX 512-byte
160// sectors, not any device- or filesystem-specific block size. The
161// counters are incremented when the I/O completes.
162#define SECTOR_SIZE 512
163//
164// read ticks, write ticks
165// =======================
166//
167// These values count the number of milliseconds that I/O requests have
168// waited on this block device. If there are multiple I/O requests waiting,
169// these values will increase at a rate greater than 1000/second; for
170// example, if 60 read requests wait for an average of 30 ms, the read_ticks
171// field will increase by 60*30 = 1800.
172//
173// in_flight
174// =========
175//
176// This value counts the number of I/O requests that have been issued to
177// the device driver but have not yet completed. It does not include I/O
178// requests that are in the queue but not yet issued to the device driver.
179//
180// io_ticks
181// ========
182//
183// This value counts the number of milliseconds during which the device has
184// had I/O requests queued.
185//
186// time_in_queue
187// =============
188//
189// This value counts the number of milliseconds that I/O requests have waited
190// on this block device. If there are multiple I/O requests waiting, this
191// value will increase as the product of the number of milliseconds times the
192// number of requests waiting (see "read ticks" above for an example).
193#define S_TO_MS 1000
194//
195
Mark Salyzyn326842f2015-04-30 09:49:41 -0700196static int dump_stat_from_fd(const char *title __unused, const char *path, int fd) {
Mark Salyzyn01d6c392016-02-04 09:20:44 -0800197 unsigned long long fields[__STAT_NUMBER_FIELD];
Mark Salyzyn326842f2015-04-30 09:49:41 -0700198 bool z;
199 char *cp, *buffer = NULL;
200 size_t i = 0;
201 FILE *fp = fdopen(fd, "rb");
202 getline(&buffer, &i, fp);
203 fclose(fp);
204 if (!buffer) {
205 return -errno;
206 }
207 i = strlen(buffer);
208 while ((i > 0) && (buffer[i - 1] == '\n')) {
209 buffer[--i] = '\0';
210 }
211 if (!*buffer) {
212 free(buffer);
213 return 0;
214 }
215 z = true;
216 for (cp = buffer, i = 0; i < (sizeof(fields) / sizeof(fields[0])); ++i) {
Mark Salyzyn01d6c392016-02-04 09:20:44 -0800217 fields[i] = strtoull(cp, &cp, 10);
Mark Salyzyn326842f2015-04-30 09:49:41 -0700218 if (fields[i] != 0) {
219 z = false;
220 }
221 }
222 if (z) { /* never accessed */
223 free(buffer);
224 return 0;
225 }
226
227 if (!strncmp(path, mmcblk0, sizeof(mmcblk0) - 1)) {
228 path += sizeof(mmcblk0) - 1;
229 }
230
231 printf("%s: %s\n", path, buffer);
232 free(buffer);
233
Mark Salyzyn01d6c392016-02-04 09:20:44 -0800234 if (fields[__STAT_IO_TICKS]) {
235 unsigned long read_perf = 0;
236 unsigned long read_ios = 0;
237 if (fields[__STAT_READ_TICKS]) {
238 unsigned long long divisor = fields[__STAT_READ_TICKS]
239 * fields[__STAT_IO_TICKS];
240 read_perf = ((unsigned long long)SECTOR_SIZE
241 * fields[__STAT_READ_SECTORS]
242 * fields[__STAT_IN_QUEUE] + (divisor >> 1))
243 / divisor;
244 read_ios = ((unsigned long long)S_TO_MS * fields[__STAT_READ_IOS]
245 * fields[__STAT_IN_QUEUE] + (divisor >> 1))
246 / divisor;
247 }
248
249 unsigned long write_perf = 0;
250 unsigned long write_ios = 0;
251 if (fields[__STAT_WRITE_TICKS]) {
252 unsigned long long divisor = fields[__STAT_WRITE_TICKS]
253 * fields[__STAT_IO_TICKS];
254 write_perf = ((unsigned long long)SECTOR_SIZE
255 * fields[__STAT_WRITE_SECTORS]
256 * fields[__STAT_IN_QUEUE] + (divisor >> 1))
257 / divisor;
258 write_ios = ((unsigned long long)S_TO_MS * fields[__STAT_WRITE_IOS]
259 * fields[__STAT_IN_QUEUE] + (divisor >> 1))
260 / divisor;
261 }
262
263 unsigned queue = (fields[__STAT_IN_QUEUE]
264 + (fields[__STAT_IO_TICKS] >> 1))
265 / fields[__STAT_IO_TICKS];
266
267 if (!write_perf && !write_ios) {
268 printf("%s: perf(ios) rd: %luKB/s(%lu/s) q: %u\n",
269 path, read_perf, read_ios, queue);
270 } else {
271 printf("%s: perf(ios) rd: %luKB/s(%lu/s) wr: %luKB/s(%lu/s) q: %u\n",
272 path, read_perf, read_ios, write_perf, write_ios, queue);
273 }
274
275 /* bugreport timeout factor adjustment */
276 if ((write_perf > 1) && (write_perf < worst_write_perf)) {
277 worst_write_perf = write_perf;
278 }
Mark Salyzyn8f37aa52015-06-12 12:28:24 -0700279 }
Mark Salyzyn326842f2015-04-30 09:49:41 -0700280 return 0;
281}
282
Mark Salyzyn8f37aa52015-06-12 12:28:24 -0700283/* Copied policy from system/core/logd/LogBuffer.cpp */
284
285#define LOG_BUFFER_SIZE (256 * 1024)
286#define LOG_BUFFER_MIN_SIZE (64 * 1024UL)
287#define LOG_BUFFER_MAX_SIZE (256 * 1024 * 1024UL)
288
289static bool valid_size(unsigned long value) {
290 if ((value < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < value)) {
291 return false;
292 }
293
294 long pages = sysconf(_SC_PHYS_PAGES);
295 if (pages < 1) {
296 return true;
297 }
298
299 long pagesize = sysconf(_SC_PAGESIZE);
300 if (pagesize <= 1) {
301 pagesize = PAGE_SIZE;
302 }
303
304 // maximum memory impact a somewhat arbitrary ~3%
305 pages = (pages + 31) / 32;
306 unsigned long maximum = pages * pagesize;
307
308 if ((maximum < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < maximum)) {
309 return true;
310 }
311
312 return value <= maximum;
313}
314
315static unsigned long property_get_size(const char *key) {
316 unsigned long value;
317 char *cp, property[PROPERTY_VALUE_MAX];
318
319 property_get(key, property, "");
320 value = strtoul(property, &cp, 10);
321
322 switch(*cp) {
323 case 'm':
324 case 'M':
325 value *= 1024;
326 /* FALLTHRU */
327 case 'k':
328 case 'K':
329 value *= 1024;
330 /* FALLTHRU */
331 case '\0':
332 break;
333
334 default:
335 value = 0;
336 }
337
338 if (!valid_size(value)) {
339 value = 0;
340 }
341
342 return value;
343}
344
345/* timeout in ms */
Felipe Leme515eb0d2015-12-14 15:09:56 -0800346static unsigned long logcat_timeout(const char *name) {
Mark Salyzyn8f37aa52015-06-12 12:28:24 -0700347 static const char global_tuneable[] = "persist.logd.size"; // Settings App
348 static const char global_default[] = "ro.logd.size"; // BoardConfig.mk
349 char key[PROP_NAME_MAX];
350 unsigned long property_size, default_size;
351
352 default_size = property_get_size(global_tuneable);
353 if (!default_size) {
354 default_size = property_get_size(global_default);
355 }
356
357 snprintf(key, sizeof(key), "%s.%s", global_tuneable, name);
358 property_size = property_get_size(key);
359
360 if (!property_size) {
361 snprintf(key, sizeof(key), "%s.%s", global_default, name);
362 property_size = property_get_size(key);
363 }
364
365 if (!property_size) {
366 property_size = default_size;
367 }
368
369 if (!property_size) {
370 property_size = LOG_BUFFER_SIZE;
371 }
372
373 /* Engineering margin is ten-fold our guess */
374 return 10 * (property_size + worst_write_perf) / worst_write_perf;
375}
376
377/* End copy from system/core/logd/LogBuffer.cpp */
378
Colin Crossf45fa6b2012-03-26 12:38:26 -0700379/* dumps the current system state to stdout */
380static void dumpstate() {
Mark Salyzyn8f37aa52015-06-12 12:28:24 -0700381 unsigned long timeout;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700382 time_t now = time(NULL);
383 char build[PROPERTY_VALUE_MAX], fingerprint[PROPERTY_VALUE_MAX];
384 char radio[PROPERTY_VALUE_MAX], bootloader[PROPERTY_VALUE_MAX];
385 char network[PROPERTY_VALUE_MAX], date[80];
386 char build_type[PROPERTY_VALUE_MAX];
387
388 property_get("ro.build.display.id", build, "(unknown)");
389 property_get("ro.build.fingerprint", fingerprint, "(unknown)");
390 property_get("ro.build.type", build_type, "(unknown)");
391 property_get("ro.baseband", radio, "(unknown)");
392 property_get("ro.bootloader", bootloader, "(unknown)");
393 property_get("gsm.operator.alpha", network, "(unknown)");
394 strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", localtime(&now));
395
396 printf("========================================================\n");
397 printf("== dumpstate: %s\n", date);
398 printf("========================================================\n");
399
400 printf("\n");
401 printf("Build: %s\n", build);
402 printf("Build fingerprint: '%s'\n", fingerprint); /* format is important for other tools */
403 printf("Bootloader: %s\n", bootloader);
404 printf("Radio: %s\n", radio);
405 printf("Network: %s\n", network);
406
407 printf("Kernel: ");
408 dump_file(NULL, "/proc/version");
409 printf("Command line: %s\n", strtok(cmdline_buf, "\n"));
410 printf("\n");
411
Arve Hjønnevåg2db0f5f2014-10-15 18:08:37 -0700412 dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700413 run_command("UPTIME", 10, "uptime", NULL);
Mark Salyzyn326842f2015-04-30 09:49:41 -0700414 dump_files("UPTIME MMC PERF", mmcblk0, skip_not_stat, dump_stat_from_fd);
Mark Salyzyn8c8130e2015-12-09 11:21:28 -0800415 dump_emmc_ecsd("/d/mmc0/mmc0:0001/ext_csd");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700416 dump_file("MEMORY INFO", "/proc/meminfo");
Elliott Hughesb32c7e12015-11-13 11:32:48 -0800417 run_command("CPU INFO", 10, "top", "-n", "1", "-d", "1", "-m", "30", "-H", NULL);
Nick Kralevich2b1f88b2015-10-07 16:38:42 -0700418 run_command("PROCRANK", 20, SU_PATH, "root", "procrank", NULL);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700419 dump_file("VIRTUAL MEMORY STATS", "/proc/vmstat");
420 dump_file("VMALLOC INFO", "/proc/vmallocinfo");
421 dump_file("SLAB INFO", "/proc/slabinfo");
422 dump_file("ZONEINFO", "/proc/zoneinfo");
423 dump_file("PAGETYPEINFO", "/proc/pagetypeinfo");
424 dump_file("BUDDYINFO", "/proc/buddyinfo");
Colin Cross2281af92012-10-28 22:41:06 -0700425 dump_file("FRAGMENTATION INFO", "/d/extfrag/unusable_index");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700426
Colin Crossf45fa6b2012-03-26 12:38:26 -0700427 dump_file("KERNEL WAKELOCKS", "/proc/wakelocks");
Todd Poynor29e27a82012-05-22 17:54:59 -0700428 dump_file("KERNEL WAKE SOURCES", "/d/wakeup_sources");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700429 dump_file("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
Mathias Agopian85aea742012-08-08 15:32:02 -0700430 dump_file("KERNEL SYNC", "/d/sync");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700431
Elliott Hughesa3533a32015-10-30 16:17:49 -0700432 run_command("PROCESSES AND THREADS", 10, "ps", "-Z", "-t", "-p", "-P", NULL);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700433 run_command("LIBRANK", 10, "librank", NULL);
434
435 do_dmesg();
436
437 run_command("LIST OF OPEN FILES", 10, SU_PATH, "root", "lsof", NULL);
Jeff Brown1dc94e32014-09-11 14:15:27 -0700438 for_each_pid(do_showmap, "SMAPS OF ALL PROCESSES");
439 for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700440
Jeff Sharkey5a930032013-03-19 15:05:19 -0700441 if (screenshot_path[0]) {
442 ALOGI("taking screenshot\n");
443 run_command(NULL, 10, "/system/bin/screencap", "-p", screenshot_path, NULL);
444 ALOGI("wrote screenshot: %s\n", screenshot_path);
445 }
446
Colin Crossf45fa6b2012-03-26 12:38:26 -0700447 // dump_file("EVENT LOG TAGS", "/etc/event-log-tags");
Mark Salyzyn8f37aa52015-06-12 12:28:24 -0700448 // calculate timeout
449 timeout = logcat_timeout("main") + logcat_timeout("system") + logcat_timeout("crash");
450 if (timeout < 20000) {
451 timeout = 20000;
452 }
Mark Salyzyn78316382015-10-09 14:02:07 -0700453 run_command("SYSTEM LOG", timeout / 1000, "logcat", "-v", "threadtime",
454 "-v", "printable",
455 "-d",
456 "*:v", NULL);
Mark Salyzyn43afe5d2016-01-26 07:24:08 -0800457 timeout = logcat_timeout("events");
Mark Salyzyn8f37aa52015-06-12 12:28:24 -0700458 if (timeout < 20000) {
459 timeout = 20000;
460 }
Mark Salyzyn78316382015-10-09 14:02:07 -0700461 run_command("EVENT LOG", timeout / 1000, "logcat", "-b", "events",
462 "-v", "threadtime",
463 "-v", "printable",
464 "-d",
465 "*:v", NULL);
Mark Salyzyn8f37aa52015-06-12 12:28:24 -0700466 timeout = logcat_timeout("radio");
467 if (timeout < 20000) {
468 timeout = 20000;
469 }
Mark Salyzyn78316382015-10-09 14:02:07 -0700470 run_command("RADIO LOG", timeout / 1000, "logcat", "-b", "radio",
471 "-v", "threadtime",
472 "-v", "printable",
473 "-d",
474 "*:v", NULL);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700475
Mark Salyzynecc07632015-07-30 14:57:09 -0700476 run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL);
477
Jason Parks31baf8d2015-10-12 15:27:10 +0000478 run_command("RAFT LOGS", 300, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL);
Sharvil Nanavati8d4cb7f2015-07-24 02:01:13 -0700479
Colin Crossf45fa6b2012-03-26 12:38:26 -0700480 /* show the traces we collected in main(), if that was done */
481 if (dump_traces_path != NULL) {
482 dump_file("VM TRACES JUST NOW", dump_traces_path);
483 }
484
485 /* only show ANR traces if they're less than 15 minutes old */
486 struct stat st;
487 char anr_traces_path[PATH_MAX];
488 property_get("dalvik.vm.stack-trace-file", anr_traces_path, "");
489 if (!anr_traces_path[0]) {
490 printf("*** NO VM TRACES FILE DEFINED (dalvik.vm.stack-trace-file)\n\n");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700491 } else {
Christopher Ferris54bcc5f2015-02-10 12:15:01 -0800492 int fd = TEMP_FAILURE_RETRY(open(anr_traces_path,
493 O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK));
Christopher Ferris7dc7f322014-07-22 16:08:19 -0700494 if (fd < 0) {
495 printf("*** NO ANR VM TRACES FILE (%s): %s\n\n", anr_traces_path, strerror(errno));
496 } else {
497 dump_file_from_fd("VM TRACES AT LAST ANR", anr_traces_path, fd);
498 }
Colin Crossf45fa6b2012-03-26 12:38:26 -0700499 }
500
501 /* slow traces for slow operations */
502 if (anr_traces_path[0] != 0) {
503 int tail = strlen(anr_traces_path)-1;
504 while (tail > 0 && anr_traces_path[tail] != '/') {
505 tail--;
506 }
507 int i = 0;
508 while (1) {
509 sprintf(anr_traces_path+tail+1, "slow%02d.txt", i);
510 if (stat(anr_traces_path, &st)) {
511 // No traces file at this index, done with the files.
512 break;
513 }
514 dump_file("VM TRACES WHEN SLOW", anr_traces_path);
515 i++;
516 }
517 }
518
Christopher Ferris7dc7f322014-07-22 16:08:19 -0700519 int dumped = 0;
520 for (size_t i = 0; i < NUM_TOMBSTONES; i++) {
521 if (tombstone_data[i].fd != -1) {
522 dumped = 1;
523 dump_file_from_fd("TOMBSTONE", tombstone_data[i].name, tombstone_data[i].fd);
524 tombstone_data[i].fd = -1;
525 }
526 }
527 if (!dumped) {
528 printf("*** NO TOMBSTONES to dump in %s\n\n", TOMBSTONE_DIR);
529 }
530
Colin Crossf45fa6b2012-03-26 12:38:26 -0700531 dump_file("NETWORK DEV INFO", "/proc/net/dev");
532 dump_file("QTAGUID NETWORK INTERFACES INFO", "/proc/net/xt_qtaguid/iface_stat_all");
JP Abgrall012c2ea2012-05-16 20:49:29 -0700533 dump_file("QTAGUID NETWORK INTERFACES INFO (xt)", "/proc/net/xt_qtaguid/iface_stat_fmt");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700534 dump_file("QTAGUID CTRL INFO", "/proc/net/xt_qtaguid/ctrl");
535 dump_file("QTAGUID STATS INFO", "/proc/net/xt_qtaguid/stats");
536
Todd Poynor2a83daa2013-11-22 15:44:22 -0800537 if (!stat(PSTORE_LAST_KMSG, &st)) {
538 /* Also TODO: Make console-ramoops CAP_SYSLOG protected. */
539 dump_file("LAST KMSG", PSTORE_LAST_KMSG);
540 } else {
541 /* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */
542 dump_file("LAST KMSG", "/proc/last_kmsg");
543 }
544
Mark Salyzyn2262c162014-12-16 09:09:26 -0800545 /* kernels must set CONFIG_PSTORE_PMSG, slice up pstore with device tree */
Mark Salyzyn78316382015-10-09 14:02:07 -0700546 run_command("LAST LOGCAT", 10, "logcat", "-L",
547 "-b", "all",
548 "-v", "threadtime",
549 "-v", "printable",
550 "-d",
551 "*:v", NULL);
Mark Salyzyn2262c162014-12-16 09:09:26 -0800552
Colin Crossf45fa6b2012-03-26 12:38:26 -0700553 /* The following have a tendency to get wedged when wifi drivers/fw goes belly-up. */
Elliott Hughesa59828a2015-01-27 20:48:52 -0800554
555 run_command("NETWORK INTERFACES", 10, "ip", "link", NULL);
Lorenzo Colittid4c3d382014-07-30 14:38:20 +0900556
557 run_command("IPv4 ADDRESSES", 10, "ip", "-4", "addr", "show", NULL);
558 run_command("IPv6 ADDRESSES", 10, "ip", "-6", "addr", "show", NULL);
559
Colin Crossf45fa6b2012-03-26 12:38:26 -0700560 run_command("IP RULES", 10, "ip", "rule", "show", NULL);
561 run_command("IP RULES v6", 10, "ip", "-6", "rule", "show", NULL);
Sreeram Ramachandran2b3bba32014-07-08 15:40:55 -0700562
563 dump_route_tables();
564
Lorenzo Colittid4c3d382014-07-30 14:38:20 +0900565 run_command("ARP CACHE", 10, "ip", "-4", "neigh", "show", NULL);
566 run_command("IPv6 ND CACHE", 10, "ip", "-6", "neigh", "show", NULL);
567
Colin Crossf45fa6b2012-03-26 12:38:26 -0700568 run_command("IPTABLES", 10, SU_PATH, "root", "iptables", "-L", "-nvx", NULL);
569 run_command("IP6TABLES", 10, SU_PATH, "root", "ip6tables", "-L", "-nvx", NULL);
JP Abgrall012c2ea2012-05-16 20:49:29 -0700570 run_command("IPTABLE NAT", 10, SU_PATH, "root", "iptables", "-t", "nat", "-L", "-nvx", NULL);
571 /* no ip6 nat */
572 run_command("IPTABLE RAW", 10, SU_PATH, "root", "iptables", "-t", "raw", "-L", "-nvx", NULL);
573 run_command("IP6TABLE RAW", 10, SU_PATH, "root", "ip6tables", "-t", "raw", "-L", "-nvx", NULL);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700574
575 run_command("WIFI NETWORKS", 20,
Dmitry Shmidt1d6b97c2013-08-21 10:58:29 -0700576 SU_PATH, "root", "wpa_cli", "IFNAME=wlan0", "list_networks", NULL);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700577
Dmitry Shmidtc11f56e2012-11-07 10:42:05 -0800578#ifdef FWDUMP_bcmdhd
Lorenzo Colitti6afc38c2015-09-09 22:59:25 +0900579 run_command("ND OFFLOAD TABLE", 5,
580 SU_PATH, "root", "wlutil", "nd_hostip", NULL);
581
582 run_command("DUMP WIFI INTERNAL COUNTERS (1)", 20,
Dmitry Shmidtc11f56e2012-11-07 10:42:05 -0800583 SU_PATH, "root", "wlutil", "counters", NULL);
Lorenzo Colitti6afc38c2015-09-09 22:59:25 +0900584
585 run_command("ND OFFLOAD STATUS (1)", 5,
586 SU_PATH, "root", "wlutil", "nd_status", NULL);
587
Dmitry Shmidtc11f56e2012-11-07 10:42:05 -0800588#endif
Dmitry Shmidt0b2c9262012-11-07 11:09:46 -0800589 dump_file("INTERRUPTS (1)", "/proc/interrupts");
590
Lorenzo Colitti6afc38c2015-09-09 22:59:25 +0900591 run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "connectivity", "--diag", NULL);
592
Dmitry Shmidtc11f56e2012-11-07 10:42:05 -0800593#ifdef FWDUMP_bcmdhd
Colin Crossf45fa6b2012-03-26 12:38:26 -0700594 run_command("DUMP WIFI STATUS", 20,
595 SU_PATH, "root", "dhdutil", "-i", "wlan0", "dump", NULL);
Lorenzo Colitti6afc38c2015-09-09 22:59:25 +0900596
597 run_command("DUMP WIFI INTERNAL COUNTERS (2)", 20,
Colin Crossf45fa6b2012-03-26 12:38:26 -0700598 SU_PATH, "root", "wlutil", "counters", NULL);
Lorenzo Colitti6afc38c2015-09-09 22:59:25 +0900599
600 run_command("ND OFFLOAD STATUS (2)", 5,
601 SU_PATH, "root", "wlutil", "nd_status", NULL);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700602#endif
Dmitry Shmidt0b2c9262012-11-07 11:09:46 -0800603 dump_file("INTERRUPTS (2)", "/proc/interrupts");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700604
605 print_properties();
606
607 run_command("VOLD DUMP", 10, "vdc", "dump", NULL);
608 run_command("SECURE CONTAINERS", 10, "vdc", "asec", "list", NULL);
609
Ken Sumrall8f75fa72013-02-08 17:35:58 -0800610 run_command("FILESYSTEMS & FREE SPACE", 10, "df", NULL);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700611
Colin Crossf45fa6b2012-03-26 12:38:26 -0700612 run_command("LAST RADIO LOG", 10, "parse_radio_log", "/proc/last_radio_log", NULL);
613
614 printf("------ BACKLIGHTS ------\n");
615 printf("LCD brightness=");
616 dump_file(NULL, "/sys/class/leds/lcd-backlight/brightness");
617 printf("Button brightness=");
618 dump_file(NULL, "/sys/class/leds/button-backlight/brightness");
619 printf("Keyboard brightness=");
620 dump_file(NULL, "/sys/class/leds/keyboard-backlight/brightness");
621 printf("ALS mode=");
622 dump_file(NULL, "/sys/class/leds/lcd-backlight/als");
623 printf("LCD driver registers:\n");
624 dump_file(NULL, "/sys/class/leds/lcd-backlight/registers");
625 printf("\n");
626
627 /* Binder state is expensive to look at as it uses a lot of memory. */
628 dump_file("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log");
629 dump_file("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log");
630 dump_file("BINDER TRANSACTIONS", "/sys/kernel/debug/binder/transactions");
631 dump_file("BINDER STATS", "/sys/kernel/debug/binder/stats");
632 dump_file("BINDER STATE", "/sys/kernel/debug/binder/state");
633
Colin Crossf45fa6b2012-03-26 12:38:26 -0700634 printf("========================================================\n");
635 printf("== Board\n");
636 printf("========================================================\n");
637
638 dumpstate_board();
639 printf("\n");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700640
641 /* Migrate the ril_dumpstate to a dumpstate_board()? */
642 char ril_dumpstate_timeout[PROPERTY_VALUE_MAX] = {0};
643 property_get("ril.dumpstate.timeout", ril_dumpstate_timeout, "30");
644 if (strnlen(ril_dumpstate_timeout, PROPERTY_VALUE_MAX - 1) > 0) {
645 if (0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1)) {
646 // su does not exist on user builds, so try running without it.
647 // This way any implementations of vril-dump that do not require
648 // root can run on user builds.
649 run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout),
650 "vril-dump", NULL);
651 } else {
652 run_command("DUMP VENDOR RIL LOGS", atoi(ril_dumpstate_timeout),
653 SU_PATH, "root", "vril-dump", NULL);
654 }
655 }
656
657 printf("========================================================\n");
658 printf("== Android Framework Services\n");
659 printf("========================================================\n");
660
661 /* the full dumpsys is starting to take a long time, so we need
662 to increase its timeout. we really need to do the timeouts in
663 dumpsys itself... */
664 run_command("DUMPSYS", 60, "dumpsys", NULL);
665
666 printf("========================================================\n");
Dianne Hackborn02bea972013-06-26 18:59:09 -0700667 printf("== Checkins\n");
668 printf("========================================================\n");
669
Dianne Hackborn59b15162013-09-04 18:04:14 -0700670 run_command("CHECKIN BATTERYSTATS", 30, "dumpsys", "batterystats", "-c", NULL);
Dianne Hackborn3e5fa732013-07-03 16:51:15 -0700671 run_command("CHECKIN MEMINFO", 30, "dumpsys", "meminfo", "--checkin", NULL);
Dianne Hackborn02bea972013-06-26 18:59:09 -0700672 run_command("CHECKIN NETSTATS", 30, "dumpsys", "netstats", "--checkin", NULL);
Dianne Hackborn5cd46aa2013-07-09 15:01:40 -0700673 run_command("CHECKIN PROCSTATS", 30, "dumpsys", "procstats", "-c", NULL);
Dianne Hackborn1bd50682013-07-11 11:45:18 -0700674 run_command("CHECKIN USAGESTATS", 30, "dumpsys", "usagestats", "-c", NULL);
Ashish Sharma8b3e1332015-04-28 13:32:54 -0700675 run_command("CHECKIN PACKAGE", 30, "dumpsys", "package", "--checkin", NULL);
Dianne Hackborn02bea972013-06-26 18:59:09 -0700676
677 printf("========================================================\n");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700678 printf("== Running Application Activities\n");
679 printf("========================================================\n");
680
681 run_command("APP ACTIVITIES", 30, "dumpsys", "activity", "all", NULL);
682
683 printf("========================================================\n");
684 printf("== Running Application Services\n");
685 printf("========================================================\n");
686
687 run_command("APP SERVICES", 30, "dumpsys", "activity", "service", "all", NULL);
688
689 printf("========================================================\n");
690 printf("== Running Application Providers\n");
691 printf("========================================================\n");
692
693 run_command("APP SERVICES", 30, "dumpsys", "activity", "provider", "all", NULL);
694
695
696 printf("========================================================\n");
697 printf("== dumpstate: done\n");
698 printf("========================================================\n");
699}
700
701static void usage() {
John Michelau1f794c42012-09-17 11:20:19 -0500702 fprintf(stderr, "usage: dumpstate [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-z]] [-s] [-q]\n"
Colin Crossf45fa6b2012-03-26 12:38:26 -0700703 " -o: write to file (instead of stdout)\n"
704 " -d: append date to filename (requires -o)\n"
Colin Crossf45fa6b2012-03-26 12:38:26 -0700705 " -p: capture screenshot to filename.png (requires -o)\n"
706 " -s: write output to control socket (for init)\n"
707 " -b: play sound file instead of vibrate, at beginning of job\n"
708 " -e: play sound file instead of vibrate, at end of job\n"
John Michelau1f794c42012-09-17 11:20:19 -0500709 " -q: disable vibrate\n"
Jeff Sharkey27f9e6d2013-03-13 15:45:50 -0700710 " -B: send broadcast when finished (requires -o and -p)\n"
Todd Poynor2a83daa2013-11-22 15:44:22 -0800711 );
Colin Crossf45fa6b2012-03-26 12:38:26 -0700712}
713
John Michelau885f8882013-05-06 16:42:02 -0500714static void sigpipe_handler(int n) {
Andres Morales2e671bb2014-08-21 12:38:22 -0700715 // don't complain to stderr or stdout
716 _exit(EXIT_FAILURE);
John Michelau885f8882013-05-06 16:42:02 -0500717}
718
Jeff Brown1dc94e32014-09-11 14:15:27 -0700719static void vibrate(FILE* vibrator, int ms) {
720 fprintf(vibrator, "%d\n", ms);
721 fflush(vibrator);
722}
723
Colin Crossf45fa6b2012-03-26 12:38:26 -0700724int main(int argc, char *argv[]) {
John Michelau885f8882013-05-06 16:42:02 -0500725 struct sigaction sigact;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700726 int do_add_date = 0;
John Michelau1f794c42012-09-17 11:20:19 -0500727 int do_vibrate = 1;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700728 char* use_outfile = 0;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700729 int use_socket = 0;
730 int do_fb = 0;
Jeff Sharkey27f9e6d2013-03-13 15:45:50 -0700731 int do_broadcast = 0;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700732
Nick Kralevich1e339872012-04-25 13:38:45 -0700733 if (getuid() != 0) {
734 // Old versions of the adb client would call the
735 // dumpstate command directly. Newer clients
736 // call /system/bin/bugreport instead. If we detect
737 // we're being called incorrectly, then exec the
738 // correct program.
739 return execl("/system/bin/bugreport", "/system/bin/bugreport", NULL);
740 }
Jeff Brown1dc94e32014-09-11 14:15:27 -0700741
Colin Crossf45fa6b2012-03-26 12:38:26 -0700742 ALOGI("begin\n");
743
Jeff Brown1dc94e32014-09-11 14:15:27 -0700744 /* clear SIGPIPE handler */
John Michelau885f8882013-05-06 16:42:02 -0500745 memset(&sigact, 0, sizeof(sigact));
746 sigact.sa_handler = sigpipe_handler;
747 sigaction(SIGPIPE, &sigact, NULL);
JP Abgrall3e03d3f2012-05-11 14:14:09 -0700748
Colin Crossf45fa6b2012-03-26 12:38:26 -0700749 /* set as high priority, and protect from OOM killer */
750 setpriority(PRIO_PROCESS, 0, -20);
Nick Kralevichcd67e9f2015-03-19 11:30:59 -0700751 FILE *oom_adj = fopen("/proc/self/oom_adj", "we");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700752 if (oom_adj) {
753 fputs("-17", oom_adj);
754 fclose(oom_adj);
755 }
756
Jeff Brown1dc94e32014-09-11 14:15:27 -0700757 /* parse arguments */
Colin Crossf45fa6b2012-03-26 12:38:26 -0700758 int c;
Jeff Brown1dc94e32014-09-11 14:15:27 -0700759 while ((c = getopt(argc, argv, "dho:svqzpB")) != -1) {
Colin Crossf45fa6b2012-03-26 12:38:26 -0700760 switch (c) {
Colin Crossf45fa6b2012-03-26 12:38:26 -0700761 case 'd': do_add_date = 1; break;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700762 case 'o': use_outfile = optarg; break;
763 case 's': use_socket = 1; break;
764 case 'v': break; // compatibility no-op
John Michelau1f794c42012-09-17 11:20:19 -0500765 case 'q': do_vibrate = 0; break;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700766 case 'p': do_fb = 1; break;
Jeff Sharkey27f9e6d2013-03-13 15:45:50 -0700767 case 'B': do_broadcast = 1; break;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700768 case '?': printf("\n");
769 case 'h':
770 usage();
771 exit(1);
772 }
773 }
774
Christopher Ferrised9354f2014-10-01 17:35:01 -0700775 // If we are going to use a socket, do it as early as possible
776 // to avoid timeouts from bugreport.
777 if (use_socket) {
778 redirect_to_socket(stdout, "dumpstate");
779 }
780
Jeff Brown1dc94e32014-09-11 14:15:27 -0700781 /* open the vibrator before dropping root */
John Michelau1f794c42012-09-17 11:20:19 -0500782 FILE *vibrator = 0;
783 if (do_vibrate) {
Nick Kralevichcd67e9f2015-03-19 11:30:59 -0700784 vibrator = fopen("/sys/class/timed_output/vibrator/enable", "we");
Jeff Brown1dc94e32014-09-11 14:15:27 -0700785 if (vibrator) {
Jeff Brown1dc94e32014-09-11 14:15:27 -0700786 vibrate(vibrator, 150);
787 }
John Michelau1f794c42012-09-17 11:20:19 -0500788 }
Colin Crossf45fa6b2012-03-26 12:38:26 -0700789
790 /* read /proc/cmdline before dropping root */
Nick Kralevichcd67e9f2015-03-19 11:30:59 -0700791 FILE *cmdline = fopen("/proc/cmdline", "re");
Colin Crossf45fa6b2012-03-26 12:38:26 -0700792 if (cmdline != NULL) {
793 fgets(cmdline_buf, sizeof(cmdline_buf), cmdline);
794 fclose(cmdline);
795 }
796
Jeff Brown1dc94e32014-09-11 14:15:27 -0700797 /* collect stack traces from Dalvik and native processes (needs root) */
798 dump_traces_path = dump_traces();
799
800 /* Get the tombstone fds here while we are running as root. */
801 get_tombstone_fds(tombstone_data);
802
803 /* ensure we will keep capabilities when we drop root */
Nick Kralevich1e339872012-04-25 13:38:45 -0700804 if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
805 ALOGE("prctl(PR_SET_KEEPCAPS) failed: %s\n", strerror(errno));
806 return -1;
807 }
Colin Crossf45fa6b2012-03-26 12:38:26 -0700808
Nick Kralevich1e339872012-04-25 13:38:45 -0700809 /* switch to non-root user and group */
810 gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW,
Nick Kralevichab46a492015-11-07 17:05:41 -0800811 AID_MOUNT, AID_INET, AID_NET_BW_STATS, AID_READPROC };
Nick Kralevich1e339872012-04-25 13:38:45 -0700812 if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
813 ALOGE("Unable to setgroups, aborting: %s\n", strerror(errno));
814 return -1;
815 }
816 if (setgid(AID_SHELL) != 0) {
817 ALOGE("Unable to setgid, aborting: %s\n", strerror(errno));
818 return -1;
819 }
820 if (setuid(AID_SHELL) != 0) {
821 ALOGE("Unable to setuid, aborting: %s\n", strerror(errno));
822 return -1;
823 }
Colin Crossf45fa6b2012-03-26 12:38:26 -0700824
Nick Kralevich1e339872012-04-25 13:38:45 -0700825 struct __user_cap_header_struct capheader;
826 struct __user_cap_data_struct capdata[2];
827 memset(&capheader, 0, sizeof(capheader));
828 memset(&capdata, 0, sizeof(capdata));
829 capheader.version = _LINUX_CAPABILITY_VERSION_3;
830 capheader.pid = 0;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700831
Nick Kralevich1e339872012-04-25 13:38:45 -0700832 capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = CAP_TO_MASK(CAP_SYSLOG);
833 capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = CAP_TO_MASK(CAP_SYSLOG);
834 capdata[0].inheritable = 0;
835 capdata[1].inheritable = 0;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700836
Nick Kralevich1e339872012-04-25 13:38:45 -0700837 if (capset(&capheader, &capdata[0]) < 0) {
838 ALOGE("capset failed: %s\n", strerror(errno));
839 return -1;
Colin Crossf45fa6b2012-03-26 12:38:26 -0700840 }
841
Jeff Brown1dc94e32014-09-11 14:15:27 -0700842 /* redirect output if needed */
Colin Crossf45fa6b2012-03-26 12:38:26 -0700843 char path[PATH_MAX], tmp_path[PATH_MAX];
844 pid_t gzip_pid = -1;
845
Christopher Ferrised9354f2014-10-01 17:35:01 -0700846 if (!use_socket && use_outfile) {
Colin Crossf45fa6b2012-03-26 12:38:26 -0700847 strlcpy(path, use_outfile, sizeof(path));
848 if (do_add_date) {
849 char date[80];
850 time_t now = time(NULL);
851 strftime(date, sizeof(date), "-%Y-%m-%d-%H-%M-%S", localtime(&now));
852 strlcat(path, date, sizeof(path));
853 }
854 if (do_fb) {
855 strlcpy(screenshot_path, path, sizeof(screenshot_path));
856 strlcat(screenshot_path, ".png", sizeof(screenshot_path));
857 }
858 strlcat(path, ".txt", sizeof(path));
Colin Crossf45fa6b2012-03-26 12:38:26 -0700859 strlcpy(tmp_path, path, sizeof(tmp_path));
860 strlcat(tmp_path, ".tmp", sizeof(tmp_path));
Christopher Ferrisff4a4dc2015-02-09 16:24:47 -0800861 redirect_to_file(stdout, tmp_path);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700862 }
863
Colin Crossf45fa6b2012-03-26 12:38:26 -0700864 dumpstate();
865
Jeff Brown1dc94e32014-09-11 14:15:27 -0700866 /* done */
867 if (vibrator) {
868 for (int i = 0; i < 3; i++) {
869 vibrate(vibrator, 75);
Colin Crossf45fa6b2012-03-26 12:38:26 -0700870 usleep((75 + 50) * 1000);
871 }
872 fclose(vibrator);
873 }
874
875 /* wait for gzip to finish, otherwise it might get killed when we exit */
876 if (gzip_pid > 0) {
877 fclose(stdout);
878 waitpid(gzip_pid, NULL, 0);
879 }
880
881 /* rename the (now complete) .tmp file to its final location */
882 if (use_outfile && rename(tmp_path, path)) {
883 fprintf(stderr, "rename(%s, %s): %s\n", tmp_path, path, strerror(errno));
884 }
885
Jeff Brown1dc94e32014-09-11 14:15:27 -0700886 /* tell activity manager we're done */
Jeff Sharkey27f9e6d2013-03-13 15:45:50 -0700887 if (do_broadcast && use_outfile && do_fb) {
Jeff Sharkeyaaaa57b2013-03-25 17:10:45 -0700888 run_command(NULL, 5, "/system/bin/am", "broadcast", "--user", "0",
Jeff Sharkey27f9e6d2013-03-13 15:45:50 -0700889 "-a", "android.intent.action.BUGREPORT_FINISHED",
890 "--es", "android.intent.extra.BUGREPORT", path,
891 "--es", "android.intent.extra.SCREENSHOT", screenshot_path,
892 "--receiver-permission", "android.permission.DUMP", NULL);
893 }
894
Colin Crossf45fa6b2012-03-26 12:38:26 -0700895 ALOGI("done\n");
896
897 return 0;
898}