async fn procedure_request(&mut self, request: SlcRequest) {
        let marker = (&request).into();
        match request {
            SlcRequest::GetAgFeatures { response } => {
                let features = (&self._local_config).into();
                // Update the procedure with the retrieved AG update.
                self.connection.receive_ag_request(marker, response(features)).await;
            }
            SlcRequest::GetSubscriberNumberInformation { response } => {
                let result = if let Some(handler) = &mut self.handler {
                    handler.subscriber_number_information().await.ok().unwrap_or_else(Vec::new)
                } else {
                    vec![]
                };
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::GetAgIndicatorStatus { response } => {
                let call_ind = self.calls.indicators();
                let status = AgIndicators {
                    service: self.network.service_available.unwrap_or(false),
                    call: call_ind.call,
                    callsetup: call_ind.callsetup,
                    callheld: call_ind.callheld,
                    signal: self.network.signal_strength.map(|ss| ss as u8).unwrap_or(0),
                    roam: self.network.roaming.unwrap_or(false),
                    battchg: self.battery_level,
                };
                // Update the procedure with the retrieved AG update.
                self.connection.receive_ag_request(marker, response(status)).await;
            }
            SlcRequest::GetNetworkOperatorName { response } => {
                let format = self.connection.network_operator_name_format();
                let name = match &self.handler {
                    Some(h) => {
                        let result = h.query_operator().await;
                        if let Err(err) = &result {
                            warn!(
                                "Got error attempting to retrieve operator name from AG: {:}",
                                err
                            );
                        };
                        result.ok().flatten()
                    }
                    None => None,
                };
                let name_option = match (name, format) {
                    (Some(n), Some(_)) => Some(n),
                    _ => None, // The format must be set before getting the network name.
                };
                // Update the procedure with the result of retrieving the AG network name.
                self.connection.receive_ag_request(marker, response(name_option)).await;
            }
            SlcRequest::SendDtmf { code, response } => {
                self.calls.send_dtmf_code(code).await;
                self.connection.receive_ag_request(marker, response()).await;
            }
            SlcRequest::SendHfIndicator { indicator, response } => {
                self.hf_indicator_update(indicator);
                self.connection.receive_ag_request(marker, response()).await;
            }
            SlcRequest::SetNrec { enable, response } => {
                let result = if let Some(handler) = &mut self.handler {
                    if let Ok(Ok(())) = handler.set_nrec_mode(enable).await {
                        Ok(())
                    } else {
                        Err(())
                    }
                } else {
                    Err(())
                };
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::SpeakerVolumeSynchronization { level, response } => {
                self.gain_control.report_speaker_gain(level);
                self.connection.receive_ag_request(marker, response()).await;
            }
            SlcRequest::MicrophoneVolumeSynchronization { level, response } => {
                self.gain_control.report_microphone_gain(level);
                self.connection.receive_ag_request(marker, response()).await;
            }
            SlcRequest::QueryCurrentCalls { response } => {
                let result = self.calls.current_calls();
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::Answer { response } => {
                let result = self.calls.answer().map_err(|e| {
                    warn!("Unexpected Answer from Hands Free: {}", e);
                });
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::HangUp { response } => {
                let result = self.calls.hang_up().map_err(|e| {
                    warn!("Unexpected Hang Up from Hands Free: {}", e);
                });
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::Hold { command, response } => {
                let result = self.calls.hold(command).map_err(|e| {
                    warn!("Unexpected Action {:?} from Hands Free: {}", command, e);
                });
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::InitiateCall { call_action, response } => {
                let result = match &self.handler {
                    Some(h) => match h.request_outgoing_call(&mut call_action.into()).await {
                        Ok(Ok(())) => Ok(()),
                        err => {
                            warn!("Error initiating outgoing call by number: {:?}", err);
                            Err(())
                        }
                    },
                    None => Err(()),
                };
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::SynchronousConnectionSetup { selected, response } => {
                // TODO(fxbug.dev/72681): Because we must send an OK response to the just before
                // setting up the synchronous connection, we send it here by routing through the
                // procedure.
                if selected.is_some() {
                    self.connection.receive_ag_request(marker, AgUpdate::Ok).await;
                }
                let result = self
                    .setup_audio_connection(selected)
                    .await
                    .map_err(|e| warn!("Error setting up audio connection: {:?}", e));
                self.connection.receive_ag_request(marker, response(result)).await;
            }
        };
    }
/// Processes a `request` for information from an HFP procedure.
Processes a `request` for information from an HFP procedure.
Processes a ` request ` for information from an HFP procedure .
async fn procedure_request(&mut self, request: SlcRequest) {
        let marker = (&request).into();
        match request {
            SlcRequest::GetAgFeatures { response } => {
                let features = (&self._local_config).into();
                // Update the procedure with the retrieved AG update.
                self.connection.receive_ag_request(marker, response(features)).await;
            }
            SlcRequest::GetSubscriberNumberInformation { response } => {
                let result = if let Some(handler) = &mut self.handler {
                    handler.subscriber_number_information().await.ok().unwrap_or_else(Vec::new)
                } else {
                    vec![]
                };
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::GetAgIndicatorStatus { response } => {
                let call_ind = self.calls.indicators();
                let status = AgIndicators {
                    service: self.network.service_available.unwrap_or(false),
                    call: call_ind.call,
                    callsetup: call_ind.callsetup,
                    callheld: call_ind.callheld,
                    signal: self.network.signal_strength.map(|ss| ss as u8).unwrap_or(0),
                    roam: self.network.roaming.unwrap_or(false),
                    battchg: self.battery_level,
                };
                // Update the procedure with the retrieved AG update.
                self.connection.receive_ag_request(marker, response(status)).await;
            }
            SlcRequest::GetNetworkOperatorName { response } => {
                let format = self.connection.network_operator_name_format();
                let name = match &self.handler {
                    Some(h) => {
                        let result = h.query_operator().await;
                        if let Err(err) = &result {
                            warn!(
                                "Got error attempting to retrieve operator name from AG: {:}",
                                err
                            );
                        };
                        result.ok().flatten()
                    }
                    None => None,
                };
                let name_option = match (name, format) {
                    (Some(n), Some(_)) => Some(n),
                    _ => None, // The format must be set before getting the network name.
                };
                // Update the procedure with the result of retrieving the AG network name.
                self.connection.receive_ag_request(marker, response(name_option)).await;
            }
            SlcRequest::SendDtmf { code, response } => {
                self.calls.send_dtmf_code(code).await;
                self.connection.receive_ag_request(marker, response()).await;
            }
            SlcRequest::SendHfIndicator { indicator, response } => {
                self.hf_indicator_update(indicator);
                self.connection.receive_ag_request(marker, response()).await;
            }
            SlcRequest::SetNrec { enable, response } => {
                let result = if let Some(handler) = &mut self.handler {
                    if let Ok(Ok(())) = handler.set_nrec_mode(enable).await {
                        Ok(())
                    } else {
                        Err(())
                    }
                } else {
                    Err(())
                };
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::SpeakerVolumeSynchronization { level, response } => {
                self.gain_control.report_speaker_gain(level);
                self.connection.receive_ag_request(marker, response()).await;
            }
            SlcRequest::MicrophoneVolumeSynchronization { level, response } => {
                self.gain_control.report_microphone_gain(level);
                self.connection.receive_ag_request(marker, response()).await;
            }
            SlcRequest::QueryCurrentCalls { response } => {
                let result = self.calls.current_calls();
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::Answer { response } => {
                let result = self.calls.answer().map_err(|e| {
                    warn!("Unexpected Answer from Hands Free: {}", e);
                });
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::HangUp { response } => {
                let result = self.calls.hang_up().map_err(|e| {
                    warn!("Unexpected Hang Up from Hands Free: {}", e);
                });
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::Hold { command, response } => {
                let result = self.calls.hold(command).map_err(|e| {
                    warn!("Unexpected Action {:?} from Hands Free: {}", command, e);
                });
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::InitiateCall { call_action, response } => {
                let result = match &self.handler {
                    Some(h) => match h.request_outgoing_call(&mut call_action.into()).await {
                        Ok(Ok(())) => Ok(()),
                        err => {
                            warn!("Error initiating outgoing call by number: {:?}", err);
                            Err(())
                        }
                    },
                    None => Err(()),
                };
                self.connection.receive_ag_request(marker, response(result)).await;
            }
            SlcRequest::SynchronousConnectionSetup { selected, response } => {
                // TODO(fxbug.dev/72681): Because we must send an OK response to the just before
                // setting up the synchronous connection, we send it here by routing through the
                // procedure.
                if selected.is_some() {
                    self.connection.receive_ag_request(marker, AgUpdate::Ok).await;
                }
                let result = self
                    .setup_audio_connection(selected)
                    .await
                    .map_err(|e| warn!("Error setting up audio connection: {:?}", e));
                self.connection.receive_ag_request(marker, response(result)).await;
            }
        };
    }
async fn procedure_request ( & mut self , request : SlcRequest ) { let marker = ( & request ) . into ( ) ; match request { SlcRequest :: GetAgFeatures { response } => { let features = ( & self . _local_config ) . into ( ) ; // Update the procedure with the retrieved AG update. self . connection . receive_ag_request ( marker , response ( features ) ) . await ; } SlcRequest :: GetSubscriberNumberInformation { response } => { let result = if let Some ( handler ) = & mut self . handler { handler . subscriber_number_information ( ) . await . ok ( ) . unwrap_or_else ( Vec :: new ) } else { vec ! [ ] } ; self . connection . receive_ag_request ( marker , response ( result ) ) . await ; } SlcRequest :: GetAgIndicatorStatus { response } => { let call_ind = self . calls . indicators ( ) ; let status = AgIndicators { service : self . network . service_available . unwrap_or ( false ) , call : call_ind . call , callsetup : call_ind . callsetup , callheld : call_ind . callheld , signal : self . network . signal_strength . map ( | ss | ss as u8 ) . unwrap_or ( 0 ) , roam : self . network . roaming . unwrap_or ( false ) , battchg : self . battery_level , } ; // Update the procedure with the retrieved AG update. self . connection . receive_ag_request ( marker , response ( status ) ) . await ; } SlcRequest :: GetNetworkOperatorName { response } => { let format = self . connection . network_operator_name_format ( ) ; let name = match & self . handler { Some ( h ) => { let result = h . query_operator ( ) . await ; if let Err ( err ) = & result { warn ! ( " " err ) ; } ; result . ok ( ) . flatten ( ) } None => None , } ; let name_option = match ( name , format ) { ( Some ( n ) , Some ( _ ) ) => Some ( n ) , _ => None , // The format must be set before getting the network name. } ; // Update the procedure with the result of retrieving the AG network name. self . connection . receive_ag_request ( marker , response ( name_option ) ) . await ; } SlcRequest :: SendDtmf { code , response } => { self . calls . send_dtmf_code ( code ) . await ; self . connection . receive_ag_request ( marker , response ( ) ) . await ; } SlcRequest :: SendHfIndicator { indicator , response } => { self . hf_indicator_update ( indicator ) ; self . connection . receive_ag_request ( marker , response ( ) ) . await ; } SlcRequest :: SetNrec { enable , response } => { let result = if let Some ( handler ) = & mut self . handler { if let Ok ( Ok ( ( ) ) ) = handler . set_nrec_mode ( enable ) . await { Ok ( ( ) ) } else { Err ( ( ) ) } } else { Err ( ( ) ) } ; self . connection . receive_ag_request ( marker , response ( result ) ) . await ; } SlcRequest :: SpeakerVolumeSynchronization { level , response } => { self . gain_control . report_speaker_gain ( level ) ; self . connection . receive_ag_request ( marker , response ( ) ) . await ; } SlcRequest :: MicrophoneVolumeSynchronization { level , response } => { self . gain_control . report_microphone_gain ( level ) ; self . connection . receive_ag_request ( marker , response ( ) ) . await ; } SlcRequest :: QueryCurrentCalls { response } => { let result = self . calls . current_calls ( ) ; self . connection . receive_ag_request ( marker , response ( result ) ) . await ; } SlcRequest :: Answer { response } => { let result = self . calls . answer ( ) . map_err ( | e | { warn ! ( " " e ) ; } ) ; self . connection . receive_ag_request ( marker , response ( result ) ) . await ; } SlcRequest :: HangUp { response } => { let result = self . calls . hang_up ( ) . map_err ( | e | { warn ! ( " " e ) ; } ) ; self . connection . receive_ag_request ( marker , response ( result ) ) . await ; } SlcRequest :: Hold { command , response } => { let result = self . calls . hold ( command ) . map_err ( | e | { warn ! ( " " command e ) ; } ) ; self . connection . receive_ag_request ( marker , response ( result ) ) . await ; } SlcRequest :: InitiateCall { call_action , response } => { let result = match & self . handler { Some ( h ) => match h . request_outgoing_call ( & mut call_action . into ( ) ) . await { Ok ( Ok ( ( ) ) ) => Ok ( ( ) ) , err => { warn ! ( " " err ) ; Err ( ( ) ) } } , None => Err ( ( ) ) , } ; self . connection . receive_ag_request ( marker , response ( result ) ) . await ; } SlcRequest :: SynchronousConnectionSetup { selected , response } => { // TODO(fxbug.dev/72681): Because we must send an OK response to the just before // setting up the synchronous connection, we send it here by routing through the // procedure. if selected . is_some ( ) { self . connection . receive_ag_request ( marker , AgUpdate :: Ok ) . await ; } let result = self . setup_audio_connection ( selected ) . await . map_err ( | e | warn ! ( " " e ) ) ; self . connection . receive_ag_request ( marker , response ( result ) ) . await ; } } ; }
Processes a `request` for information from an HFP procedure.
Processes a ` request ` for information from an HFP procedure .
&mut self
request
SlcRequest
&mut self
request
SlcRequest