Merge "aconfig: Print flags with namespace, and sort them" into main

This commit is contained in:
Treehugger Robot
2024-01-12 04:31:30 +00:00
committed by Gerrit Code Review

View File

@@ -20,6 +20,7 @@ use aconfig_protos::aconfig::Flag_state as State;
use aconfig_protos::aconfig::Parsed_flags as ProtoParsedFlags; use aconfig_protos::aconfig::Parsed_flags as ProtoParsedFlags;
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use regex::Regex; use regex::Regex;
use std::collections::BTreeMap;
use std::collections::HashMap; use std::collections::HashMap;
use std::process::Command; use std::process::Command;
use std::{fs, str}; use std::{fs, str};
@@ -66,7 +67,7 @@ fn main() -> Result<()> {
let device_config_flags = parse_device_config(dc_stdout); let device_config_flags = parse_device_config(dc_stdout);
// read aconfig_flags.pb files // read aconfig_flags.pb files
let mut flags: HashMap<String, Vec<String>> = HashMap::new(); let mut flags: BTreeMap<String, Vec<String>> = BTreeMap::new();
for partition in ["system", "system_ext", "product", "vendor"] { for partition in ["system", "system_ext", "product", "vendor"] {
let path = format!("/{}/etc/aconfig_flags.pb", partition); let path = format!("/{}/etc/aconfig_flags.pb", partition);
let Ok(bytes) = fs::read(&path) else { let Ok(bytes) = fs::read(&path) else {
@@ -86,11 +87,10 @@ fn main() -> Result<()> {
// print flags // print flags
for (key, mut value) in flags { for (key, mut value) in flags {
let (_, package_and_name) = key.split_once('/').unwrap();
if let Some(dc_value) = device_config_flags.get(&key) { if let Some(dc_value) = device_config_flags.get(&key) {
value.push(dc_value.to_string()); value.push(dc_value.to_string());
} }
println!("{}: {}", package_and_name, value.join(", ")); println!("{}: {}", key, value.join(", "));
} }
Ok(()) Ok(())