From 789d7a5882cba2074e8a389e75ddbc29ef4c3cf7 Mon Sep 17 00:00:00 2001 From: Gavin Corkery Date: Wed, 24 Feb 2021 23:52:35 +0000 Subject: Store ANR traces in internal directory By storing ANR traces in /bugreports/dumptrace_XXXXXX, dumpstate may unlink the ANR traces successfully to avoid a storage leak. Test: adb bugreport, ensure ANR traces are in the bugreport and that the temporary ANR traces file has been unlinked Bug: 122292569 Bug: 179812900 Change-Id: I50e62d5dea1cb7d2aea316553eec310fb579e52d --- cmds/dumpstate/dumpstate.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 9e73dcc4d5..70ba806176 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -2059,7 +2059,7 @@ static void DumpstateWifiOnly() { } Dumpstate::RunStatus Dumpstate::DumpTraces(const char** path) { - const std::string temp_file_pattern = "/data/anr/dumptrace_XXXXXX"; + const std::string temp_file_pattern = ds.bugreport_internal_dir_ + "/dumptrace_XXXXXX"; const size_t buf_size = temp_file_pattern.length() + 1; std::unique_ptr file_name_buf(new char[buf_size]); memcpy(file_name_buf.get(), temp_file_pattern.c_str(), buf_size); @@ -3066,6 +3066,9 @@ void Dumpstate::CleanupTmpFiles() { android::os::UnlinkAndLogOnError(tmp_path_); android::os::UnlinkAndLogOnError(screenshot_path_); android::os::UnlinkAndLogOnError(path_); + if (dump_traces_path != nullptr) { + android::os::UnlinkAndLogOnError(dump_traces_path); + } } void Dumpstate::EnableParallelRunIfNeeded() { -- cgit v1.2.3-59-g8ed1b