From 9338007cffc6c96dba546e3a06b83a34a81b390a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Thu, 20 Jul 2023 09:25:56 +0200 Subject: [PATCH 1/3] aconfig: remove the 'debug' dump format The --format=debug dump output format is largely superseded by the textproto format now that aconfig doesn't use hand-written wrappers around the auto-generated proto struct anymore. Remove the format to reduce the risk of code rot. Bug: 283910447 Test: atest aconfig.test Change-Id: I6700fc4eafd3fa3a63952109c0105d34c7ffd98b --- tools/aconfig/src/commands.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tools/aconfig/src/commands.rs b/tools/aconfig/src/commands.rs index bf4592175c..2e2aa0f6c4 100644 --- a/tools/aconfig/src/commands.rs +++ b/tools/aconfig/src/commands.rs @@ -213,7 +213,6 @@ pub fn create_device_config_sysprops(mut input: Input) -> Result> { #[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)] pub enum DumpFormat { Text, - Debug, Protobuf, Textproto, } @@ -238,12 +237,6 @@ pub fn dump_parsed_flags(mut input: Vec, format: DumpFormat) -> Result { - for parsed_flag in parsed_flags.parsed_flag.into_iter() { - let line = format!("{:#?}\n", parsed_flag); - output.extend_from_slice(line.as_bytes()); - } - } DumpFormat::Protobuf => { parsed_flags.write_to_vec(&mut output)?; } From 3fa2f078ff631ae6cb1dfe6e3f4348f3934b39df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Thu, 20 Jul 2023 09:35:05 +0200 Subject: [PATCH 2/3] aconfig: improve the 'text' dump format Standardize the flag values as ' + ', e.g. 'READ_ONLY + ENABLED'. Bug: 283910447 Test: atest aconfig.test Test: printflags # manually inspect output Change-Id: I60f74196816327613bd8165a688f8b36da5bdac7 --- tools/aconfig/src/commands.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/aconfig/src/commands.rs b/tools/aconfig/src/commands.rs index 2e2aa0f6c4..5ca53a733c 100644 --- a/tools/aconfig/src/commands.rs +++ b/tools/aconfig/src/commands.rs @@ -228,11 +228,11 @@ pub fn dump_parsed_flags(mut input: Vec, format: DumpFormat) -> Result { for parsed_flag in parsed_flags.parsed_flag.into_iter() { let line = format!( - "{}/{}: {:?} {:?}\n", + "{}/{}: {:?} + {:?}\n", parsed_flag.package(), parsed_flag.name(), - parsed_flag.state(), - parsed_flag.permission() + parsed_flag.permission(), + parsed_flag.state() ); output.extend_from_slice(line.as_bytes()); } @@ -319,7 +319,7 @@ mod tests { let input = parse_test_flags_as_input(); let bytes = dump_parsed_flags(vec![input], DumpFormat::Text).unwrap(); let text = std::str::from_utf8(&bytes).unwrap(); - assert!(text.contains("com.android.aconfig.test/disabled_ro: DISABLED READ_ONLY")); + assert!(text.contains("com.android.aconfig.test/disabled_ro: READ_ONLY + DISABLED")); } #[test] From ea4981407b1dca6f4331c4bc75e55090bc143e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Thu, 20 Jul 2023 11:07:35 +0200 Subject: [PATCH 3/3] aconfig: add 'verbose' dump format Add a new --format=verbose dump output format. This is identical to the default 'text' format but includes the source files from which the flag declaration and values were read, and is intended to help debug why a flag isn't set to some expected value. Bug: 283910447 Test: atest aconfig.test Test: printflags --format=verbose # manually inspect output Change-Id: I03a1c8d940e7a0c6f91e986c5bafa4aa6cd1125a --- tools/aconfig/src/commands.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/aconfig/src/commands.rs b/tools/aconfig/src/commands.rs index 5ca53a733c..4f0a706dc0 100644 --- a/tools/aconfig/src/commands.rs +++ b/tools/aconfig/src/commands.rs @@ -213,6 +213,7 @@ pub fn create_device_config_sysprops(mut input: Input) -> Result> { #[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)] pub enum DumpFormat { Text, + Verbose, Protobuf, Textproto, } @@ -237,6 +238,21 @@ pub fn dump_parsed_flags(mut input: Vec, format: DumpFormat) -> Result { + for parsed_flag in parsed_flags.parsed_flag.into_iter() { + let sources: Vec<_> = + parsed_flag.trace.iter().map(|tracepoint| tracepoint.source()).collect(); + let line = format!( + "{}/{}: {:?} + {:?} ({})\n", + parsed_flag.package(), + parsed_flag.name(), + parsed_flag.permission(), + parsed_flag.state(), + sources.join(", ") + ); + output.extend_from_slice(line.as_bytes()); + } + } DumpFormat::Protobuf => { parsed_flags.write_to_vec(&mut output)?; }