Merge "Invoke updatable aflags" into main
diff --git a/tools/aconfig/aconfig_flags/flags.aconfig b/tools/aconfig/aconfig_flags/flags.aconfig
index 96bb81a..2488b5c 100644
--- a/tools/aconfig/aconfig_flags/flags.aconfig
+++ b/tools/aconfig/aconfig_flags/flags.aconfig
@@ -30,4 +30,14 @@
metadata {
purpose: PURPOSE_BUGFIX
}
-}
\ No newline at end of file
+}
+
+flag {
+ name: "invoke_updatable_aflags"
+ namespace: "core_experiments_team_internal"
+ bug: "385383899"
+ description: "When enabled, the system aflags binary invokes the updatable aflags."
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/tools/aconfig/aconfig_flags/src/lib.rs b/tools/aconfig/aconfig_flags/src/lib.rs
index 2e89127..dc507ae 100644
--- a/tools/aconfig/aconfig_flags/src/lib.rs
+++ b/tools/aconfig/aconfig_flags/src/lib.rs
@@ -39,6 +39,11 @@
pub fn enable_aconfigd_from_mainline() -> bool {
aconfig_flags_rust::enable_only_new_storage()
}
+
+ /// Returns the value for the invoke_updatable_aflags flag.
+ pub fn invoke_updatable_aflags() -> bool {
+ aconfig_flags_rust::invoke_updatable_aflags()
+ }
}
/// Module used when building with cargo
@@ -55,4 +60,10 @@
// Used only to enable typechecking and testing with cargo
true
}
+
+ /// Returns the value for the invoke_updatable_aflags flag.
+ pub fn invoke_updatable_aflags() -> bool {
+ // Used only to enable typechecking and testing with cargo
+ true
+ }
}
diff --git a/tools/aconfig/aflags/src/main.rs b/tools/aconfig/aflags/src/main.rs
index 8173bc2..e4af2a7 100644
--- a/tools/aconfig/aflags/src/main.rs
+++ b/tools/aconfig/aflags/src/main.rs
@@ -16,6 +16,9 @@
//! `aflags` is a device binary to read and write aconfig flags.
+use std::env;
+use std::process::{Command as OsCommand, Stdio};
+
use anyhow::{anyhow, ensure, Result};
use clap::Parser;
@@ -298,7 +301,34 @@
}
}
+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 mut child = OsCommand::new(updatable_command);
+ for arg in command_args {
+ child.arg(arg);
+ }
+
+ let output = child
+ .stdin(Stdio::piped())
+ .stdout(Stdio::piped())
+ .spawn()
+ .expect("failed to execute child")
+ .wait_with_output()
+ .expect("failed to execute command");
+
+ println!("{}", String::from_utf8_lossy(&output.stdout).trim());
+}
+
fn main() -> Result<()> {
+ if aconfig_flags::auto_generated::invoke_updatable_aflags() {
+ invoke_updatable_aflags();
+ return Ok(());
+ }
+
ensure!(nix::unistd::Uid::current().is_root(), "must be root");
let cli = Cli::parse();