diff options
author | Yabin Cui <yabinc@google.com> | 2023-05-12 20:47:27 +0000 |
---|---|---|
committer | Cherrypicker Worker <android-build-cherrypicker-worker@system.gserviceaccount.com> | 2023-05-12 20:47:27 +0000 |
commit | 1c3d80e06459a55d9e3f40c5eece1cc4179295cf (patch) | |
tree | 0e9a8dc65ba26f862efe8c0ac1b13a26fe44aba5 /profcollectd | |
parent | 1fee7b09ac26897b4510b6811dfa4d400b326dba (diff) | |
download | extras-1c3d80e06459a55d9e3f40c5eece1cc4179295cf.tar.gz |
profcollectd: Put usage setting in the report zip file
Bug: 282060259
Test: run am broadcast -a com.android.server.profcollect.UPLOAD_PROFILES
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:1a2601f23f3b60901bbc5f4577a84469ab27d751)
Merged-In: I7ea32d6b840ce99f3290a725d095e960b2870b77
Change-Id: I7ea32d6b840ce99f3290a725d095e960b2870b77
Diffstat (limited to 'profcollectd')
-rw-r--r-- | profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl | 3 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/lib.rs | 2 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/report.rs | 14 | ||||
-rw-r--r-- | profcollectd/libprofcollectd/service.rs | 4 |
4 files changed, 18 insertions, 5 deletions
diff --git a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl index bfc24446..07699309 100644 --- a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl +++ b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl @@ -24,7 +24,8 @@ interface IProfCollectd { void terminate(); void trace_once(@utf8InCpp String tag); void process(); - @utf8InCpp String report(); + /** -1 if there is no usageSetting */ + @utf8InCpp String report(int usageSetting); @utf8InCpp String get_supported_provider(); void registerProviderStatusCallback(IProviderStatusCallback cb); } diff --git a/profcollectd/libprofcollectd/lib.rs b/profcollectd/libprofcollectd/lib.rs index da178f27..c0e12e32 100644 --- a/profcollectd/libprofcollectd/lib.rs +++ b/profcollectd/libprofcollectd/lib.rs @@ -114,7 +114,7 @@ pub fn process() -> Result<()> { /// Process traces and report profile. pub fn report() -> Result<String> { - Ok(get_profcollectd_service()?.report()?) + Ok(get_profcollectd_service()?.report(report::NO_USAGE_SETTING)?) } /// Clear all local data. diff --git a/profcollectd/libprofcollectd/report.rs b/profcollectd/libprofcollectd/report.rs index 6686ec62..cbce1d61 100644 --- a/profcollectd/libprofcollectd/report.rs +++ b/profcollectd/libprofcollectd/report.rs @@ -32,11 +32,18 @@ use zip::ZipWriter; use crate::config::Config; +pub const NO_USAGE_SETTING: i32 = -1; + lazy_static! { pub static ref UUID_CONTEXT: Context = Context::new(0); } -pub fn pack_report(profile: &Path, report: &Path, config: &Config) -> Result<String> { +pub fn pack_report( + profile: &Path, + report: &Path, + config: &Config, + usage_setting: i32, +) -> Result<String> { let mut report = PathBuf::from(report); let report_filename = get_report_filename(&config.node_id)?; report.push(&report_filename); @@ -70,6 +77,11 @@ pub fn pack_report(profile: &Path, report: &Path, config: &Config) -> Result<Str zip.write_all(&buffer)?; Ok(()) })?; + + if usage_setting != NO_USAGE_SETTING { + zip.start_file("usage_setting", options)?; + zip.write_all(usage_setting.to_string().as_bytes())?; + } zip.finish()?; Ok(report_filename) diff --git a/profcollectd/libprofcollectd/service.rs b/profcollectd/libprofcollectd/service.rs index 87c3b3cf..3188888f 100644 --- a/profcollectd/libprofcollectd/service.rs +++ b/profcollectd/libprofcollectd/service.rs @@ -79,11 +79,11 @@ impl IProfCollectd for ProfcollectdBinderService { .context("Failed to process profiles.") .map_err(err_to_binder_status) } - fn report(&self) -> BinderResult<String> { + fn report(&self, usage_setting: i32) -> BinderResult<String> { self.process()?; let lock = &mut *self.lock(); - pack_report(&PROFILE_OUTPUT_DIR, &REPORT_OUTPUT_DIR, &lock.config) + pack_report(&PROFILE_OUTPUT_DIR, &REPORT_OUTPUT_DIR, &lock.config, usage_setting) .context("Failed to create profile report.") .map_err(err_to_binder_status) } |