summaryrefslogtreecommitdiff
path: root/dumpstate
diff options
context:
space:
mode:
authorCalvin On <con@google.com>2016-06-16 10:58:09 -0700
committerCalvin On <con@google.com>2016-06-29 15:00:43 -0700
commit46b5a7c650c5021ed51e55cec0b9ca58ecfe86e6 (patch)
treebaad5e4cc3cc07a45636c88cee4a691a05e649e3 /dumpstate
parentddf3b24fe6a412fc769400a2adb50d43c7f417e6 (diff)
downloadbullhead-46b5a7c650c5021ed51e55cec0b9ca58ecfe86e6.tar.gz
Add Wearable node.db to Bullhead dumpstate.
Bug: 28640932 Change-Id: I6267d1c6b34b9c21aabc368eec20019c13f3c027
Diffstat (limited to 'dumpstate')
-rw-r--r--dumpstate/dumpstate.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/dumpstate/dumpstate.cpp b/dumpstate/dumpstate.cpp
index ef6d6ff..7887f6f 100644
--- a/dumpstate/dumpstate.cpp
+++ b/dumpstate/dumpstate.cpp
@@ -13,9 +13,53 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <errno.h>
+#include <string>
+#include <string.h>
+#define LOG_TAG "dumpstate"
+#include <cutils/log.h>
#include <dumpstate.h>
+/**
+ * Dump Wearable node database if present.
+ *
+ * TODO This function is a temporary solution for Android Wear and should be
+ * removed once dumpsys has proper support for adding files to the zip, or
+ * moved to a common library.
+ */
+void dump_wear_nodedb() {
+ // we rely on su to workaround selinux permissions in the app data directory
+ // so this will only work on userdebug builds
+ if (is_user_build()) {
+ return;
+ }
+
+ std::string tmp_nodedb_path = bugreport_dir + "/wear-nodedb.db";
+ std::string wear_nodedb_path = "/data/data/com.google.android.gms/databases/node.db";
+
+ if (run_command("COPY WEAR NODE DB", 600, SU_PATH, "root",
+ "cp", wear_nodedb_path.c_str(), tmp_nodedb_path.c_str(), NULL)) {
+ MYLOGE("Wear node.db copy failed\n");
+ return;
+ }
+ if (run_command("CHOWN WEAR NODE DB", 600, SU_PATH, "root",
+ "chown", "shell:shell", tmp_nodedb_path.c_str(), NULL)) {
+ MYLOGE("Wear node.db chown failed\n");
+ return;
+ }
+ if (add_zip_entry(ZIP_ROOT_DIR + wear_nodedb_path, tmp_nodedb_path)) {
+ MYLOGD("Wear node.db added to zip file\n");
+ } else {
+ MYLOGE("Unable to add zip for Wear node.db\n");
+ }
+ // unconditionally remove the db since it's just a copy
+ if (remove(tmp_nodedb_path.c_str())) {
+ MYLOGE("Error removing Wear node.db file %s: %s\n",
+ tmp_nodedb_path.c_str(), strerror(errno));
+ }
+}
+
void dumpstate_board()
{
dump_file("INTERRUPTS", "/proc/interrupts");
@@ -36,4 +80,6 @@ void dumpstate_board()
run_command("LITTLE cluster cpuidle", 5, SU_PATH, "root", "/system/bin/sh", "-c", "for d in $(ls -d /sys/devices/system/cpu/cpu0/cpuidle/state*); do echo \"$d: `cat $d/name` `cat $d/desc` `cat $d/time` `cat $d/usage`\"; done", NULL);
dump_file("big cluster time-in-state", "/sys/devices/system/cpu/cpu4/cpufreq/stats/time_in_state");
run_command("big cluster cpuidle", 5, SU_PATH, "root", "/system/bin/sh", "-c", "for d in $(ls -d /sys/devices/system/cpu/cpu4/cpuidle/state*); do echo \"$d: `cat $d/name` `cat $d/desc` `cat $d/time` `cat $d/usage`\"; done", NULL);
+
+ dump_wear_nodedb();
};