/// Facade to launch basemgr from Sl4f
/// Use default config if custom config is not provided.
Facade to launch basemgr from Sl4f
Use default config if custom config is not provided.
Facade to launch basemgr from Sl4f Use default config if custom config is not provided .
pub async fn start_basemgr(&self, args: Value) -> Result<BasemgrResult, Error> {
        match self.discover_basemgr_service()? {
            Some(mut proxy) => {
                proxy.shutdown()?;
            }
            None => {}
        };
        let mut launch_options = client::LaunchOptions::new();
        // if we cannot get "basemgr" which means there's no custom config or it's not valid, we use default config
        // host the custom startup.config in /config_override/data
        match args.get("config") {
            Some(config) => {
                let con_str = config.to_string();
                let (dir2_server, dir2_client) = zx::Channel::create()?;
                fasync::Task::spawn(async move {
                    let mut pkg_dir = pseudo_directory! {"startup.config" => read_only_str(|| Ok(con_str.to_string()))};
                    pkg_dir.open(
                        OPEN_RIGHT_READABLE | OPEN_RIGHT_WRITABLE,
                        MODE_TYPE_DIRECTORY,
                        &mut iter::empty(),
                        ServerEnd::new(dir2_server),
                    );
                    pkg_dir.await;
                    Ok::<(), Error>(())
                }.unwrap_or_else(|e: anyhow::Error| fx_log_err!("Psuedo dir stopped serving: {:?}", e)),
                ).detach();
                launch_options.add_handle_to_namespace(
                    "/config_override/data".to_string(),
                    dir2_client.into_handle(),
                );
            }
            None => {}
        }
        //launch basemgr
        let tag = "BaseManagerFacade::start_basemgr";
        let launcher = match client::launcher() {
            Ok(r) => r,
            Err(err) => fx_err_and_bail!(
                &with_line!(tag),
                format_err!("Failed to get launcher service: {}", err)
            ),
        };
        let basemgr = client::launch_with_options(
            &launcher,
            COMPONENT_URL.to_string(),
            None,
            launch_options,
        )?;
        // detach when basemgr out dir is ready as it's a signal
        let event_stream = basemgr.controller().take_event_stream();
        event_stream
            .try_filter_map(|event| {
                let event = match event {
                    ComponentControllerEvent::OnDirectoryReady {} => {
                        Some(basemgr.controller().detach())
                    }
                    _ => None,
                };
                future::ready(Ok(event))
            })
            .next()
            .await;
        Ok(BasemgrResult::Success)
    }
pub async fn start_basemgr ( & self , args : Value ) -> Result < BasemgrResult , Error > { match self . discover_basemgr_service ( ) ? { Some ( mut proxy ) => { proxy . shutdown ( ) ? ; } None => { } } ; let mut launch_options = client :: LaunchOptions :: new ( ) ; // if we cannot get "basemgr" which means there's no custom config or it's not valid, we use default config // host the custom startup.config in /config_override/data match args . get ( " " ) { Some ( config ) => { let con_str = config . to_string ( ) ; let ( dir2_server , dir2_client ) = zx :: Channel :: create ( ) ? ; fasync :: Task :: spawn ( async move { let mut pkg_dir = pseudo_directory ! { " " read_only_str ( Ok ( con_str to_string ( ) ) ) } ; pkg_dir . open ( OPEN_RIGHT_READABLE | OPEN_RIGHT_WRITABLE , MODE_TYPE_DIRECTORY , & mut iter :: empty ( ) , ServerEnd :: new ( dir2_server ) , ) ; pkg_dir . await ; Ok :: < ( ) , Error > ( ( ) ) } . unwrap_or_else ( | e : anyhow :: Error | fx_log_err ! ( " " e ) ) , ) . detach ( ) ; launch_options . add_handle_to_namespace ( " " . to_string ( ) , dir2_client . into_handle ( ) , ) ; } None => { } } //launch basemgr let tag = " " ; let launcher = match client :: launcher ( ) { Ok ( r ) => r , Err ( err ) => fx_err_and_bail ! ( with_line ( tag ) format_err ( " " err ) ) , } ; let basemgr = client :: launch_with_options ( & launcher , COMPONENT_URL . to_string ( ) , None , launch_options , ) ? ; // detach when basemgr out dir is ready as it's a signal let event_stream = basemgr . controller ( ) . take_event_stream ( ) ; event_stream . try_filter_map ( | event | { let event = match event { ComponentControllerEvent :: OnDirectoryReady { } => { Some ( basemgr . controller ( ) . detach ( ) ) } _ => None , } ; future :: ready ( Ok ( event ) ) } ) . next ( ) . await ; Ok ( BasemgrResult :: Success ) }
Facade to launch basemgr from Sl4f
Use default config if custom config is not provided.
Facade to launch basemgr from Sl4f Use default config if custom config is not provided .
&self
args
Value