Merge change 2437 into donut
* changes:
Modify init.goldfish.sh to launch the 'qemu-props' program when the emulator boots up. Its purpose is to receive a list of system property (name,value) pairs and set them on launch.
diff --git a/adb/adb.c b/adb/adb.c
index 6e170ae..956df54 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -23,6 +23,7 @@
#include <errno.h>
#include <string.h>
#include <time.h>
+#include <sys/time.h>
#include "sysdeps.h"
#include "adb.h"
@@ -657,10 +658,25 @@
void start_device_log(void)
{
int fd;
- char path[100];
+ char path[PATH_MAX];
+ struct tm now;
+ time_t t;
+ char value[PROPERTY_VALUE_MAX];
- snprintf(path, sizeof path, "/data/adb_%ld.txt", (long)time(NULL));
- fd = unix_open(path, O_WRONLY | O_CREAT | O_APPEND, 0640);
+ // read the trace mask from persistent property persist.adb.trace_mask
+ // give up if the property is not set or cannot be parsed
+ property_get("persist.adb.trace_mask", value, "");
+ if (sscanf(value, "%x", &adb_trace_mask) != 1)
+ return;
+
+ adb_mkdir("/data/adb", 0775);
+ tzset();
+ time(&t);
+ localtime_r(&t, &now);
+ strftime(path, sizeof(path),
+ "/data/adb/adb-%Y-%m-%d-%H-%M-%S.txt",
+ &now);
+ fd = unix_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640);
if (fd < 0)
return;
@@ -671,11 +687,6 @@
fd = unix_open("/dev/null", O_RDONLY);
dup2(fd, 0);
-
- // log everything
- adb_trace_mask = ~0;
- // except TRACE_RWX is a bit too verbose
- adb_trace_mask &= ~TRACE_RWX;
}
#endif
@@ -875,9 +886,10 @@
** AID_INET to diagnose network issues (netcfg, ping)
** AID_GRAPHICS to access the frame buffer
** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump)
+ ** AID_SDCARD_RW to allow writing to the SD card
*/
gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS,
- AID_NET_BT, AID_NET_BT_ADMIN };
+ AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW };
setgroups(sizeof(groups)/sizeof(groups[0]), groups);
/* then switch user and group to "shell" */
@@ -1078,9 +1090,8 @@
adb_device_banner = "recovery";
recovery_mode = 1;
}
-#if ADB_DEVICE_LOG
+
start_device_log();
-#endif
return adb_main(0);
#endif
}
diff --git a/adb/adb.h b/adb/adb.h
index 3c4fe60..b9ed556 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -345,11 +345,6 @@
#endif
-/* set this to log to /data/adb/adb_<time>.txt on the device.
- * has no effect if the /data/adb/ directory does not exist.
- */
-#define ADB_DEVICE_LOG 0
-
#if !TRACE_PACKETS
#define print_packet(tag,p) do {} while (0)
#endif