summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2021-03-04 08:56:55 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-03-04 08:56:55 +0000
commitc444a466a1526a4868184d9a0a541a51d4c08070 (patch)
tree3a90d653b0596bf1d18687cb7740884ef4930865
parentd8fdc08b82e7a645c7cbc5b21df3a66dc4edb9ea (diff)
parent4e33c57d7714c496436510d473904e142c04585c (diff)
downloadextras-c444a466a1526a4868184d9a0a541a51d4c08070.tar.gz
Merge "profcollect: Remove report at the old location"
-rw-r--r--profcollectd/libprofcollectd/config.rs2
-rw-r--r--profcollectd/libprofcollectd/service.rs14
2 files changed, 14 insertions, 2 deletions
diff --git a/profcollectd/libprofcollectd/config.rs b/profcollectd/libprofcollectd/config.rs
index e9a1d288..e72fa47a 100644
--- a/profcollectd/libprofcollectd/config.rs
+++ b/profcollectd/libprofcollectd/config.rs
@@ -30,6 +30,8 @@ lazy_static! {
pub static ref TRACE_OUTPUT_DIR: &'static Path = Path::new("/data/misc/profcollectd/trace/");
pub static ref PROFILE_OUTPUT_DIR: &'static Path = Path::new("/data/misc/profcollectd/output/");
pub static ref REPORT_OUTPUT_DIR: &'static Path = Path::new("/data/misc/profcollectd/report/");
+ pub static ref OLD_REPORT_OUTPUT_FILE: &'static Path =
+ Path::new("/data/misc/profcollectd/report.zip");
pub static ref CONFIG_FILE: &'static Path =
Path::new("/data/misc/profcollectd/output/config.json");
}
diff --git a/profcollectd/libprofcollectd/service.rs b/profcollectd/libprofcollectd/service.rs
index c01b8492..d3413b84 100644
--- a/profcollectd/libprofcollectd/service.rs
+++ b/profcollectd/libprofcollectd/service.rs
@@ -21,13 +21,16 @@ use binder::public_api::Result as BinderResult;
use binder::Status;
use profcollectd_aidl_interface::aidl::com::android::server::profcollect::IProfCollectd::IProfCollectd;
use std::ffi::CString;
-use std::fs::{create_dir, read_to_string, remove_dir_all, write};
+use std::fs::{create_dir, read_to_string, remove_dir_all, remove_file, write};
use std::{
str::FromStr,
sync::{Mutex, MutexGuard},
};
-use crate::config::{Config, CONFIG_FILE, PROFILE_OUTPUT_DIR, REPORT_OUTPUT_DIR, TRACE_OUTPUT_DIR};
+use crate::config::{
+ Config, CONFIG_FILE, OLD_REPORT_OUTPUT_FILE, PROFILE_OUTPUT_DIR, REPORT_OUTPUT_DIR,
+ TRACE_OUTPUT_DIR,
+};
use crate::report::pack_report;
use crate::scheduler::Scheduler;
@@ -104,6 +107,13 @@ impl ProfcollectdBinderService {
remove_dir_all(*TRACE_OUTPUT_DIR)?;
create_dir(*PROFILE_OUTPUT_DIR)?;
create_dir(*TRACE_OUTPUT_DIR)?;
+
+ // Remove the report file in the old output location.
+ // TODO: Remove this after all devices have updated to the new profcollect.
+ if OLD_REPORT_OUTPUT_FILE.exists() {
+ remove_file(*OLD_REPORT_OUTPUT_FILE)?;
+ }
+
write(*CONFIG_FILE, &new_config.to_string())?;
}