Merge "metricsd: Report the data partition usage."
diff --git a/adb/Android.mk b/adb/Android.mk
index 5786d18..4ee1ced 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -37,6 +37,7 @@
adb_auth.cpp \
adb_io.cpp \
adb_listeners.cpp \
+ adb_trace.cpp \
adb_utils.cpp \
sockets.cpp \
transport.cpp \
diff --git a/adb/adb.cpp b/adb/adb.cpp
index 19dd03d..e973603 100644
--- a/adb/adb.cpp
+++ b/adb/adb.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG ADB
#include "sysdeps.h"
#include "adb.h"
@@ -32,7 +32,6 @@
#include <string>
#include <vector>
-#include <unordered_map>
#include <base/logging.h>
#include <base/macros.h>
@@ -53,22 +52,6 @@
#include <sys/mount.h>
#endif
-#if !ADB_HOST
-const char* adb_device_banner = "device";
-static android::base::LogdLogger gLogdLogger;
-#else
-const char* adb_device_banner = "host";
-#endif
-
-void AdbLogger(android::base::LogId id, android::base::LogSeverity severity,
- const char* tag, const char* file, unsigned int line,
- const char* message) {
- android::base::StderrLogger(id, severity, tag, file, line, message);
-#if !ADB_HOST
- gLogdLogger(id, severity, tag, file, line, message);
-#endif
-}
-
std::string adb_version() {
// Don't change the format of this --- it's parsed by ddmlib.
return android::base::StringPrintf("Android Debug Bridge version %d.%d.%d\n"
@@ -97,128 +80,6 @@
exit(-1);
}
-#if !ADB_HOST
-static std::string get_log_file_name() {
- struct tm now;
- time_t t;
- tzset();
- time(&t);
- localtime_r(&t, &now);
-
- char timestamp[PATH_MAX];
- strftime(timestamp, sizeof(timestamp), "%Y-%m-%d-%H-%M-%S", &now);
-
- return android::base::StringPrintf("/data/adb/adb-%s-%d", timestamp,
- getpid());
-}
-
-void start_device_log(void) {
- int fd = unix_open(get_log_file_name().c_str(),
- O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
- if (fd == -1) {
- return;
- }
-
- // Redirect stdout and stderr to the log file.
- dup2(fd, STDOUT_FILENO);
- dup2(fd, STDERR_FILENO);
- fprintf(stderr, "--- adb starting (pid %d) ---\n", getpid());
- unix_close(fd);
-}
-#endif
-
-int adb_trace_mask;
-
-std::string get_trace_setting_from_env() {
- const char* setting = getenv("ADB_TRACE");
- if (setting == nullptr) {
- setting = "";
- }
-
- return std::string(setting);
-}
-
-#if !ADB_HOST
-std::string get_trace_setting_from_prop() {
- char buf[PROPERTY_VALUE_MAX];
- property_get("persist.adb.trace_mask", buf, "");
- return std::string(buf);
-}
-#endif
-
-std::string get_trace_setting() {
-#if ADB_HOST
- return get_trace_setting_from_env();
-#else
- return get_trace_setting_from_prop();
-#endif
-}
-
-// Split the space separated list of tags from the trace setting and build the
-// trace mask from it. note that '1' and 'all' are special cases to enable all
-// tracing.
-//
-// adb's trace setting comes from the ADB_TRACE environment variable, whereas
-// adbd's comes from the system property persist.adb.trace_mask.
-static void setup_trace_mask() {
- const std::string trace_setting = get_trace_setting();
- if (trace_setting.empty()) {
- return;
- }
-
- std::unordered_map<std::string, int> trace_flags = {
- {"1", 0},
- {"all", 0},
- {"adb", TRACE_ADB},
- {"sockets", TRACE_SOCKETS},
- {"packets", TRACE_PACKETS},
- {"rwx", TRACE_RWX},
- {"usb", TRACE_USB},
- {"sync", TRACE_SYNC},
- {"sysdeps", TRACE_SYSDEPS},
- {"transport", TRACE_TRANSPORT},
- {"jdwp", TRACE_JDWP},
- {"services", TRACE_SERVICES},
- {"auth", TRACE_AUTH},
- {"fdevent", TRACE_FDEVENT},
- {"shell", TRACE_SHELL}};
-
- std::vector<std::string> elements = android::base::Split(trace_setting, " ");
- for (const auto& elem : elements) {
- const auto& flag = trace_flags.find(elem);
- if (flag == trace_flags.end()) {
- D("Unknown trace flag: %s", elem.c_str());
- continue;
- }
-
- if (flag->second == 0) {
- // 0 is used for the special values "1" and "all" that enable all
- // tracing.
- adb_trace_mask = ~0;
- return;
- } else {
- adb_trace_mask |= 1 << flag->second;
- }
- }
-}
-
-void adb_trace_init(char** argv) {
-#if !ADB_HOST
- // Don't open log file if no tracing, since this will block
- // the crypto unmount of /data
- if (!get_trace_setting().empty()) {
- if (isatty(STDOUT_FILENO) == 0) {
- start_device_log();
- }
- }
-#endif
-
- setup_trace_mask();
- android::base::InitLogging(argv, AdbLogger);
-
- D("%s", adb_version().c_str());
-}
-
apacket* get_apacket(void)
{
apacket* p = reinterpret_cast<apacket*>(malloc(sizeof(apacket)));
diff --git a/adb/adb_auth.cpp b/adb/adb_auth.cpp
index 2364f7b..1ffab09 100644
--- a/adb/adb_auth.cpp
+++ b/adb/adb_auth.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG ADB
#include "sysdeps.h"
#include "adb_auth.h"
diff --git a/adb/adb_auth_client.cpp b/adb/adb_auth_client.cpp
index cedc847..463b496 100644
--- a/adb/adb_auth_client.cpp
+++ b/adb/adb_auth_client.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_AUTH
+#define TRACE_TAG AUTH
#include "sysdeps.h"
#include "adb_auth.h"
diff --git a/adb/adb_auth_host.cpp b/adb/adb_auth_host.cpp
index 749fec2..7b314c3 100644
--- a/adb/adb_auth_host.cpp
+++ b/adb/adb_auth_host.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_AUTH
+#define TRACE_TAG AUTH
#include "sysdeps.h"
#include "adb_auth.h"
@@ -452,7 +452,6 @@
}
int adb_auth_keygen(const char* filename) {
- adb_trace_mask |= (1 << TRACE_AUTH);
return (generate_key(filename) == 0);
}
diff --git a/adb/adb_client.cpp b/adb/adb_client.cpp
index ff68415..63cb3c3 100644
--- a/adb/adb_client.cpp
+++ b/adb/adb_client.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG ADB
#include "sysdeps.h"
#include "adb_client.h"
diff --git a/adb/adb_io.cpp b/adb/adb_io.cpp
index 14e295f..7788996 100644
--- a/adb/adb_io.cpp
+++ b/adb/adb_io.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_RWX
+#define TRACE_TAG RWX
#include "adb_io.h"
@@ -84,10 +84,8 @@
}
}
- D("readx: fd=%d wanted=%zu got=%zu", fd, len0, len0 - len);
- if (ADB_TRACING) {
- dump_hex(reinterpret_cast<const unsigned char*>(buf), len0);
- }
+ VLOG(RWX) << "readx: fd=" << fd << " wanted=" << len0 << " got=" << (len0 - len)
+ << " " << dump_hex(reinterpret_cast<const unsigned char*>(buf), len0);
return true;
}
@@ -96,10 +94,8 @@
const char* p = reinterpret_cast<const char*>(buf);
int r;
- D("writex: fd=%d len=%d: ", fd, (int)len);
- if (ADB_TRACING) {
- dump_hex(reinterpret_cast<const unsigned char*>(buf), len);
- }
+ VLOG(RWX) << "writex: fd=" << fd << " len=" << len
+ << " " << dump_hex(reinterpret_cast<const unsigned char*>(buf), len);
while (len > 0) {
r = adb_write(fd, p, len);
diff --git a/adb/adb_trace.cpp b/adb/adb_trace.cpp
new file mode 100644
index 0000000..04b82f6
--- /dev/null
+++ b/adb/adb_trace.cpp
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2015 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 "sysdeps.h"
+#include "adb_trace.h"
+
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include <base/logging.h>
+#include <base/strings.h>
+
+#include "adb.h"
+
+#if !ADB_HOST
+#include <cutils/properties.h>
+#endif
+
+#if !ADB_HOST
+const char* adb_device_banner = "device";
+static android::base::LogdLogger gLogdLogger;
+#else
+const char* adb_device_banner = "host";
+#endif
+
+void AdbLogger(android::base::LogId id, android::base::LogSeverity severity,
+ const char* tag, const char* file, unsigned int line,
+ const char* message) {
+ android::base::StderrLogger(id, severity, tag, file, line, message);
+#if !ADB_HOST
+ gLogdLogger(id, severity, tag, file, line, message);
+#endif
+}
+
+
+#if !ADB_HOST
+static std::string get_log_file_name() {
+ struct tm now;
+ time_t t;
+ tzset();
+ time(&t);
+ localtime_r(&t, &now);
+
+ char timestamp[PATH_MAX];
+ strftime(timestamp, sizeof(timestamp), "%Y-%m-%d-%H-%M-%S", &now);
+
+ return android::base::StringPrintf("/data/adb/adb-%s-%d", timestamp,
+ getpid());
+}
+
+void start_device_log(void) {
+ int fd = unix_open(get_log_file_name().c_str(),
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
+ if (fd == -1) {
+ return;
+ }
+
+ // Redirect stdout and stderr to the log file.
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDERR_FILENO);
+ fprintf(stderr, "--- adb starting (pid %d) ---\n", getpid());
+ unix_close(fd);
+}
+#endif
+
+int adb_trace_mask;
+
+std::string get_trace_setting_from_env() {
+ const char* setting = getenv("ADB_TRACE");
+ if (setting == nullptr) {
+ setting = "";
+ }
+
+ return std::string(setting);
+}
+
+#if !ADB_HOST
+std::string get_trace_setting_from_prop() {
+ char buf[PROPERTY_VALUE_MAX];
+ property_get("persist.adb.trace_mask", buf, "");
+ return std::string(buf);
+}
+#endif
+
+std::string get_trace_setting() {
+#if ADB_HOST
+ return get_trace_setting_from_env();
+#else
+ return get_trace_setting_from_prop();
+#endif
+}
+
+// Split the space separated list of tags from the trace setting and build the
+// trace mask from it. note that '1' and 'all' are special cases to enable all
+// tracing.
+//
+// adb's trace setting comes from the ADB_TRACE environment variable, whereas
+// adbd's comes from the system property persist.adb.trace_mask.
+static void setup_trace_mask() {
+ const std::string trace_setting = get_trace_setting();
+ if (trace_setting.empty()) {
+ return;
+ }
+
+ std::unordered_map<std::string, int> trace_flags = {
+ {"1", 0},
+ {"all", 0},
+ {"adb", ADB},
+ {"sockets", SOCKETS},
+ {"packets", PACKETS},
+ {"rwx", RWX},
+ {"usb", USB},
+ {"sync", SYNC},
+ {"sysdeps", SYSDEPS},
+ {"transport", TRANSPORT},
+ {"jdwp", JDWP},
+ {"services", SERVICES},
+ {"auth", AUTH},
+ {"fdevent", FDEVENT},
+ {"shell", SHELL}};
+
+ std::vector<std::string> elements = android::base::Split(trace_setting, " ");
+ for (const auto& elem : elements) {
+ const auto& flag = trace_flags.find(elem);
+ if (flag == trace_flags.end()) {
+ LOG(ERROR) << "Unknown trace flag: " << elem;
+ continue;
+ }
+
+ if (flag->second == 0) {
+ // 0 is used for the special values "1" and "all" that enable all
+ // tracing.
+ adb_trace_mask = ~0;
+ return;
+ } else {
+ adb_trace_mask |= 1 << flag->second;
+ }
+ }
+}
+
+void adb_trace_init(char** argv) {
+#if !ADB_HOST
+ // Don't open log file if no tracing, since this will block
+ // the crypto unmount of /data
+ if (!get_trace_setting().empty()) {
+ if (isatty(STDOUT_FILENO) == 0) {
+ start_device_log();
+ }
+ }
+#endif
+
+ android::base::InitLogging(argv, AdbLogger);
+ setup_trace_mask();
+
+ VLOG(ADB) << adb_version();
+}
+
+void adb_trace_enable(AdbTrace trace_tag) {
+ adb_trace_mask |= (1 << trace_tag);
+}
diff --git a/adb/adb_trace.h b/adb/adb_trace.h
index b4155df..78b2deb 100644
--- a/adb/adb_trace.h
+++ b/adb/adb_trace.h
@@ -22,36 +22,40 @@
/* IMPORTANT: if you change the following list, don't
* forget to update the corresponding 'tags' table in
- * the adb_trace_init() function implemented in adb.c
+ * the adb_trace_init() function implemented in adb_trace.cpp.
*/
enum AdbTrace {
- TRACE_ADB = 0, /* 0x001 */
- TRACE_SOCKETS,
- TRACE_PACKETS,
- TRACE_TRANSPORT,
- TRACE_RWX, /* 0x010 */
- TRACE_USB,
- TRACE_SYNC,
- TRACE_SYSDEPS,
- TRACE_JDWP, /* 0x100 */
- TRACE_SERVICES,
- TRACE_AUTH,
- TRACE_FDEVENT,
- TRACE_SHELL
+ ADB = 0, /* 0x001 */
+ SOCKETS,
+ PACKETS,
+ TRANSPORT,
+ RWX, /* 0x010 */
+ USB,
+ SYNC,
+ SYSDEPS,
+ JDWP, /* 0x100 */
+ SERVICES,
+ AUTH,
+ FDEVENT,
+ SHELL
};
-extern int adb_trace_mask;
-extern unsigned char adb_trace_output_count;
-void adb_trace_init(char**);
+#define VLOG_IS_ON(TAG) \
+ ((adb_trace_mask & (1 << TAG)) != 0)
-#define ADB_TRACING ((adb_trace_mask & (1 << TRACE_TAG)) != 0)
+#define VLOG(TAG) \
+ if (LIKELY(!VLOG_IS_ON(TAG))) \
+ ; \
+ else \
+ LOG(INFO)
// You must define TRACE_TAG before using this macro.
#define D(...) \
- do { \
- if (ADB_TRACING) { \
- LOG(INFO) << android::base::StringPrintf(__VA_ARGS__); \
- } \
- } while (0)
+ VLOG(TRACE_TAG) << android::base::StringPrintf(__VA_ARGS__)
+
+
+extern int adb_trace_mask;
+void adb_trace_init(char**);
+void adb_trace_enable(AdbTrace trace_tag);
#endif /* __ADB_TRACE_H */
diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp
index 72ee901..7ff5c3d 100644
--- a/adb/adb_utils.cpp
+++ b/adb/adb_utils.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG ADB
#include "adb_utils.h"
@@ -151,7 +151,7 @@
return true;
}
-void dump_hex(const void* data, size_t byte_count) {
+std::string dump_hex(const void* data, size_t byte_count) {
byte_count = std::min(byte_count, size_t(16));
const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
@@ -170,7 +170,7 @@
line.push_back(c);
}
- D("%s", line.c_str());
+ return line;
}
bool parse_host_and_port(const std::string& address,
diff --git a/adb/adb_utils.h b/adb/adb_utils.h
index b38ec59..b9da980 100644
--- a/adb/adb_utils.h
+++ b/adb/adb_utils.h
@@ -31,7 +31,7 @@
std::string escape_arg(const std::string& s);
-void dump_hex(const void* ptr, size_t byte_count);
+std::string dump_hex(const void* ptr, size_t byte_count);
// Parses 'address' into 'host' and 'port'.
// If no port is given, takes the default from *port.
diff --git a/adb/client/main.cpp b/adb/client/main.cpp
index 47234ee..a225a53 100644
--- a/adb/client/main.cpp
+++ b/adb/client/main.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG ADB
#include "sysdeps.h"
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index 4e93dee..8aad97d 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG ADB
#include "sysdeps.h"
@@ -1546,6 +1546,8 @@
}
else if (!strcmp(argv[0], "keygen")) {
if (argc < 2) return usage();
+ // Always print key generation information for keygen command.
+ adb_trace_enable(AUTH);
return adb_auth_keygen(argv[1]);
}
else if (!strcmp(argv[0], "jdwp")) {
diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index cb0cb3d..8c3ca63 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG ADB
#include "sysdeps.h"
diff --git a/adb/fdevent.cpp b/adb/fdevent.cpp
index 666a15f..2de9386 100644
--- a/adb/fdevent.cpp
+++ b/adb/fdevent.cpp
@@ -15,7 +15,7 @@
** limitations under the License.
*/
-#define TRACE_TAG TRACE_FDEVENT
+#define TRACE_TAG FDEVENT
#include "sysdeps.h"
#include "fdevent.h"
diff --git a/adb/file_sync_service.cpp b/adb/file_sync_service.cpp
index 8db9ca7..f588b40 100644
--- a/adb/file_sync_service.cpp
+++ b/adb/file_sync_service.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_SYNC
+#define TRACE_TAG SYNC
#include "sysdeps.h"
#include "file_sync_service.h"
diff --git a/adb/jdwp_service.cpp b/adb/jdwp_service.cpp
index 0fa0732..4f0f740 100644
--- a/adb/jdwp_service.cpp
+++ b/adb/jdwp_service.cpp
@@ -16,7 +16,7 @@
/* implement the "debug-ports" and "track-debug-ports" device services */
-#define TRACE_TAG TRACE_JDWP
+#define TRACE_TAG JDWP
#include "sysdeps.h"
@@ -324,8 +324,9 @@
}
CloseProcess:
- if (proc->pid >= 0)
+ if (proc->pid >= 0) {
D( "remove pid %d to jdwp process list", proc->pid );
+ }
jdwp_process_free(proc);
return;
}
diff --git a/adb/remount_service.cpp b/adb/remount_service.cpp
index 2893263..35ba056 100644
--- a/adb/remount_service.cpp
+++ b/adb/remount_service.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG ADB
#include "sysdeps.h"
diff --git a/adb/services.cpp b/adb/services.cpp
index d0494ec..1153c31 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_SERVICES
+#define TRACE_TAG SERVICES
#include "sysdeps.h"
diff --git a/adb/set_verity_enable_state_service.cpp b/adb/set_verity_enable_state_service.cpp
index bae38cf..fd1740d 100644
--- a/adb/set_verity_enable_state_service.cpp
+++ b/adb/set_verity_enable_state_service.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_ADB
+#define TRACE_TAG ADB
#include "sysdeps.h"
diff --git a/adb/shell_service.cpp b/adb/shell_service.cpp
index f1bc36d..714a2d8 100644
--- a/adb/shell_service.cpp
+++ b/adb/shell_service.cpp
@@ -75,7 +75,7 @@
// to be more complex due to partial reads and non-blocking I/O so this model
// was chosen instead.
-#define TRACE_TAG TRACE_SHELL
+#define TRACE_TAG SHELL
#include "shell_service.h"
diff --git a/adb/sockets.cpp b/adb/sockets.cpp
index bd33d79..8562496 100644
--- a/adb/sockets.cpp
+++ b/adb/sockets.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_SOCKETS
+#define TRACE_TAG SOCKETS
#include "sysdeps.h"
diff --git a/adb/sysdeps_win32.cpp b/adb/sysdeps_win32.cpp
index 5b23c79..2b1ec48 100644
--- a/adb/sysdeps_win32.cpp
+++ b/adb/sysdeps_win32.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_SYSDEPS
+#define TRACE_TAG SYSDEPS
#include "sysdeps.h"
diff --git a/adb/transport.cpp b/adb/transport.cpp
index 402546b..ffbb107 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_TRANSPORT
+#define TRACE_TAG TRANSPORT
#include "sysdeps.h"
#include "transport.h"
@@ -42,7 +42,7 @@
ADB_MUTEX_DEFINE( transport_lock );
-static void dump_packet(const char* name, const char* func, apacket* p) {
+static std::string dump_packet(const char* name, const char* func, apacket* p) {
unsigned command = p->msg.command;
int len = p->msg.data_length;
char cmd[9];
@@ -73,9 +73,10 @@
else
snprintf(arg1, sizeof arg1, "0x%x", p->msg.arg1);
- D("%s: %s: [%s] arg0=%s arg1=%s (len=%d) ",
- name, func, cmd, arg0, arg1, len);
- dump_hex(p->data, len);
+ std::string result = android::base::StringPrintf("%s: %s: [%s] arg0=%s arg1=%s (len=%d) ",
+ name, func, cmd, arg0, arg1, len);
+ result += dump_hex(p->data, len);
+ return result;
}
static int
@@ -99,9 +100,7 @@
}
}
- if (ADB_TRACING) {
- dump_packet(name, "from remote", *ppacket);
- }
+ VLOG(TRANSPORT) << dump_packet(name, "from remote", *ppacket);
return 0;
}
@@ -113,9 +112,7 @@
snprintf(buff, sizeof buff, "fd=%d", fd);
name = buff;
}
- if (ADB_TRACING) {
- dump_packet(name, "to remote", *ppacket);
- }
+ VLOG(TRANSPORT) << dump_packet(name, "to remote", *ppacket);
char* p = reinterpret_cast<char*>(ppacket); /* we really write the packet address */
int len = sizeof(apacket*);
while(len > 0) {
@@ -996,19 +993,16 @@
adb_mutex_unlock(&transport_lock);
}
-#undef TRACE_TAG
-#define TRACE_TAG TRACE_RWX
-
int check_header(apacket *p, atransport *t)
{
if(p->msg.magic != (p->msg.command ^ 0xffffffff)) {
- D("check_header(): invalid magic");
+ VLOG(RWX) << "check_header(): invalid magic";
return -1;
}
if(p->msg.data_length > t->get_max_payload()) {
- D("check_header(): %u > atransport::max_payload = %zu",
- p->msg.data_length, t->get_max_payload());
+ VLOG(RWX) << "check_header(): " << p->msg.data_length << " atransport::max_payload = "
+ << t->get_max_payload();
return -1;
}
diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp
index 0c4315a..bf0cc3c 100644
--- a/adb/transport_local.cpp
+++ b/adb/transport_local.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_TRANSPORT
+#define TRACE_TAG TRANSPORT
#include "sysdeps.h"
#include "transport.h"
diff --git a/adb/transport_usb.cpp b/adb/transport_usb.cpp
index b520607..263f9e7 100644
--- a/adb/transport_usb.cpp
+++ b/adb/transport_usb.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_TRANSPORT
+#define TRACE_TAG TRANSPORT
#include "sysdeps.h"
#include "transport.h"
diff --git a/adb/usb_linux.cpp b/adb/usb_linux.cpp
index f2b9820..c633f7f 100644
--- a/adb/usb_linux.cpp
+++ b/adb/usb_linux.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_USB
+#define TRACE_TAG USB
#include "sysdeps.h"
diff --git a/adb/usb_linux_client.cpp b/adb/usb_linux_client.cpp
index c7a9b58..817917e 100644
--- a/adb/usb_linux_client.cpp
+++ b/adb/usb_linux_client.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_USB
+#define TRACE_TAG USB
#include "sysdeps.h"
@@ -491,12 +491,14 @@
int err;
err = ioctl(h->bulk_in, FUNCTIONFS_CLEAR_HALT);
- if (err < 0)
+ if (err < 0) {
D("[ kick: source (fd=%d) clear halt failed (%d) ]", h->bulk_in, errno);
+ }
err = ioctl(h->bulk_out, FUNCTIONFS_CLEAR_HALT);
- if (err < 0)
+ if (err < 0) {
D("[ kick: sink (fd=%d) clear halt failed (%d) ]", h->bulk_out, errno);
+ }
adb_mutex_lock(&h->lock);
diff --git a/adb/usb_osx.cpp b/adb/usb_osx.cpp
index 8037606..e0dcc756 100644
--- a/adb/usb_osx.cpp
+++ b/adb/usb_osx.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_USB
+#define TRACE_TAG USB
#include "sysdeps.h"
diff --git a/adb/usb_windows.cpp b/adb/usb_windows.cpp
index 5bb0100..d811b24 100644
--- a/adb/usb_windows.cpp
+++ b/adb/usb_windows.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define TRACE_TAG TRACE_USB
+#define TRACE_TAG USB
#include "sysdeps.h"
diff --git a/include/utils/BasicHashtable.h b/include/utils/BasicHashtable.h
index c235d62..cf47059 100644
--- a/include/utils/BasicHashtable.h
+++ b/include/utils/BasicHashtable.h
@@ -19,7 +19,6 @@
#include <stdint.h>
#include <sys/types.h>
-#include <utils/SharedBuffer.h>
#include <utils/TypeHelpers.h>
namespace android {
@@ -55,13 +54,7 @@
virtual ~BasicHashtableImpl();
void dispose();
-
- inline void edit() {
- if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) {
- clone();
- }
- }
-
+ void edit();
void setTo(const BasicHashtableImpl& other);
void clear();
diff --git a/include/utils/String16.h b/include/utils/String16.h
index d131bfc..b2ab5dc 100644
--- a/include/utils/String16.h
+++ b/include/utils/String16.h
@@ -18,7 +18,6 @@
#define ANDROID_STRING16_H
#include <utils/Errors.h>
-#include <utils/SharedBuffer.h>
#include <utils/Unicode.h>
#include <utils/TypeHelpers.h>
@@ -34,6 +33,7 @@
// ---------------------------------------------------------------------------
+class SharedBuffer;
class String8;
class TextOutput;
@@ -64,10 +64,10 @@
~String16();
inline const char16_t* string() const;
- inline size_t size() const;
- inline const SharedBuffer* sharedBuffer() const;
+ const SharedBuffer* sharedBuffer() const;
+ size_t size() const;
void setTo(const String16& other);
status_t setTo(const char16_t* other);
status_t setTo(const char16_t* other, size_t len);
@@ -144,16 +144,6 @@
return mString;
}
-inline size_t String16::size() const
-{
- return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1;
-}
-
-inline const SharedBuffer* String16::sharedBuffer() const
-{
- return SharedBuffer::bufferFromData(mString);
-}
-
inline String16& String16::operator=(const String16& other)
{
setTo(other);
diff --git a/include/utils/String8.h b/include/utils/String8.h
index ecfcf10..a8a37db 100644
--- a/include/utils/String8.h
+++ b/include/utils/String8.h
@@ -18,7 +18,6 @@
#define ANDROID_STRING8_H
#include <utils/Errors.h>
-#include <utils/SharedBuffer.h>
#include <utils/Unicode.h>
#include <utils/TypeHelpers.h>
@@ -29,6 +28,7 @@
namespace android {
+class SharedBuffer;
class String16;
class TextOutput;
@@ -65,11 +65,11 @@
inline const char* string() const;
inline size_t size() const;
- inline size_t length() const;
inline size_t bytes() const;
inline bool isEmpty() const;
- inline const SharedBuffer* sharedBuffer() const;
+ size_t length() const;
+ const SharedBuffer* sharedBuffer() const;
void clear();
@@ -263,11 +263,6 @@
return mString;
}
-inline size_t String8::length() const
-{
- return SharedBuffer::sizeFromData(mString)-1;
-}
-
inline size_t String8::size() const
{
return length();
@@ -280,12 +275,7 @@
inline size_t String8::bytes() const
{
- return SharedBuffer::sizeFromData(mString)-1;
-}
-
-inline const SharedBuffer* String8::sharedBuffer() const
-{
- return SharedBuffer::bufferFromData(mString);
+ return length();
}
inline bool String8::contains(const char* other) const
diff --git a/libbacktrace/Android.build.mk b/libbacktrace/Android.build.mk
index 8e63dab..84d07f2 100644
--- a/libbacktrace/Android.build.mk
+++ b/libbacktrace/Android.build.mk
@@ -79,8 +79,13 @@
ifeq ($(build_type),host)
# Only build if host builds are supported.
ifeq ($(build_host),true)
- LOCAL_CFLAGS += -Wno-extern-c-compat -fno-omit-frame-pointer
include $(LLVM_HOST_BUILD_MK)
+ # -fno-omit-frame-pointer should be set for host build. Because currently
+ # libunwind can't recognize .debug_frame using dwarf version 4, and it relies
+ # on stack frame pointer to do unwinding on x86.
+ # $(LLVM_HOST_BUILD_MK) overwrites -fno-omit-frame-pointer. so the below line
+ # must be after the include.
+ LOCAL_CFLAGS += -Wno-extern-c-compat -fno-omit-frame-pointer
include $(BUILD_HOST_$(build_target))
endif
endif
diff --git a/libbacktrace/BacktraceMap.cpp b/libbacktrace/BacktraceMap.cpp
index eac20fe..ba86632 100644
--- a/libbacktrace/BacktraceMap.cpp
+++ b/libbacktrace/BacktraceMap.cpp
@@ -63,7 +63,7 @@
// 6f000000-6f01e000 rwxp 00000000 00:0c 16389419 /system/lib/libcomposer.so\n
// 012345678901234567890123456789012345678901234567890123456789
// 0 1 2 3 4 5
- if (sscanf(line, "%lx-%lx %4s %*x %*x:%*x %*d%n",
+ if (sscanf(line, "%lx-%lx %4s %*x %*x:%*x %*d %n",
&start, &end, permissions, &name_pos) != 3) {
#endif
return false;
@@ -82,9 +82,6 @@
map->flags |= PROT_EXEC;
}
- while (isspace(line[name_pos])) {
- name_pos += 1;
- }
map->name = line+name_pos;
if (!map->name.empty() && map->name[map->name.length()-1] == '\n') {
map->name.erase(map->name.length()-1);
diff --git a/libbacktrace/map_info.c b/libbacktrace/map_info.c
deleted file mode 100644
index 073b24a..0000000
--- a/libbacktrace/map_info.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2013 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 <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <log/log.h>
-#include <sys/time.h>
-
-#include <backtrace/backtrace.h>
-
-#if defined(__APPLE__)
-
-// Mac OS vmmap(1) output:
-// __TEXT 0009f000-000a1000 [ 8K 8K] r-x/rwx SM=COW /Volumes/android/dalvik-dev/out/host/darwin-x86/bin/libcorkscrew_test\n
-// 012345678901234567890123456789012345678901234567890123456789
-// 0 1 2 3 4 5
-static backtrace_map_info_t* parse_vmmap_line(const char* line) {
- unsigned long int start;
- unsigned long int end;
- char permissions[4];
- int name_pos;
- if (sscanf(line, "%*21c %lx-%lx [%*13c] %3c/%*3c SM=%*3c %n",
- &start, &end, permissions, &name_pos) != 3) {
- return NULL;
- }
-
- const char* name = line + name_pos;
- size_t name_len = strlen(name);
-
- backtrace_map_info_t* mi = calloc(1, sizeof(backtrace_map_info_t) + name_len);
- if (mi != NULL) {
- mi->start = start;
- mi->end = end;
- mi->is_readable = permissions[0] == 'r';
- mi->is_writable = permissions[1] == 'w';
- mi->is_executable = permissions[2] == 'x';
- memcpy(mi->name, name, name_len);
- mi->name[name_len - 1] = '\0';
- ALOGV("Parsed map: start=0x%08x, end=0x%08x, "
- "is_readable=%d, is_writable=%d is_executable=%d, name=%s",
- mi->start, mi->end,
- mi->is_readable, mi->is_writable, mi->is_executable, mi->name);
- }
- return mi;
-}
-
-backtrace_map_info_t* backtrace_create_map_info_list(pid_t pid) {
- char cmd[1024];
- if (pid < 0) {
- pid = getpid();
- }
- snprintf(cmd, sizeof(cmd), "vmmap -w -resident -submap -allSplitLibs -interleaved %d", pid);
- FILE* fp = popen(cmd, "r");
- if (fp == NULL) {
- return NULL;
- }
-
- char line[1024];
- backtrace_map_info_t* milist = NULL;
- while (fgets(line, sizeof(line), fp) != NULL) {
- backtrace_map_info_t* mi = parse_vmmap_line(line);
- if (mi != NULL) {
- mi->next = milist;
- milist = mi;
- }
- }
- pclose(fp);
- return milist;
-}
-
-#else
-
-// Linux /proc/<pid>/maps lines:
-// 6f000000-6f01e000 rwxp 00000000 00:0c 16389419 /system/lib/libcomposer.so\n
-// 012345678901234567890123456789012345678901234567890123456789
-// 0 1 2 3 4 5
-static backtrace_map_info_t* parse_maps_line(const char* line)
-{
- unsigned long int start;
- unsigned long int end;
- char permissions[5];
- int name_pos;
- if (sscanf(line, "%lx-%lx %4s %*x %*x:%*x %*d%n", &start, &end,
- permissions, &name_pos) != 3) {
- return NULL;
- }
-
- while (isspace(line[name_pos])) {
- name_pos += 1;
- }
- const char* name = line + name_pos;
- size_t name_len = strlen(name);
- if (name_len && name[name_len - 1] == '\n') {
- name_len -= 1;
- }
-
- backtrace_map_info_t* mi = calloc(1, sizeof(backtrace_map_info_t) + name_len + 1);
- if (mi) {
- mi->start = start;
- mi->end = end;
- mi->is_readable = strlen(permissions) == 4 && permissions[0] == 'r';
- mi->is_writable = strlen(permissions) == 4 && permissions[1] == 'w';
- mi->is_executable = strlen(permissions) == 4 && permissions[2] == 'x';
- memcpy(mi->name, name, name_len);
- mi->name[name_len] = '\0';
- ALOGV("Parsed map: start=0x%08x, end=0x%08x, "
- "is_readable=%d, is_writable=%d, is_executable=%d, name=%s",
- mi->start, mi->end,
- mi->is_readable, mi->is_writable, mi->is_executable, mi->name);
- }
- return mi;
-}
-
-backtrace_map_info_t* backtrace_create_map_info_list(pid_t tid) {
- char path[PATH_MAX];
- char line[1024];
- FILE* fp;
- backtrace_map_info_t* milist = NULL;
-
- if (tid < 0) {
- tid = getpid();
- }
- snprintf(path, PATH_MAX, "/proc/%d/maps", tid);
- fp = fopen(path, "r");
- if (fp) {
- while(fgets(line, sizeof(line), fp)) {
- backtrace_map_info_t* mi = parse_maps_line(line);
- if (mi) {
- mi->next = milist;
- milist = mi;
- }
- }
- fclose(fp);
- }
- return milist;
-}
-
-#endif
-
-void backtrace_destroy_map_info_list(backtrace_map_info_t* milist) {
- while (milist) {
- backtrace_map_info_t* next = milist->next;
- free(milist);
- milist = next;
- }
-}
-
-const backtrace_map_info_t* backtrace_find_map_info(
- const backtrace_map_info_t* milist, uintptr_t addr) {
- const backtrace_map_info_t* mi = milist;
- while (mi && !(addr >= mi->start && addr < mi->end)) {
- mi = mi->next;
- }
- return mi;
-}
diff --git a/libmemtrack/Android.mk b/libmemtrack/Android.mk
index a8fb3eb..7b170f5 100644
--- a/libmemtrack/Android.mk
+++ b/libmemtrack/Android.mk
@@ -13,7 +13,6 @@
include $(CLEAR_VARS)
LOCAL_SRC_FILES := memtrack_test.c
LOCAL_MODULE := memtrack_test
-LOCAL_C_INCLUDES := $(call include-path-for, libpagemap)
LOCAL_SHARED_LIBRARIES := libmemtrack libpagemap
LOCAL_CFLAGS := -Wall -Werror
include $(BUILD_EXECUTABLE)
diff --git a/libutils/BasicHashtable.cpp b/libutils/BasicHashtable.cpp
index 491d9e9..1e9f053 100644
--- a/libutils/BasicHashtable.cpp
+++ b/libutils/BasicHashtable.cpp
@@ -22,6 +22,8 @@
#include <utils/BasicHashtable.h>
#include <utils/misc.h>
+#include "SharedBuffer.h"
+
namespace android {
BasicHashtableImpl::BasicHashtableImpl(size_t entrySize, bool hasTrivialDestructor,
@@ -46,6 +48,12 @@
{
}
+void BasicHashtableImpl::edit() {
+ if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) {
+ clone();
+ }
+}
+
void BasicHashtableImpl::dispose() {
if (mBuckets) {
releaseBuckets(mBuckets, mBucketCount);
diff --git a/libutils/SharedBuffer.cpp b/libutils/SharedBuffer.cpp
index 3555fb7..003e386 100644
--- a/libutils/SharedBuffer.cpp
+++ b/libutils/SharedBuffer.cpp
@@ -17,9 +17,10 @@
#include <stdlib.h>
#include <string.h>
-#include <utils/SharedBuffer.h>
#include <utils/Atomic.h>
+#include "SharedBuffer.h"
+
// ---------------------------------------------------------------------------
namespace android {
diff --git a/include/utils/SharedBuffer.h b/libutils/SharedBuffer.h
similarity index 100%
rename from include/utils/SharedBuffer.h
rename to libutils/SharedBuffer.h
diff --git a/libutils/String16.cpp b/libutils/String16.cpp
index 91efdaa..67be9d8 100644
--- a/libutils/String16.cpp
+++ b/libutils/String16.cpp
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <ctype.h>
+#include "SharedBuffer.h"
namespace android {
@@ -165,6 +166,16 @@
SharedBuffer::bufferFromData(mString)->release();
}
+size_t String16::size() const
+{
+ return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1;
+}
+
+const SharedBuffer* String16::sharedBuffer() const
+{
+ return SharedBuffer::bufferFromData(mString);
+}
+
void String16::setTo(const String16& other)
{
SharedBuffer::bufferFromData(other.mString)->acquire();
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index 69313ea..5e85520 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -19,12 +19,13 @@
#include <utils/Compat.h>
#include <utils/Log.h>
#include <utils/Unicode.h>
-#include <utils/SharedBuffer.h>
#include <utils/String16.h>
#include <utils/threads.h>
#include <ctype.h>
+#include "SharedBuffer.h"
+
/*
* Functions outside android is below the namespace android, since they use
* functions and constants in android namespace.
@@ -211,6 +212,16 @@
SharedBuffer::bufferFromData(mString)->release();
}
+size_t String8::length() const
+{
+ return SharedBuffer::sizeFromData(mString)-1;
+}
+
+const SharedBuffer* String8::sharedBuffer() const
+{
+ return SharedBuffer::bufferFromData(mString);
+}
+
String8 String8::format(const char* fmt, ...)
{
va_list args;
diff --git a/libutils/VectorImpl.cpp b/libutils/VectorImpl.cpp
index 2f770f5..2ac158b 100644
--- a/libutils/VectorImpl.cpp
+++ b/libutils/VectorImpl.cpp
@@ -23,9 +23,10 @@
#include <cutils/log.h>
#include <utils/Errors.h>
-#include <utils/SharedBuffer.h>
#include <utils/VectorImpl.h>
+#include "SharedBuffer.h"
+
/*****************************************************************************/
diff --git a/metricsd/Android.mk b/metricsd/Android.mk
index e299042..c35f4e8 100644
--- a/metricsd/Android.mk
+++ b/metricsd/Android.mk
@@ -90,6 +90,7 @@
LOCAL_CLANG := true
LOCAL_CPP_EXTENSION := $(metrics_cpp_extension)
LOCAL_CPPFLAGS := $(metrics_CPPFLAGS)
+LOCAL_RTTI_FLAG := -frtti
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_SHARED_LIBRARIES := $(metrics_shared_libraries)
LOCAL_SRC_FILES := $(libmetrics_sources)
diff --git a/metricsd/metrics_library_mock.h b/metricsd/include/metrics/metrics_library_mock.h
similarity index 100%
rename from metricsd/metrics_library_mock.h
rename to metricsd/include/metrics/metrics_library_mock.h
diff --git a/metricsd/timer_mock.h b/metricsd/include/metrics/timer_mock.h
similarity index 100%
rename from metricsd/timer_mock.h
rename to metricsd/include/metrics/timer_mock.h
diff --git a/metricsd/metrics_daemon.cc b/metricsd/metrics_daemon.cc
index b831ff2..b63be46 100644
--- a/metricsd/metrics_daemon.cc
+++ b/metricsd/metrics_daemon.cc
@@ -76,13 +76,13 @@
// The {Read,Write}Sectors numbers are in sectors/second.
// A sector is usually 512 bytes.
-const char kMetricReadSectorsLongName[] = "Platform.ReadSectorsLong";
-const char kMetricWriteSectorsLongName[] = "Platform.WriteSectorsLong";
-const char kMetricReadSectorsShortName[] = "Platform.ReadSectorsShort";
-const char kMetricWriteSectorsShortName[] = "Platform.WriteSectorsShort";
+const char kMetricReadSectorsLongName[] = "Platform.ReadSectors.PerMinute";
+const char kMetricWriteSectorsLongName[] = "Platform.WriteSectors.PerMinute";
+const char kMetricReadSectorsShortName[] = "Platform.ReadSectors.PerSecond";
+const char kMetricWriteSectorsShortName[] = "Platform.WriteSectors.PerSecond";
const int kMetricStatsShortInterval = 1; // seconds
-const int kMetricStatsLongInterval = 30; // seconds
+const int kMetricStatsLongInterval = 60; // seconds
const int kMetricMeminfoInterval = 30; // seconds
@@ -97,16 +97,16 @@
// Major page faults, i.e. the ones that require data to be read from disk.
-const char kMetricPageFaultsLongName[] = "Platform.PageFaultsLong";
-const char kMetricPageFaultsShortName[] = "Platform.PageFaultsShort";
+const char kMetricPageFaultsLongName[] = "Platform.PageFaults.PerMinute";
+const char kMetricPageFaultsShortName[] = "Platform.PageFaults.PerSecond";
// Swap in and Swap out
-const char kMetricSwapInLongName[] = "Platform.SwapInLong";
-const char kMetricSwapInShortName[] = "Platform.SwapInShort";
+const char kMetricSwapInLongName[] = "Platform.SwapIn.PerMinute";
+const char kMetricSwapInShortName[] = "Platform.SwapIn.PerSecond";
-const char kMetricSwapOutLongName[] = "Platform.SwapOutLong";
-const char kMetricSwapOutShortName[] = "Platform.SwapOutShort";
+const char kMetricSwapOutLongName[] = "Platform.SwapOut.PerMinute";
+const char kMetricSwapOutShortName[] = "Platform.SwapOut.PerSecond";
const char kMetricsProcStatFileName[] = "/proc/stat";
const char kVmStatFileName[] = "/proc/vmstat";
@@ -894,7 +894,7 @@
int swap_used = swap_total - swap_free;
int swap_used_percent = swap_used * 100 / swap_total;
SendSample("Platform.MeminfoSwapUsed", swap_used, 1, 8 * 1000 * 1000, 100);
- SendLinearSample("Platform.MeminfoSwapUsedPercent", swap_used_percent,
+ SendLinearSample("Platform.MeminfoSwapUsed.Percent", swap_used_percent,
100, 101);
}
return true;
diff --git a/metricsd/metrics_daemon_test.cc b/metricsd/metrics_daemon_test.cc
index 1adf9de..cc00cc2 100644
--- a/metricsd/metrics_daemon_test.cc
+++ b/metricsd/metrics_daemon_test.cc
@@ -30,7 +30,7 @@
#include "constants.h"
#include "metrics_daemon.h"
-#include "metrics_library_mock.h"
+#include "metrics/metrics_library_mock.h"
#include "persistent_integer_mock.h"
using base::FilePath;
diff --git a/metricsd/timer_test.cc b/metricsd/timer_test.cc
index 432c3d2..bc7a2a1 100644
--- a/metricsd/timer_test.cc
+++ b/metricsd/timer_test.cc
@@ -20,9 +20,9 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include "metrics/metrics_library_mock.h"
#include "metrics/timer.h"
-#include "metrics_library_mock.h"
-#include "timer_mock.h"
+#include "metrics/timer_mock.h"
using ::testing::_;
using ::testing::Return;
diff --git a/metricsd/uploader/upload_service_test.cc b/metricsd/uploader/upload_service_test.cc
index 873953e..09748db 100644
--- a/metricsd/uploader/upload_service_test.cc
+++ b/metricsd/uploader/upload_service_test.cc
@@ -23,7 +23,7 @@
#include <base/sys_info.h>
#include "constants.h"
-#include "metrics_library_mock.h"
+#include "metrics/metrics_library_mock.h"
#include "persistent_integer.h"
#include "serialization/metric_sample.h"
#include "uploader/metrics_log.h"