Loading tools/aconfig/aconfig_flags/src/lib.rs +0 −11 Original line number Diff line number Diff line Loading @@ -30,11 +30,6 @@ /// Module used when building with the Android tool-chain #[cfg(not(feature = "cargo"))] pub mod auto_generated { /// Returns the value for the enable_only_new_storage flag. pub fn enable_only_new_storage() -> bool { aconfig_flags_rust::enable_only_new_storage() } /// Returns the value for the enable_aconfigd_from_mainline flag. pub fn enable_aconfigd_from_mainline() -> bool { aconfig_flags_rust::enable_only_new_storage() Loading @@ -49,12 +44,6 @@ pub mod auto_generated { /// Module used when building with cargo #[cfg(feature = "cargo")] pub mod auto_generated { /// Returns a placeholder value for the enable_only_new_storage flag. pub fn enable_only_new_storage() -> bool { // Used only to enable typechecking and testing with cargo true } /// Returns a placeholder value for the enable_aconfigd_from_mainline flag. pub fn enable_aconfigd_from_mainline() -> bool { // Used only to enable typechecking and testing with cargo Loading tools/aconfig/aflags/src/main.rs +5 −30 Original line number Diff line number Diff line Loading @@ -132,11 +132,6 @@ trait FlagSource { fn override_flag(namespace: &str, qualified_name: &str, value: &str) -> Result<()>; } enum FlagSourceType { DeviceConfig, AconfigStorage, } const ABOUT_TEXT: &str = "Tool for reading and writing flags. Rows in the table from the `list` command follow this format: Loading Loading @@ -184,9 +179,6 @@ enum Command { /// <package>.<flag_name> qualified_name: String, }, /// Display which flag storage backs aconfig flags. WhichBacking, } struct PaddingInfo { Loading Loading @@ -251,11 +243,8 @@ fn set_flag(qualified_name: &str, value: &str) -> Result<()> { Ok(()) } fn list(source_type: FlagSourceType, container: Option<String>) -> Result<String> { let flags_unfiltered = match source_type { FlagSourceType::DeviceConfig => DeviceConfigSource::list_flags()?, FlagSourceType::AconfigStorage => AconfigStorageSource::list_flags()?, }; fn list(container: Option<String>) -> Result<String> { let flags_unfiltered = AconfigStorageSource::list_flags()?; if let Some(ref c) = container { ensure!( Loading Loading @@ -293,19 +282,12 @@ fn list(source_type: FlagSourceType, container: Option<String>) -> Result<String Ok(result) } fn display_which_backing() -> String { if aconfig_flags::auto_generated::enable_only_new_storage() { "aconfig_storage".to_string() } else { "device_config".to_string() } } fn invoke_updatable_aflags() { let updatable_command = "/apex/com.android.configinfrastructure/bin/aflags_updatable"; let args: Vec<String> = env::args().collect(); let command_args = if args.len() >= 2 { &args[1..] } else { &["--help".to_string()] }; let default_command_args = ["--help".to_string()]; let command_args = if args.len() >= 2 { &args[1..] } else { &default_command_args }; let mut child = OsCommand::new(updatable_command); for arg in command_args { Loading Loading @@ -337,17 +319,10 @@ fn main() -> Result<()> { let cli = Cli::parse(); let output = match cli.command { Command::List { container } => { if aconfig_flags::auto_generated::enable_only_new_storage() { list(FlagSourceType::AconfigStorage, container) .map_err(|err| anyhow!("could not list flags: {err}")) .map(Some) } else { list(FlagSourceType::DeviceConfig, container).map(Some) } list(container).map_err(|err| anyhow!("could not list flags: {err}")).map(Some) } Command::Enable { qualified_name } => set_flag(&qualified_name, "true").map(|_| None), Command::Disable { qualified_name } => set_flag(&qualified_name, "false").map(|_| None), Command::WhichBacking => Ok(Some(display_which_backing())), }; match output { Ok(Some(text)) => println!("{text}"), Loading Loading
tools/aconfig/aconfig_flags/src/lib.rs +0 −11 Original line number Diff line number Diff line Loading @@ -30,11 +30,6 @@ /// Module used when building with the Android tool-chain #[cfg(not(feature = "cargo"))] pub mod auto_generated { /// Returns the value for the enable_only_new_storage flag. pub fn enable_only_new_storage() -> bool { aconfig_flags_rust::enable_only_new_storage() } /// Returns the value for the enable_aconfigd_from_mainline flag. pub fn enable_aconfigd_from_mainline() -> bool { aconfig_flags_rust::enable_only_new_storage() Loading @@ -49,12 +44,6 @@ pub mod auto_generated { /// Module used when building with cargo #[cfg(feature = "cargo")] pub mod auto_generated { /// Returns a placeholder value for the enable_only_new_storage flag. pub fn enable_only_new_storage() -> bool { // Used only to enable typechecking and testing with cargo true } /// Returns a placeholder value for the enable_aconfigd_from_mainline flag. pub fn enable_aconfigd_from_mainline() -> bool { // Used only to enable typechecking and testing with cargo Loading
tools/aconfig/aflags/src/main.rs +5 −30 Original line number Diff line number Diff line Loading @@ -132,11 +132,6 @@ trait FlagSource { fn override_flag(namespace: &str, qualified_name: &str, value: &str) -> Result<()>; } enum FlagSourceType { DeviceConfig, AconfigStorage, } const ABOUT_TEXT: &str = "Tool for reading and writing flags. Rows in the table from the `list` command follow this format: Loading Loading @@ -184,9 +179,6 @@ enum Command { /// <package>.<flag_name> qualified_name: String, }, /// Display which flag storage backs aconfig flags. WhichBacking, } struct PaddingInfo { Loading Loading @@ -251,11 +243,8 @@ fn set_flag(qualified_name: &str, value: &str) -> Result<()> { Ok(()) } fn list(source_type: FlagSourceType, container: Option<String>) -> Result<String> { let flags_unfiltered = match source_type { FlagSourceType::DeviceConfig => DeviceConfigSource::list_flags()?, FlagSourceType::AconfigStorage => AconfigStorageSource::list_flags()?, }; fn list(container: Option<String>) -> Result<String> { let flags_unfiltered = AconfigStorageSource::list_flags()?; if let Some(ref c) = container { ensure!( Loading Loading @@ -293,19 +282,12 @@ fn list(source_type: FlagSourceType, container: Option<String>) -> Result<String Ok(result) } fn display_which_backing() -> String { if aconfig_flags::auto_generated::enable_only_new_storage() { "aconfig_storage".to_string() } else { "device_config".to_string() } } fn invoke_updatable_aflags() { let updatable_command = "/apex/com.android.configinfrastructure/bin/aflags_updatable"; let args: Vec<String> = env::args().collect(); let command_args = if args.len() >= 2 { &args[1..] } else { &["--help".to_string()] }; let default_command_args = ["--help".to_string()]; let command_args = if args.len() >= 2 { &args[1..] } else { &default_command_args }; let mut child = OsCommand::new(updatable_command); for arg in command_args { Loading Loading @@ -337,17 +319,10 @@ fn main() -> Result<()> { let cli = Cli::parse(); let output = match cli.command { Command::List { container } => { if aconfig_flags::auto_generated::enable_only_new_storage() { list(FlagSourceType::AconfigStorage, container) .map_err(|err| anyhow!("could not list flags: {err}")) .map(Some) } else { list(FlagSourceType::DeviceConfig, container).map(Some) } list(container).map_err(|err| anyhow!("could not list flags: {err}")).map(Some) } Command::Enable { qualified_name } => set_flag(&qualified_name, "true").map(|_| None), Command::Disable { qualified_name } => set_flag(&qualified_name, "false").map(|_| None), Command::WhichBacking => Ok(Some(display_which_backing())), }; match output { Ok(Some(text)) => println!("{text}"), Loading