Merge "Remove temporary file on user builds." into nyc-dev
am: d97e99f
* commit 'd97e99f7d4665530a699bb72ee694174cb938536':
Remove temporary file on user builds.
Change-Id: Ie53c87ba8508d024ac0bf55a62c8934fb323ccc1
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index d903ed1..2873e40 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -95,6 +95,10 @@
// TODO: change to "v1" before final N build
static std::string VERSION_DEFAULT = "v1-dev4";
+static bool is_user_build() {
+ return 0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1);
+}
+
/* gets the tombstone data, according to the bugreport type: if zipped gets all tombstones,
* otherwise gets just those modified in the last half an hour. */
static void get_tombstone_fds(tombstone_data_t data[NUM_TOMBSTONES]) {
@@ -872,7 +876,7 @@
char ril_dumpstate_timeout[PROPERTY_VALUE_MAX] = {0};
property_get("ril.dumpstate.timeout", ril_dumpstate_timeout, "30");
if (strnlen(ril_dumpstate_timeout, PROPERTY_VALUE_MAX - 1) > 0) {
- if (0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1)) {
+ if (is_user_build()) {
// su does not exist on user builds, so try running without it.
// This way any implementations of vril-dump that do not require
// root can run on user builds.
@@ -976,6 +980,15 @@
return false;
}
+ if (is_user_build()) {
+ MYLOGD("Removing temporary file %s\n", bugreport_path.c_str())
+ if (remove(bugreport_path.c_str())) {
+ ALOGW("remove(%s): %s\n", bugreport_path.c_str(), strerror(errno));
+ }
+ } else {
+ MYLOGD("Keeping temporary file %s on non-user build\n", bugreport_path.c_str())
+ }
+
return true;
}