summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Felipe Leme <felipeal@google.com> 2016-04-21 15:42:55 -0700
committer Felipe Leme <felipeal@google.com> 2016-04-27 15:18:11 -0700
commitc4eee56dab06a7de1db18327f8d4831f89d1d640 (patch)
treed5f46bb8865d2e6c82f035eae556502c77159392
parent5882a267d0bee5e9505fe4e714f50378f5ef70d0 (diff)
Remove temporary file on user builds.
BUG: 27366368 Change-Id: Id85566f6ba02fcb6afc122ffe6990d0a14086375
-rw-r--r--cmds/dumpstate/dumpstate.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index ea14c66d59..b731c53377 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -95,6 +95,10 @@ const std::string& ZIP_ROOT_DIR = "FS";
// 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 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver
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 @@ static bool finish_zip_file(const std::string& bugreport_name, const std::string
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;
}