async fn new_call(&self, remote: &str, fidl_state: FidlCallState) -> Result<CallId, Error> {
        let mut inner = self.inner.lock().await;
        let call_id = inner.next_call_id;
        inner.next_call_id += 1;
        let mut state = CallState {
            remote: remote.into(),
            peer_id: None,
            responder: None,
            state: fidl_state,
            reported_state: None,
            dtmf_codes: vec![],
        };

        if let Some(peer_id) = inner.active_peer.clone() {
            let peer = inner.peers.get_mut(&peer_id).expect("Active peer must exist in peers map");

            let (client_end, stream) = fidl::endpoints::create_request_stream::<CallMarker>()
                .map_err(|e| format_err!("Error creating fidl endpoints: {}", e))?;
            // This does not handle the case where there is no peer responder
            let responder = peer
                .call_responder
                .take()
                .ok_or_else(|| format_err!("No peer call responder for {:?}", peer_id))?;
            if let Ok(()) = responder.send(client_end, remote, fidl_state) {
                let task = fasync::Task::local(self.clone().manage_call(peer_id, call_id, stream));
                peer.call_tasks.insert(call_id, task);
                state.peer_id = Some(peer_id);
            }
        } else {
            inner.unreported_calls.push_back(call_id);
        }

        inner.calls.insert(call_id, state);
        Ok(call_id)
    }
/// Notify HFP of an ongoing call. Simulates a new call from the network in the
/// "incoming ringing" state.
///
/// Arguments:
///     `remote`: The number associated with the remote party. This can be any string formatted
///     number (e.g. +1-555-555-5555).
///     `fidl_state`: The state to assign to the newly created call.
Notify HFP of an ongoing call. Simulates a new call from the network in the
"incoming ringing" state.

`remote`: The number associated with the remote party. This can be any string formatted
number .
`fidl_state`: The state to assign to the newly created call.
Notify HFP of an ongoing call . Simulates a new call from the network in the " incoming ringing " state . ` remote ` : The number associated with the remote party . This can be any string formatted number . ` fidl_state ` : The state to assign to the newly created call .
async fn new_call(&self, remote: &str, fidl_state: FidlCallState) -> Result<CallId, Error> {
        let mut inner = self.inner.lock().await;
        let call_id = inner.next_call_id;
        inner.next_call_id += 1;
        let mut state = CallState {
            remote: remote.into(),
            peer_id: None,
            responder: None,
            state: fidl_state,
            reported_state: None,
            dtmf_codes: vec![],
        };
        if let Some(peer_id) = inner.active_peer.clone() {
            let peer = inner.peers.get_mut(&peer_id).expect("Active peer must exist in peers map");
            let (client_end, stream) = fidl::endpoints::create_request_stream::<CallMarker>()
                .map_err(|e| format_err!("Error creating fidl endpoints: {}", e))?;
            // This does not handle the case where there is no peer responder
            let responder = peer
                .call_responder
                .take()
                .ok_or_else(|| format_err!("No peer call responder for {:?}", peer_id))?;
            if let Ok(()) = responder.send(client_end, remote, fidl_state) {
                let task = fasync::Task::local(self.clone().manage_call(peer_id, call_id, stream));
                peer.call_tasks.insert(call_id, task);
                state.peer_id = Some(peer_id);
            }
        } else {
            inner.unreported_calls.push_back(call_id);
        }
        inner.calls.insert(call_id, state);
        Ok(call_id)
    }
async fn new_call ( & self , remote : & str , fidl_state : FidlCallState ) -> Result < CallId , Error > { let mut inner = self . inner . lock ( ) . await ; let call_id = inner . next_call_id ; inner . next_call_id += 1 ; let mut state = CallState { remote : remote . into ( ) , peer_id : None , responder : None , state : fidl_state , reported_state : None , dtmf_codes : vec ! [ ] , } ; if let Some ( peer_id ) = inner . active_peer . clone ( ) { let peer = inner . peers . get_mut ( & peer_id ) . expect ( " " ) ; let ( client_end , stream ) = fidl :: endpoints :: create_request_stream :: < CallMarker > ( ) . map_err ( | e | format_err ! ( " " e ) ) ? ; // This does not handle the case where there is no peer responder let responder = peer . call_responder . take ( ) . ok_or_else ( | | format_err ! ( " " peer_id ) ) ? ; if let Ok ( ( ) ) = responder . send ( client_end , remote , fidl_state ) { let task = fasync :: Task :: local ( self . clone ( ) . manage_call ( peer_id , call_id , stream ) ) ; peer . call_tasks . insert ( call_id , task ) ; state . peer_id = Some ( peer_id ) ; } } else { inner . unreported_calls . push_back ( call_id ) ; } inner . calls . insert ( call_id , state ) ; Ok ( call_id ) }
Notify HFP of an ongoing call.
Notify HFP of an ongoing call .
&self
remote
&str
fidl_state
FidlCallState
&self
remote
&str
fidl_state
FidlCallState