blob: 2b19b93b87eec11aedf0912b21028fc2f9b713cb [file] [log] [blame]
Mark Salyzyn7b30ff82015-01-26 13:41:33 -08001// Copyright 2006-2015 The Android Open Source Project
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08002
Mark Salyzyn65772ca2013-12-13 11:10:11 -08003#include <assert.h>
4#include <ctype.h>
5#include <errno.h>
6#include <fcntl.h>
Aristidis Papaioannoueba73442014-10-16 22:19:55 -07007#include <math.h>
Mark Salyzyn65772ca2013-12-13 11:10:11 -08008#include <stdio.h>
9#include <stdlib.h>
10#include <stdarg.h>
11#include <string.h>
12#include <signal.h>
13#include <time.h>
14#include <unistd.h>
Traian Schiau59763032015-04-10 15:51:39 +030015#include <sys/cdefs.h>
Mark Salyzyn65772ca2013-12-13 11:10:11 -080016#include <sys/socket.h>
17#include <sys/stat.h>
18#include <arpa/inet.h>
19
20#include <cutils/sockets.h>
Mark Salyzyn95132e92013-11-22 10:55:48 -080021#include <log/log.h>
Mark Salyzynfa3716b2014-02-14 16:05:05 -080022#include <log/log_read.h>
Colin Cross9227bd32013-07-23 16:59:20 -070023#include <log/logger.h>
24#include <log/logd.h>
25#include <log/logprint.h>
26#include <log/event_tag_map.h>
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080027
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080028#define DEFAULT_MAX_ROTATED_LOGS 4
29
30static AndroidLogFormat * g_logformat;
31
32/* logd prefixes records with a length field */
33#define RECORD_LENGTH_FIELD_SIZE_BYTES sizeof(uint32_t)
34
Joe Onorato6fa09a02010-02-26 10:04:23 -080035struct log_device_t {
Mark Salyzyn95132e92013-11-22 10:55:48 -080036 const char* device;
Joe Onorato6fa09a02010-02-26 10:04:23 -080037 bool binary;
Mark Salyzyn95132e92013-11-22 10:55:48 -080038 struct logger *logger;
39 struct logger_list *logger_list;
Joe Onorato6fa09a02010-02-26 10:04:23 -080040 bool printed;
Joe Onorato6fa09a02010-02-26 10:04:23 -080041
Joe Onorato6fa09a02010-02-26 10:04:23 -080042 log_device_t* next;
43
Mark Salyzyn5f6738a2015-02-27 13:41:34 -080044 log_device_t(const char* d, bool b) {
Joe Onorato6fa09a02010-02-26 10:04:23 -080045 device = d;
46 binary = b;
Joe Onorato6fa09a02010-02-26 10:04:23 -080047 next = NULL;
48 printed = false;
Traian Schiau59763032015-04-10 15:51:39 +030049 logger = NULL;
50 logger_list = NULL;
Joe Onorato6fa09a02010-02-26 10:04:23 -080051 }
Joe Onorato6fa09a02010-02-26 10:04:23 -080052};
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080053
54namespace android {
55
56/* Global Variables */
57
58static const char * g_outputFileName = NULL;
Traian Schiau59763032015-04-10 15:51:39 +030059// 0 means "no log rotation"
60static size_t g_logRotateSizeKBytes = 0;
61// 0 means "unbounded"
62static size_t g_maxRotatedLogs = DEFAULT_MAX_ROTATED_LOGS;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080063static int g_outFD = -1;
Traian Schiau59763032015-04-10 15:51:39 +030064static size_t g_outByteCount = 0;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080065static int g_printBinary = 0;
Mark Salyzyn9421b0c2015-02-26 14:33:35 -080066static int g_devCount = 0; // >1 means multiple
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080067
Traian Schiau59763032015-04-10 15:51:39 +030068__noreturn static void logcat_panic(bool showHelp, const char *fmt, ...) __printflike(2,3);
69
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080070static int openLogFile (const char *pathname)
71{
Edwin Vane80b221c2012-08-13 12:55:07 -040072 return open(pathname, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080073}
74
75static void rotateLogs()
76{
77 int err;
78
79 // Can't rotate logs if we're not outputting to a file
80 if (g_outputFileName == NULL) {
81 return;
82 }
83
84 close(g_outFD);
85
Aristidis Papaioannoueba73442014-10-16 22:19:55 -070086 // Compute the maximum number of digits needed to count up to g_maxRotatedLogs in decimal.
87 // eg: g_maxRotatedLogs == 30 -> log10(30) == 1.477 -> maxRotationCountDigits == 2
88 int maxRotationCountDigits =
89 (g_maxRotatedLogs > 0) ? (int) (floor(log10(g_maxRotatedLogs) + 1)) : 0;
90
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080091 for (int i = g_maxRotatedLogs ; i > 0 ; i--) {
92 char *file0, *file1;
93
Aristidis Papaioannoueba73442014-10-16 22:19:55 -070094 asprintf(&file1, "%s.%.*d", g_outputFileName, maxRotationCountDigits, i);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080095
96 if (i - 1 == 0) {
97 asprintf(&file0, "%s", g_outputFileName);
98 } else {
Aristidis Papaioannoueba73442014-10-16 22:19:55 -070099 asprintf(&file0, "%s.%.*d", g_outputFileName, maxRotationCountDigits, i - 1);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800100 }
101
Traian Schiau59763032015-04-10 15:51:39 +0300102 if (!file0 || !file1) {
103 perror("while rotating log files");
104 break;
105 }
106
107 err = rename(file0, file1);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800108
109 if (err < 0 && errno != ENOENT) {
110 perror("while rotating log files");
111 }
112
113 free(file1);
114 free(file0);
115 }
116
Traian Schiau59763032015-04-10 15:51:39 +0300117 g_outFD = openLogFile(g_outputFileName);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800118
119 if (g_outFD < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300120 logcat_panic(false, "couldn't open output file");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800121 }
122
123 g_outByteCount = 0;
124
125}
126
Mark Salyzyn95132e92013-11-22 10:55:48 -0800127void printBinary(struct log_msg *buf)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800128{
Mark Salyzyn95132e92013-11-22 10:55:48 -0800129 size_t size = buf->len();
130
131 TEMP_FAILURE_RETRY(write(g_outFD, buf, size));
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800132}
133
Mark Salyzyn95132e92013-11-22 10:55:48 -0800134static void processBuffer(log_device_t* dev, struct log_msg *buf)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800135{
Mathias Agopian50844522010-03-17 16:10:26 -0700136 int bytesWritten = 0;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800137 int err;
138 AndroidLogEntry entry;
139 char binaryMsgBuf[1024];
140
Joe Onorato6fa09a02010-02-26 10:04:23 -0800141 if (dev->binary) {
Mark Salyzyn9421b0c2015-02-26 14:33:35 -0800142 static bool hasOpenedEventTagMap = false;
143 static EventTagMap *eventTagMap = NULL;
144
145 if (!eventTagMap && !hasOpenedEventTagMap) {
146 eventTagMap = android_openEventTagMap(EVENT_TAG_MAP_FILE);
147 hasOpenedEventTagMap = true;
148 }
Mark Salyzyn95132e92013-11-22 10:55:48 -0800149 err = android_log_processBinaryLogBuffer(&buf->entry_v1, &entry,
Mark Salyzyn9421b0c2015-02-26 14:33:35 -0800150 eventTagMap,
Mark Salyzyn95132e92013-11-22 10:55:48 -0800151 binaryMsgBuf,
152 sizeof(binaryMsgBuf));
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800153 //printf(">>> pri=%d len=%d msg='%s'\n",
154 // entry.priority, entry.messageLen, entry.message);
155 } else {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800156 err = android_log_processLogBuffer(&buf->entry_v1, &entry);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800157 }
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800158 if (err < 0) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800159 goto error;
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800160 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800161
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800162 if (android_log_shouldPrintLine(g_logformat, entry.tag, entry.priority)) {
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800163 bytesWritten = android_log_printLogLine(g_logformat, g_outFD, &entry);
164
165 if (bytesWritten < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300166 logcat_panic(false, "output error");
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800167 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800168 }
169
170 g_outByteCount += bytesWritten;
171
Mark Salyzyn95132e92013-11-22 10:55:48 -0800172 if (g_logRotateSizeKBytes > 0
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800173 && (g_outByteCount / 1024) >= g_logRotateSizeKBytes
174 ) {
175 rotateLogs();
176 }
177
178error:
179 //fprintf (stderr, "Error processing record\n");
180 return;
181}
182
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800183static void maybePrintStart(log_device_t* dev, bool printDividers) {
184 if (!dev->printed || printDividers) {
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800185 if (g_devCount > 1 && !g_printBinary) {
186 char buf[1024];
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800187 snprintf(buf, sizeof(buf), "--------- %s %s\n",
188 dev->printed ? "switch to" : "beginning of",
Mark Salyzyn95132e92013-11-22 10:55:48 -0800189 dev->device);
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800190 if (write(g_outFD, buf, strlen(buf)) < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300191 logcat_panic(false, "output error");
Joe Onorato6fa09a02010-02-26 10:04:23 -0800192 }
193 }
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800194 dev->printed = true;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800195 }
196}
197
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800198static void setupOutput()
199{
200
201 if (g_outputFileName == NULL) {
202 g_outFD = STDOUT_FILENO;
203
204 } else {
205 struct stat statbuf;
206
207 g_outFD = openLogFile (g_outputFileName);
208
209 if (g_outFD < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300210 logcat_panic(false, "couldn't open output file");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800211 }
212
Traian Schiau59763032015-04-10 15:51:39 +0300213 if (fstat(g_outFD, &statbuf) == -1) {
214 close(g_outFD);
215 logcat_panic(false, "couldn't get output file stat\n");
216 }
217
218 if ((size_t) statbuf.st_size > SIZE_MAX || statbuf.st_size < 0) {
219 close(g_outFD);
220 logcat_panic(false, "invalid output file stat\n");
221 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800222
223 g_outByteCount = statbuf.st_size;
224 }
225}
226
227static void show_help(const char *cmd)
228{
229 fprintf(stderr,"Usage: %s [options] [filterspecs]\n", cmd);
230
231 fprintf(stderr, "options include:\n"
232 " -s Set default filter to silent.\n"
Mark Salyzynbba894a2015-03-09 09:32:56 -0700233 " Like specifying filterspec '*:S'\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800234 " -f <filename> Log to file. Default to stdout\n"
Traian Schiau59763032015-04-10 15:51:39 +0300235 " -r <kbytes> Rotate log every kbytes. Requires -f\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800236 " -n <count> Sets max number of rotated logs to <count>, default 4\n"
Pierre Zurekead88fc2010-10-17 22:39:37 +0200237 " -v <format> Sets the log print format, where <format> is:\n\n"
238 " brief color long process raw tag thread threadtime time\n\n"
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800239 " -D print dividers between each log buffer\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800240 " -c clear (flush) the entire log and exit\n"
241 " -d dump the log and then exit (don't block)\n"
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800242 " -t <count> print only the most recent <count> lines (implies -d)\n"
Mark Salyzyn190b7ac2014-09-01 10:41:33 -0700243 " -t '<time>' print most recent lines since specified time (implies -d)\n"
Mark Salyzyn5d3d1f12013-12-09 13:47:00 -0800244 " -T <count> print only the most recent <count> lines (does not imply -d)\n"
Mark Salyzyn190b7ac2014-09-01 10:41:33 -0700245 " -T '<time>' print most recent lines since specified time (not imply -d)\n"
246 " count is pure numerical, time is 'MM-DD hh:mm:ss.mmm'\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800247 " -g get the size of the log's ring buffer and exit\n"
Mark Salyzyn7c975ac2014-12-15 10:01:31 -0800248 " -L dump logs from prior to last reboot\n"
Mark Salyzyn34facab2014-02-06 14:48:50 -0800249 " -b <buffer> Request alternate ring buffer, 'main', 'system', 'radio',\n"
Mark Salyzyn99f47a92014-04-07 14:58:08 -0700250 " 'events', 'crash' or 'all'. Multiple -b parameters are\n"
251 " allowed and results are interleaved. The default is\n"
252 " -b main -b system -b crash.\n"
Mark Salyzyn34facab2014-02-06 14:48:50 -0800253 " -B output the log in binary.\n"
Mark Salyzynbbbe14f2014-04-11 13:49:43 -0700254 " -S output statistics.\n"
255 " -G <size> set size of log ring buffer, may suffix with K or M.\n"
256 " -p print prune white and ~black list. Service is specified as\n"
257 " UID, UID/PID or /PID. Weighed for quicker pruning if prefix\n"
258 " with ~, otherwise weighed for longevity if unadorned. All\n"
259 " other pruning activity is oldest first. Special case ~!\n"
260 " represents an automatic quicker pruning for the noisiest\n"
261 " UID as determined by the current statistics.\n"
262 " -P '<list> ...' set prune white and ~black list, using same format as\n"
263 " printed above. Must be quoted.\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800264
265 fprintf(stderr,"\nfilterspecs are a series of \n"
266 " <tag>[:priority]\n\n"
267 "where <tag> is a log component tag (or * for all) and priority is:\n"
Mark Salyzynbba894a2015-03-09 09:32:56 -0700268 " V Verbose (default for <tag>)\n"
269 " D Debug (default for '*')\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800270 " I Info\n"
271 " W Warn\n"
272 " E Error\n"
273 " F Fatal\n"
Mark Salyzynbba894a2015-03-09 09:32:56 -0700274 " S Silent (suppress all output)\n"
275 "\n'*' by itself means '*:D' and <tag> by itself means <tag>:V.\n"
276 "If no '*' filterspec or -s on command line, all filter defaults to '*:V'.\n"
277 "eg: '*:S <tag>' prints only <tag>, '<tag>:S' suppresses all <tag> log messages.\n"
278 "\nIf not specified on the command line, filterspec is set from ANDROID_LOG_TAGS.\n"
279 "\nIf not specified with -v on command line, format is set from ANDROID_PRINTF_LOG\n"
Mark Salyzyn649fc602014-09-16 09:15:15 -0700280 "or defaults to \"threadtime\"\n\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800281}
282
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800283static int setLogFormat(const char * formatString)
284{
285 static AndroidLogPrintFormat format;
286
287 format = android_log_formatFromString(formatString);
288
289 if (format == FORMAT_OFF) {
290 // FORMAT_OFF means invalid string
291 return -1;
292 }
293
294 android_log_setPrintFormat(g_logformat, format);
295
296 return 0;
297}
298
Mark Salyzyn671e3432014-05-06 07:34:59 -0700299static const char multipliers[][2] = {
300 { "" },
301 { "K" },
302 { "M" },
303 { "G" }
304};
305
306static unsigned long value_of_size(unsigned long value)
307{
308 for (unsigned i = 0;
309 (i < sizeof(multipliers)/sizeof(multipliers[0])) && (value >= 1024);
310 value /= 1024, ++i) ;
311 return value;
312}
313
314static const char *multiplier_of_size(unsigned long value)
315{
316 unsigned i;
317 for (i = 0;
318 (i < sizeof(multipliers)/sizeof(multipliers[0])) && (value >= 1024);
319 value /= 1024, ++i) ;
320 return multipliers[i];
321}
322
Traian Schiau59763032015-04-10 15:51:39 +0300323/*String to unsigned int, returns -1 if it fails*/
324static bool getSizeTArg(char *ptr, size_t *val, size_t min = 0,
325 size_t max = SIZE_MAX)
326{
327 char *endp;
328 errno = 0;
329 size_t ret = (size_t) strtoll(ptr, &endp, 0);
330
331 if (endp[0] != '\0' || errno != 0 ) {
332 return false;
333 }
334
335 if (ret > max || ret < min) {
336 return false;
337 }
338
339 *val = ret;
340 return true;
341}
342
343static void logcat_panic(bool showHelp, const char *fmt, ...)
344{
Mark Salyzyn77d7e812015-04-13 09:27:57 -0700345 va_list args;
346 va_start(args, fmt);
347 vfprintf(stderr, fmt, args);
348 va_end(args);
Traian Schiau59763032015-04-10 15:51:39 +0300349
350 if (showHelp) {
351 show_help(getprogname());
352 }
353
354 exit(EXIT_FAILURE);
355}
356
357} /* namespace android */
358
359
Joe Onorato6fa09a02010-02-26 10:04:23 -0800360int main(int argc, char **argv)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800361{
Traian Schiau59763032015-04-10 15:51:39 +0300362 using namespace android;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800363 int err;
364 int hasSetLogFormat = 0;
365 int clearLog = 0;
366 int getLogSize = 0;
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800367 unsigned long setLogSize = 0;
368 int getPruneList = 0;
369 char *setPruneList = NULL;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800370 int printStatistics = 0;
Mark Salyzyn2d3f38a2015-01-26 10:46:44 -0800371 int mode = ANDROID_LOG_RDONLY;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800372 const char *forceFilters = NULL;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800373 log_device_t* devices = NULL;
374 log_device_t* dev;
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800375 bool printDividers = false;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800376 struct logger_list *logger_list;
Traian Schiau59763032015-04-10 15:51:39 +0300377 size_t tail_lines = 0;
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800378 log_time tail_time(log_time::EPOCH);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800379
Mark Salyzyn65772ca2013-12-13 11:10:11 -0800380 signal(SIGPIPE, exit);
381
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800382 g_logformat = android_log_format_new();
383
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800384 if (argc == 2 && 0 == strcmp(argv[1], "--help")) {
Traian Schiau59763032015-04-10 15:51:39 +0300385 show_help(argv[0]);
386 return EXIT_SUCCESS;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800387 }
388
389 for (;;) {
390 int ret;
391
Traian Schiau59763032015-04-10 15:51:39 +0300392 ret = getopt(argc, argv, ":cdDLt:T:gG:sQf:r:n:v:b:BSpP:");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800393
394 if (ret < 0) {
395 break;
396 }
397
398 switch(ret) {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800399 case 's':
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800400 // default to all silent
401 android_log_addFilterRule(g_logformat, "*:s");
402 break;
403
404 case 'c':
405 clearLog = 1;
Mark Salyzyn2d3f38a2015-01-26 10:46:44 -0800406 mode |= ANDROID_LOG_WRONLY;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800407 break;
408
Mark Salyzyn7c975ac2014-12-15 10:01:31 -0800409 case 'L':
410 mode |= ANDROID_LOG_PSTORE;
411 break;
412
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800413 case 'd':
Mark Salyzyn2d3f38a2015-01-26 10:46:44 -0800414 mode |= ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800415 break;
416
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800417 case 't':
Mark Salyzyn2d3f38a2015-01-26 10:46:44 -0800418 mode |= ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK;
Mark Salyzyn5d3d1f12013-12-09 13:47:00 -0800419 /* FALLTHRU */
420 case 'T':
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800421 if (strspn(optarg, "0123456789") != strlen(optarg)) {
422 char *cp = tail_time.strptime(optarg,
423 log_time::default_format);
424 if (!cp) {
Traian Schiau59763032015-04-10 15:51:39 +0300425 logcat_panic(false,
426 "-%c \"%s\" not in \"%s\" time format\n",
427 ret, optarg, log_time::default_format);
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800428 }
429 if (*cp) {
430 char c = *cp;
431 *cp = '\0';
432 fprintf(stderr,
433 "WARNING: -%c \"%s\"\"%c%s\" time truncated\n",
434 ret, optarg, c, cp + 1);
435 *cp = c;
436 }
437 } else {
Traian Schiau59763032015-04-10 15:51:39 +0300438 if (!getSizeTArg(optarg, &tail_lines, 1)) {
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800439 fprintf(stderr,
440 "WARNING: -%c %s invalid, setting to 1\n",
441 ret, optarg);
442 tail_lines = 1;
443 }
444 }
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800445 break;
446
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800447 case 'D':
448 printDividers = true;
449 break;
450
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800451 case 'g':
452 getLogSize = 1;
453 break;
454
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800455 case 'G': {
Traian Schiau59763032015-04-10 15:51:39 +0300456 char *cp;
457 if (strtoll(optarg, &cp, 0) > 0) {
458 setLogSize = strtoll(optarg, &cp, 0);
459 } else {
460 setLogSize = 0;
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800461 }
462
463 switch(*cp) {
464 case 'g':
465 case 'G':
466 setLogSize *= 1024;
467 /* FALLTHRU */
468 case 'm':
469 case 'M':
470 setLogSize *= 1024;
471 /* FALLTHRU */
472 case 'k':
473 case 'K':
474 setLogSize *= 1024;
475 /* FALLTHRU */
476 case '\0':
477 break;
478
479 default:
480 setLogSize = 0;
481 }
482
483 if (!setLogSize) {
484 fprintf(stderr, "ERROR: -G <num><multiplier>\n");
Traian Schiau59763032015-04-10 15:51:39 +0300485 return EXIT_FAILURE;
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800486 }
487 }
488 break;
489
490 case 'p':
491 getPruneList = 1;
492 break;
493
494 case 'P':
495 setPruneList = optarg;
496 break;
497
Joe Onorato6fa09a02010-02-26 10:04:23 -0800498 case 'b': {
Mark Salyzyn34facab2014-02-06 14:48:50 -0800499 if (strcmp(optarg, "all") == 0) {
500 while (devices) {
501 dev = devices;
502 devices = dev->next;
503 delete dev;
504 }
505
Mark Salyzynd0bd1b12014-10-10 15:25:38 -0700506 devices = dev = NULL;
Traian Schiau59763032015-04-10 15:51:39 +0300507 g_devCount = 0;
Mark Salyzynd0bd1b12014-10-10 15:25:38 -0700508 for(int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
509 const char *name = android_log_id_to_name((log_id_t)i);
510 log_id_t log_id = android_name_to_log_id(name);
511
512 if (log_id != (log_id_t)i) {
513 continue;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800514 }
Mark Salyzynd0bd1b12014-10-10 15:25:38 -0700515
516 bool binary = strcmp(name, "events") == 0;
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800517 log_device_t* d = new log_device_t(name, binary);
Mark Salyzynd0bd1b12014-10-10 15:25:38 -0700518
519 if (dev) {
520 dev->next = d;
521 dev = d;
522 } else {
523 devices = dev = d;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800524 }
Traian Schiau59763032015-04-10 15:51:39 +0300525 g_devCount++;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800526 }
527 break;
528 }
529
Joe Onorato6fa09a02010-02-26 10:04:23 -0800530 bool binary = strcmp(optarg, "events") == 0;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800531
532 if (devices) {
533 dev = devices;
534 while (dev->next) {
535 dev = dev->next;
536 }
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800537 dev->next = new log_device_t(optarg, binary);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800538 } else {
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800539 devices = new log_device_t(optarg, binary);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800540 }
Traian Schiau59763032015-04-10 15:51:39 +0300541 g_devCount++;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800542 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800543 break;
544
545 case 'B':
Traian Schiau59763032015-04-10 15:51:39 +0300546 g_printBinary = 1;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800547 break;
548
549 case 'f':
550 // redirect output to a file
Traian Schiau59763032015-04-10 15:51:39 +0300551 g_outputFileName = optarg;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800552
553 break;
554
555 case 'r':
Traian Schiau59763032015-04-10 15:51:39 +0300556 if (!getSizeTArg(optarg, &g_logRotateSizeKBytes, 1)) {
557 logcat_panic(true, "Invalid parameter %s to -r\n", optarg);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800558 }
559 break;
560
561 case 'n':
Traian Schiau59763032015-04-10 15:51:39 +0300562 if (!getSizeTArg(optarg, &g_maxRotatedLogs, 1)) {
563 logcat_panic(true, "Invalid parameter %s to -n\n", optarg);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800564 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800565 break;
566
567 case 'v':
568 err = setLogFormat (optarg);
569 if (err < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300570 logcat_panic(true, "Invalid parameter %s to -v\n", optarg);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800571 }
572
Mark Salyzyn649fc602014-09-16 09:15:15 -0700573 if (strcmp("color", optarg)) { // exception for modifiers
574 hasSetLogFormat = 1;
575 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800576 break;
577
578 case 'Q':
579 /* this is a *hidden* option used to start a version of logcat */
580 /* in an emulated device only. it basically looks for androidboot.logcat= */
581 /* on the kernel command line. If something is found, it extracts a log filter */
582 /* and uses it to run the program. If nothing is found, the program should */
583 /* quit immediately */
584#define KERNEL_OPTION "androidboot.logcat="
585#define CONSOLE_OPTION "androidboot.console="
586 {
587 int fd;
588 char* logcat;
589 char* console;
590 int force_exit = 1;
591 static char cmdline[1024];
592
593 fd = open("/proc/cmdline", O_RDONLY);
594 if (fd >= 0) {
595 int n = read(fd, cmdline, sizeof(cmdline)-1 );
596 if (n < 0) n = 0;
597 cmdline[n] = 0;
598 close(fd);
599 } else {
600 cmdline[0] = 0;
601 }
602
603 logcat = strstr( cmdline, KERNEL_OPTION );
604 console = strstr( cmdline, CONSOLE_OPTION );
605 if (logcat != NULL) {
606 char* p = logcat + sizeof(KERNEL_OPTION)-1;;
607 char* q = strpbrk( p, " \t\n\r" );;
608
609 if (q != NULL)
610 *q = 0;
611
612 forceFilters = p;
613 force_exit = 0;
614 }
615 /* if nothing found or invalid filters, exit quietly */
Traian Schiau59763032015-04-10 15:51:39 +0300616 if (force_exit) {
617 return EXIT_SUCCESS;
618 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800619
620 /* redirect our output to the emulator console */
621 if (console) {
622 char* p = console + sizeof(CONSOLE_OPTION)-1;
623 char* q = strpbrk( p, " \t\n\r" );
624 char devname[64];
625 int len;
626
627 if (q != NULL) {
628 len = q - p;
629 } else
630 len = strlen(p);
631
632 len = snprintf( devname, sizeof(devname), "/dev/%.*s", len, p );
633 fprintf(stderr, "logcat using %s (%d)\n", devname, len);
634 if (len < (int)sizeof(devname)) {
635 fd = open( devname, O_WRONLY );
636 if (fd >= 0) {
637 dup2(fd, 1);
638 dup2(fd, 2);
639 close(fd);
640 }
641 }
642 }
643 }
644 break;
645
Mark Salyzyn34facab2014-02-06 14:48:50 -0800646 case 'S':
647 printStatistics = 1;
648 break;
649
Traian Schiau59763032015-04-10 15:51:39 +0300650 case ':':
651 logcat_panic(true, "Option -%c needs an argument\n", optopt);
652 break;
653
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800654 default:
Traian Schiau59763032015-04-10 15:51:39 +0300655 logcat_panic(true, "Unrecognized Option %c\n", optopt);
656 break;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800657 }
658 }
659
Joe Onorato6fa09a02010-02-26 10:04:23 -0800660 if (!devices) {
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800661 dev = devices = new log_device_t("main", false);
Traian Schiau59763032015-04-10 15:51:39 +0300662 g_devCount = 1;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800663 if (android_name_to_log_id("system") == LOG_ID_SYSTEM) {
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800664 dev = dev->next = new log_device_t("system", false);
Traian Schiau59763032015-04-10 15:51:39 +0300665 g_devCount++;
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800666 }
Mark Salyzyn99f47a92014-04-07 14:58:08 -0700667 if (android_name_to_log_id("crash") == LOG_ID_CRASH) {
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800668 dev = dev->next = new log_device_t("crash", false);
Traian Schiau59763032015-04-10 15:51:39 +0300669 g_devCount++;
Mark Salyzyn99f47a92014-04-07 14:58:08 -0700670 }
Joe Onorato6fa09a02010-02-26 10:04:23 -0800671 }
672
Traian Schiau59763032015-04-10 15:51:39 +0300673 if (g_logRotateSizeKBytes != 0 && g_outputFileName == NULL) {
674 logcat_panic(true, "-r requires -f as well\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800675 }
676
Traian Schiau59763032015-04-10 15:51:39 +0300677 setupOutput();
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800678
679 if (hasSetLogFormat == 0) {
680 const char* logFormat = getenv("ANDROID_PRINTF_LOG");
681
682 if (logFormat != NULL) {
683 err = setLogFormat(logFormat);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800684 if (err < 0) {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800685 fprintf(stderr, "invalid format in ANDROID_PRINTF_LOG '%s'\n",
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800686 logFormat);
687 }
Mark Salyzyn649fc602014-09-16 09:15:15 -0700688 } else {
689 setLogFormat("threadtime");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800690 }
691 }
692
693 if (forceFilters) {
694 err = android_log_addFilterString(g_logformat, forceFilters);
695 if (err < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300696 logcat_panic(false, "Invalid filter expression in logcat args\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800697 }
698 } else if (argc == optind) {
699 // Add from environment variable
700 char *env_tags_orig = getenv("ANDROID_LOG_TAGS");
701
702 if (env_tags_orig != NULL) {
703 err = android_log_addFilterString(g_logformat, env_tags_orig);
704
Mark Salyzyn95132e92013-11-22 10:55:48 -0800705 if (err < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300706 logcat_panic(true,
707 "Invalid filter expression in ANDROID_LOG_TAGS\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800708 }
709 }
710 } else {
711 // Add from commandline
712 for (int i = optind ; i < argc ; i++) {
713 err = android_log_addFilterString(g_logformat, argv[i]);
714
Mark Salyzyn95132e92013-11-22 10:55:48 -0800715 if (err < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300716 logcat_panic(true, "Invalid filter expression '%s'\n", argv[i]);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800717 }
718 }
719 }
720
Joe Onorato6fa09a02010-02-26 10:04:23 -0800721 dev = devices;
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800722 if (tail_time != log_time::EPOCH) {
723 logger_list = android_logger_list_alloc_time(mode, tail_time, 0);
724 } else {
725 logger_list = android_logger_list_alloc(mode, tail_lines, 0);
726 }
Joe Onorato6fa09a02010-02-26 10:04:23 -0800727 while (dev) {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800728 dev->logger_list = logger_list;
729 dev->logger = android_logger_open(logger_list,
730 android_name_to_log_id(dev->device));
731 if (!dev->logger) {
Traian Schiau59763032015-04-10 15:51:39 +0300732 logcat_panic(false, "Unable to open log device '%s'\n",
733 dev->device);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800734 }
Joe Onorato6fa09a02010-02-26 10:04:23 -0800735
736 if (clearLog) {
737 int ret;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800738 ret = android_logger_clear(dev->logger);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800739 if (ret) {
Traian Schiau59763032015-04-10 15:51:39 +0300740 logcat_panic(false, "failed to clear the log");
Joe Onorato6fa09a02010-02-26 10:04:23 -0800741 }
Joe Onorato6fa09a02010-02-26 10:04:23 -0800742 }
743
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800744 if (setLogSize && android_logger_set_log_size(dev->logger, setLogSize)) {
Traian Schiau59763032015-04-10 15:51:39 +0300745 logcat_panic(false, "failed to set the log size");
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800746 }
747
Joe Onorato6fa09a02010-02-26 10:04:23 -0800748 if (getLogSize) {
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800749 long size, readable;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800750
Mark Salyzyn95132e92013-11-22 10:55:48 -0800751 size = android_logger_get_log_size(dev->logger);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800752 if (size < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300753 logcat_panic(false, "failed to get the log size");
Joe Onorato6fa09a02010-02-26 10:04:23 -0800754 }
755
Mark Salyzyn95132e92013-11-22 10:55:48 -0800756 readable = android_logger_get_log_readable_size(dev->logger);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800757 if (readable < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300758 logcat_panic(false, "failed to get the readable log size");
Joe Onorato6fa09a02010-02-26 10:04:23 -0800759 }
760
Mark Salyzyn671e3432014-05-06 07:34:59 -0700761 printf("%s: ring buffer is %ld%sb (%ld%sb consumed), "
Joe Onorato6fa09a02010-02-26 10:04:23 -0800762 "max entry is %db, max payload is %db\n", dev->device,
Mark Salyzyn671e3432014-05-06 07:34:59 -0700763 value_of_size(size), multiplier_of_size(size),
764 value_of_size(readable), multiplier_of_size(readable),
Joe Onorato6fa09a02010-02-26 10:04:23 -0800765 (int) LOGGER_ENTRY_MAX_LEN, (int) LOGGER_ENTRY_MAX_PAYLOAD);
766 }
767
768 dev = dev->next;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800769 }
770
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800771 if (setPruneList) {
Traian Schiau59763032015-04-10 15:51:39 +0300772 size_t len = strlen(setPruneList);
773 /*extra 32 bytes are needed by android_logger_set_prune_list */
774 size_t bLen = len + 32;
775 char *buf = NULL;
776 if (asprintf(&buf, "%-*s", (int)(bLen - 1), setPruneList) > 0) {
777 buf[len] = '\0';
778 if (android_logger_set_prune_list(logger_list, buf, bLen)) {
779 logcat_panic(false, "failed to set the prune list");
780 }
781 free(buf);
782 } else {
783 logcat_panic(false, "failed to set the prune list (alloc)");
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800784 }
785 }
786
Mark Salyzyn1c950472014-04-01 17:19:47 -0700787 if (printStatistics || getPruneList) {
Mark Salyzyn34facab2014-02-06 14:48:50 -0800788 size_t len = 8192;
789 char *buf;
790
791 for(int retry = 32;
792 (retry >= 0) && ((buf = new char [len]));
Traian Schiau59763032015-04-10 15:51:39 +0300793 delete [] buf, buf = NULL, --retry) {
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800794 if (getPruneList) {
795 android_logger_get_prune_list(logger_list, buf, len);
796 } else {
797 android_logger_get_statistics(logger_list, buf, len);
798 }
Mark Salyzyn34facab2014-02-06 14:48:50 -0800799 buf[len-1] = '\0';
Traian Schiau59763032015-04-10 15:51:39 +0300800 if (atol(buf) < 3) {
Mark Salyzyn34facab2014-02-06 14:48:50 -0800801 delete [] buf;
802 buf = NULL;
803 break;
804 }
Traian Schiau59763032015-04-10 15:51:39 +0300805 size_t ret = atol(buf) + 1;
806 if (ret <= len) {
807 len = ret;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800808 break;
809 }
Traian Schiau59763032015-04-10 15:51:39 +0300810 len = ret;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800811 }
812
813 if (!buf) {
Traian Schiau59763032015-04-10 15:51:39 +0300814 logcat_panic(false, "failed to read data");
Mark Salyzyn34facab2014-02-06 14:48:50 -0800815 }
816
817 // remove trailing FF
818 char *cp = buf + len - 1;
819 *cp = '\0';
820 bool truncated = *--cp != '\f';
821 if (!truncated) {
822 *cp = '\0';
823 }
824
825 // squash out the byte count
826 cp = buf;
827 if (!truncated) {
Mark Salyzyn22e287d2014-03-21 13:12:16 -0700828 while (isdigit(*cp)) {
829 ++cp;
830 }
831 if (*cp == '\n') {
Mark Salyzyn34facab2014-02-06 14:48:50 -0800832 ++cp;
833 }
834 }
835
836 printf("%s", cp);
837 delete [] buf;
Traian Schiau59763032015-04-10 15:51:39 +0300838 return EXIT_SUCCESS;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800839 }
840
841
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800842 if (getLogSize) {
Traian Schiau59763032015-04-10 15:51:39 +0300843 return EXIT_SUCCESS;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800844 }
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800845 if (setLogSize || setPruneList) {
Traian Schiau59763032015-04-10 15:51:39 +0300846 return EXIT_SUCCESS;
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800847 }
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800848 if (clearLog) {
Traian Schiau59763032015-04-10 15:51:39 +0300849 return EXIT_SUCCESS;
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800850 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800851
852 //LOG_EVENT_INT(10, 12345);
853 //LOG_EVENT_LONG(11, 0x1122334455667788LL);
854 //LOG_EVENT_STRING(0, "whassup, doc?");
855
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800856 dev = NULL;
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800857 log_device_t unexpected("unexpected", false);
Mark Salyzyn95132e92013-11-22 10:55:48 -0800858 while (1) {
859 struct log_msg log_msg;
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800860 log_device_t* d;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800861 int ret = android_logger_list_read(logger_list, &log_msg);
862
863 if (ret == 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300864 logcat_panic(false, "read: unexpected EOF!\n");
Mark Salyzyn95132e92013-11-22 10:55:48 -0800865 }
866
867 if (ret < 0) {
868 if (ret == -EAGAIN) {
869 break;
870 }
871
872 if (ret == -EIO) {
Traian Schiau59763032015-04-10 15:51:39 +0300873 logcat_panic(false, "read: unexpected EOF!\n");
Mark Salyzyn95132e92013-11-22 10:55:48 -0800874 }
875 if (ret == -EINVAL) {
Traian Schiau59763032015-04-10 15:51:39 +0300876 logcat_panic(false, "read: unexpected length.\n");
Mark Salyzyn95132e92013-11-22 10:55:48 -0800877 }
Traian Schiau59763032015-04-10 15:51:39 +0300878 logcat_panic(false, "logcat read failure");
Mark Salyzyn95132e92013-11-22 10:55:48 -0800879 }
880
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800881 for(d = devices; d; d = d->next) {
882 if (android_name_to_log_id(d->device) == log_msg.id()) {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800883 break;
884 }
885 }
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800886 if (!d) {
Traian Schiau59763032015-04-10 15:51:39 +0300887 g_devCount = 2; // set to Multiple
Mark Salyzyn9421b0c2015-02-26 14:33:35 -0800888 d = &unexpected;
889 d->binary = log_msg.id() == LOG_ID_EVENTS;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800890 }
891
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800892 if (dev != d) {
893 dev = d;
Traian Schiau59763032015-04-10 15:51:39 +0300894 maybePrintStart(dev, printDividers);
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800895 }
Traian Schiau59763032015-04-10 15:51:39 +0300896 if (g_printBinary) {
897 printBinary(&log_msg);
Mark Salyzyn95132e92013-11-22 10:55:48 -0800898 } else {
Traian Schiau59763032015-04-10 15:51:39 +0300899 processBuffer(dev, &log_msg);
Mark Salyzyn95132e92013-11-22 10:55:48 -0800900 }
901 }
902
903 android_logger_list_free(logger_list);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800904
Traian Schiau59763032015-04-10 15:51:39 +0300905 return EXIT_SUCCESS;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800906}