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

Commit 5f3f7068 authored by Ted Bauer's avatar Ted Bauer Committed by Automerger Merge Worker
Browse files

Merge "Invoke updatable aflags" into main am: d19da651

parents cad39b3e d19da651
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -31,3 +31,13 @@ flag {
    purpose: PURPOSE_BUGFIX
  }
}

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
  }
}
+11 −0
Original line number Diff line number Diff line
@@ -39,6 +39,11 @@ pub mod auto_generated {
    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 @@ pub mod auto_generated {
        // 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
    }
}
+30 −0
Original line number Diff line number Diff line
@@ -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 display_which_backing() -> 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 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();