diff options
author | Zhi Dou <zhidou@google.com> | 2024-03-04 07:23:23 +0000 |
---|---|---|
committer | Zhi Dou <zhidou@google.com> | 2024-03-04 22:03:05 +0000 |
commit | 5c912f481e4220543f154f4c3a41fc56315faec0 (patch) | |
tree | 6a9fe171a06cca9dbe772486f355e00651e1887f | |
parent | a290c6caf8798bc4c1133093da1d797f668b7ec2 (diff) | |
download | build-5c912f481e4220543f154f4c3a41fc56315faec0.tar.gz |
printflags: print flags declared in mainline module
This change adds flag files in mainline module into the read path of
printflags.
Bug: 327466668
Test: build image, flash device with new image, and adb shell printflags
Change-Id: I3c88019086b17ce2eed3c00afff651b1ebd55353
-rw-r--r-- | tools/aconfig/printflags/src/main.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tools/aconfig/printflags/src/main.rs b/tools/aconfig/printflags/src/main.rs index a0c9ee8b9b..7838b51e62 100644 --- a/tools/aconfig/printflags/src/main.rs +++ b/tools/aconfig/printflags/src/main.rs @@ -67,9 +67,23 @@ fn main() -> Result<()> { let device_config_flags = parse_device_config(dc_stdout); // read aconfig_flags.pb files + let apex_pattern = Regex::new(r"^/apex/[^@]+\.[^@]+$").unwrap(); + let mut mount_points = vec![ + "system".to_string(), + "system_ext".to_string(), + "product".to_string(), + "vendor".to_string(), + ]; + for apex in fs::read_dir("/apex")? { + let path_name = apex?.path().display().to_string(); + if let Some(canonical_path) = apex_pattern.captures(&path_name) { + mount_points.push(canonical_path.get(0).unwrap().as_str().to_owned()); + } + } + let mut flags: BTreeMap<String, Vec<String>> = BTreeMap::new(); - for partition in ["system", "system_ext", "product", "vendor"] { - let path = format!("/{}/etc/aconfig_flags.pb", partition); + for mount_point in mount_points { + let path = format!("/{}/etc/aconfig_flags.pb", mount_point); let Ok(bytes) = fs::read(&path) else { eprintln!("warning: failed to read {}", path); continue; @@ -80,7 +94,7 @@ fn main() -> Result<()> { })?; for flag in parsed_flags.parsed_flag { let key = format!("{}/{}.{}", flag.namespace(), flag.package(), flag.name()); - let value = format!("{:?} + {:?} ({})", flag.permission(), flag.state(), partition); + let value = format!("{:?} + {:?} ({})", flag.permission(), flag.state(), mount_point); flags.entry(key).or_default().push(value); } } |