Merge "Make adb's daemon-port on the host machine configurable."
diff --git a/adb/usb_vendors.c b/adb/usb_vendors.c
index 515c8c8..7f3cb54 100644
--- a/adb/usb_vendors.c
+++ b/adb/usb_vendors.c
@@ -65,6 +65,9 @@
 #define VENDOR_ID_ZTE           0x19D2
 // Kyocera's USB Vendor ID
 #define VENDOR_ID_KYOCERA       0x0482
+// Pantech's USB Vendor ID
+#define VENDOR_ID_PANTECH       0x10A9
+
 
 /** built-in vendor list */
 int builtInVendorIds[] = {
@@ -83,6 +86,7 @@
     VENDOR_ID_SHARP,
     VENDOR_ID_ZTE,
     VENDOR_ID_KYOCERA,
+    VENDOR_ID_PANTECH,
 };
 
 #define BUILT_IN_VENDOR_COUNT    (sizeof(builtInVendorIds)/sizeof(builtInVendorIds[0]))
diff --git a/logcat/event.logtags b/logcat/event.logtags
index 5e6c256..95a16d7 100644
--- a/logcat/event.logtags
+++ b/logcat/event.logtags
@@ -150,7 +150,7 @@
 # time: cpu time millis (not wall time), including lock acquisition
 # blocking_package: if this is on a main thread, the package name, otherwise ""
 # sample_percent: the percent likelihood this query was logged
-52000 db_operation (db|3),(sql|3),(time|1|3),(blocking_package|3),(sample_percent|1|6)
+52000 db_sample (db|3),(sql|3),(time|1|3),(blocking_package|3),(sample_percent|1|6)
 
 # http request/response stats
 52001 http_stats (useragent|3),(response|2|3),(processing|2|3),(tx|1|2),(rx|1|2)
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index a6114ac..5f72311 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -52,7 +52,8 @@
 	id \
 	vmstat \
 	nandread \
-        ionice
+	uptime \
+	ionice
 
 LOCAL_SRC_FILES:= \
 	toolbox.c \
diff --git a/toolbox/uptime.c b/toolbox/uptime.c
new file mode 100644
index 0000000..8b1983d
--- /dev/null
+++ b/toolbox/uptime.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/time.h>
+#include <linux/ioctl.h>
+#include <linux/rtc.h>
+#include <linux/android_alarm.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+
+static void format_time(int time, char* buffer) {
+    int seconds, minutes, hours, days;
+
+    seconds = time % 60;
+    time /= 60;
+    minutes = time % 60;
+    time /= 60;
+    hours = time % 24;
+    days = time / 24;
+
+    if (days > 0)
+        sprintf(buffer, "%d days, %02d:%02d:%02d", days, hours, minutes, seconds);
+    else
+        sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds);
+}
+
+int64_t elapsedRealtime()
+{
+    struct timespec ts;
+    int fd, result;
+
+    fd = open("/dev/alarm", O_RDONLY);
+    if (fd < 0)
+        return fd;
+
+   result = ioctl(fd, ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &ts);
+   close(fd);
+
+    if (result == 0)
+        return ts.tv_sec;
+    return -1;
+}
+
+int uptime_main(int argc, char *argv[])
+{
+    float up_time, idle_time;
+    char up_string[100], idle_string[100], sleep_string[100];
+    int elapsed;
+
+    FILE* file = fopen("/proc/uptime", "r");
+    if (!file) {
+        fprintf(stderr, "Could not open /proc/uptime\n");
+        return -1;
+    }
+    if (fscanf(file, "%f %f", &up_time, &idle_time) != 2) {
+        fprintf(stderr, "Could not parse /proc/uptime\n");
+        fclose(file);
+        return -1;
+    }
+    fclose(file);
+
+    elapsed = elapsedRealtime();
+    if (elapsed < 0) {
+        fprintf(stderr, "elapsedRealtime failed\n");
+        return -1;
+    }
+
+    format_time(elapsed, up_string);
+    format_time((int)idle_time, idle_string);
+    format_time((int)(elapsed - up_time), sleep_string);
+    printf("up time: %s, idle time: %s, sleep time: %s\n", up_string, idle_string, sleep_string);
+
+    return 0;
+}