Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 778bb0d0 authored by Dennis Shen's avatar Dennis Shen
Browse files

clean up enable_only_new_storage flag

The flag is fully launched, then this flag is removed from actual code. now cleaning up in other places.

Test: m
Flag: com.android.aconfig.flags.invoke_updatable_aflags
Change-Id: I4c90de2a97ff94d3cee7e8ca873ba6b6dc25dba1
parent 45782010
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -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()
@@ -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
+5 −30
Original line number Diff line number Diff line
@@ -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:
@@ -184,9 +179,6 @@ enum Command {
        /// <package>.<flag_name>
        qualified_name: String,
    },

    /// Display which flag storage backs aconfig flags.
    WhichBacking,
}

struct PaddingInfo {
@@ -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!(
@@ -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 {
@@ -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}"),