summaryrefslogtreecommitdiff
path: root/profcollectd
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2021-11-30 14:24:10 +0800
committerYi Kong <yikong@google.com>2021-11-30 14:27:44 +0800
commit6e3fe967430b14ac1289cf4521e1cf4105d3a2c4 (patch)
treef95dc97734acb8c018ff2c5784bfd3444e12ed18 /profcollectd
parentdbb2c44f8b2c07e46f9c9b3179c6a78f3976afbd (diff)
downloadextras-6e3fe967430b14ac1289cf4521e1cf4105d3a2c4.tar.gz
profcollectd: Clean up dead code
We moved away from directly copying reports to internal storage for report uploading, remove the unused methods. Test: build Change-Id: I5071e28c20cf1f4b9588da4b51495e160ef3170f
Diffstat (limited to 'profcollectd')
-rw-r--r--profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl2
-rw-r--r--profcollectd/libprofcollectd/config.rs3
-rw-r--r--profcollectd/libprofcollectd/service.rs50
3 files changed, 3 insertions, 52 deletions
diff --git a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl
index 5dcf1119..c8f33a1e 100644
--- a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl
+++ b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl
@@ -23,7 +23,5 @@ interface IProfCollectd {
void trace_once(@utf8InCpp String tag);
void process();
@utf8InCpp String report();
- void copy_report_to_bb(int bb_profile_id, @utf8InCpp String report);
- void delete_report(@utf8InCpp String report);
@utf8InCpp String get_supported_provider();
}
diff --git a/profcollectd/libprofcollectd/config.rs b/profcollectd/libprofcollectd/config.rs
index 5f8982cf..74c3c8f1 100644
--- a/profcollectd/libprofcollectd/config.rs
+++ b/profcollectd/libprofcollectd/config.rs
@@ -37,9 +37,6 @@ 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 BETTERBUG_CACHE_DIR_PREFIX: &'static Path = Path::new("/data/user/");
- pub static ref BETTERBUG_CACHE_DIR_SUFFIX: &'static Path =
- Path::new("com.google.android.apps.internal.betterbug/cache/");
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 89fa8acb..0062b2b3 100644
--- a/profcollectd/libprofcollectd/service.rs
+++ b/profcollectd/libprofcollectd/service.rs
@@ -16,20 +16,18 @@
//! ProfCollect Binder service implementation.
-use anyhow::{anyhow, bail, Context, Error, Result};
+use anyhow::{anyhow, Context, Error, Result};
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::{copy, read_dir, read_to_string, remove_file, write};
-use std::path::PathBuf;
+use std::fs::{read_dir, read_to_string, remove_file, write};
use std::str::FromStr;
use std::sync::{Mutex, MutexGuard};
use std::time::Duration;
use crate::config::{
- clear_data, Config, BETTERBUG_CACHE_DIR_PREFIX, BETTERBUG_CACHE_DIR_SUFFIX, CONFIG_FILE,
- PROFILE_OUTPUT_DIR, REPORT_OUTPUT_DIR, REPORT_RETENTION_SECS,
+ clear_data, Config, CONFIG_FILE, PROFILE_OUTPUT_DIR, REPORT_OUTPUT_DIR, REPORT_RETENTION_SECS,
};
use crate::report::{get_report_ts, pack_report};
use crate::scheduler::Scheduler;
@@ -88,53 +86,11 @@ impl IProfCollectd for ProfcollectdBinderService {
.context("Failed to create profile report.")
.map_err(err_to_binder_status)
}
- fn delete_report(&self, report_name: &str) -> BinderResult<()> {
- verify_report_name(report_name).map_err(err_to_binder_status)?;
-
- let mut report = PathBuf::from(&*REPORT_OUTPUT_DIR);
- report.push(report_name);
- report.set_extension("zip");
- remove_file(&report).ok();
- Ok(())
- }
- fn copy_report_to_bb(&self, bb_profile_id: i32, report_name: &str) -> BinderResult<()> {
- if bb_profile_id < 0 {
- return Err(err_to_binder_status(anyhow!("Invalid profile ID")));
- }
- verify_report_name(report_name).map_err(err_to_binder_status)?;
-
- let mut report = PathBuf::from(&*REPORT_OUTPUT_DIR);
- report.push(report_name);
- report.set_extension("zip");
-
- let mut dest = PathBuf::from(&*BETTERBUG_CACHE_DIR_PREFIX);
- dest.push(bb_profile_id.to_string());
- dest.push(&*BETTERBUG_CACHE_DIR_SUFFIX);
- if !dest.is_dir() {
- return Err(err_to_binder_status(anyhow!("Cannot open BetterBug cache dir")));
- }
- dest.push(report_name);
- dest.set_extension("zip");
-
- copy(report, dest)
- .map(|_| ())
- .context("Failed to copy report to bb storage.")
- .map_err(err_to_binder_status)
- }
fn get_supported_provider(&self) -> BinderResult<String> {
Ok(self.lock().scheduler.get_trace_provider_name().to_string())
}
}
-/// Verify that the report name is valid, i.e. not a relative path component, to prevent potential
-/// attack.
-fn verify_report_name(report_name: &str) -> Result<()> {
- match report_name.chars().all(|c| c.is_ascii_hexdigit() || c == '-') {
- true => Ok(()),
- false => bail!("Invalid report name: {}", report_name),
- }
-}
-
impl ProfcollectdBinderService {
pub fn new() -> Result<Self> {
let new_scheduler = Scheduler::new()?;