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

Commit 0f8bb33e authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

floss: telephony: Add alert state to dialing

Some qualification tests require an alerting state after dialing.

Bug: 274555061
Tag: #floss
Test: manual

Change-Id: Ief35e4fee1e5d896b426f6452b339584fef85206
parent 987aebf8
Loading
Loading
Loading
Loading
+37 −11
Original line number Diff line number Diff line
@@ -794,12 +794,15 @@ impl BluetoothMedia {
                // Respond OK/ERROR to the HF which sent the command.
                // This should be called before calling phone_state_change.
                self.simple_at_response(success, addr.clone());
                if success {
                    // Success means the call state has changed. Inform the LibBluetooth stack.
                    self.phone_state_change("".into());
                } else {
                if !success {
                    warn!("[{}]: Unexpected dialing command from HF", DisplayAddress(&addr));
                    return;
                }
                // Inform libbluetooth that the state has changed to dialing.
                self.phone_state_change("".into());
                // Change to alerting state and inform libbluetooth.
                self.dialing_to_alerting();
                self.phone_state_change("".into());
            }
            HfpCallbacks::CallHold(command, addr) => {
                let success = match command {
@@ -814,7 +817,7 @@ impl BluetoothMedia {
                // This should be called before calling phone_state_change.
                self.simple_at_response(success, addr.clone());
                if success {
                    // Success means the call state has changed. Inform the LibBluetooth stack.
                    // Success means the call state has changed. Inform libbluetooth.
                    self.phone_state_change("".into());
                } else {
                    warn!(
@@ -1301,10 +1304,13 @@ impl BluetoothMedia {
        }
        // There must be exactly one incoming/dialing call in the list.
        for c in self.call_list.iter_mut() {
            if c.state == CallState::Incoming || c.state == CallState::Dialing {
            match c.state {
                CallState::Incoming | CallState::Dialing | CallState::Alerting => {
                    c.state = CallState::Active;
                    break;
                }
                _ => {}
            }
        }
        self.phone_state.state = CallState::Idle;
        self.phone_state.num_active += 1;
@@ -1319,16 +1325,19 @@ impl BluetoothMedia {
            CallState::Idle if self.phone_state.num_active > 0 => {
                self.phone_state.num_active -= 1;
            }
            CallState::Incoming | CallState::Dialing => {
            CallState::Incoming | CallState::Dialing | CallState::Alerting => {
                self.phone_state.state = CallState::Idle;
            }
            _ => {
                return false;
            }
        }
        // At this point, there must be exactly one incoming/dialing/active call to be removed.
        // At this point, there must be exactly one incoming/dialing/alerting/active call to be
        // removed.
        self.call_list.retain(|x| match x.state {
            CallState::Active | CallState::Incoming | CallState::Dialing => false,
            CallState::Active | CallState::Incoming | CallState::Dialing | CallState::Alerting => {
                false
            }
            _ => true,
        });
        true
@@ -1351,6 +1360,20 @@ impl BluetoothMedia {
        true
    }

    fn dialing_to_alerting(&mut self) -> bool {
        if !self.phone_ops_enabled || self.phone_state.state != CallState::Dialing {
            return false;
        }
        for c in self.call_list.iter_mut() {
            if c.state == CallState::Dialing {
                c.state = CallState::Alerting;
                break;
            }
        }
        self.phone_state.state = CallState::Alerting;
        true
    }

    fn release_held_impl(&mut self) -> bool {
        if !self.phone_ops_enabled || self.phone_state.state != CallState::Idle {
            return false;
@@ -2112,6 +2135,9 @@ impl IBluetoothTelephony for BluetoothMedia {
            return false;
        }
        self.phone_state_change("".into());
        // Change to alerting state and inform libbluetooth.
        self.dialing_to_alerting();
        self.phone_state_change("".into());
        true
    }

+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ static headset::bthf_call_state_t from_rust_call_state(rusty::CallState state) {
      return headset::BTHF_CALL_STATE_INCOMING;
    case rusty::CallState::Dialing:
      return headset::BTHF_CALL_STATE_DIALING;
    case rusty::CallState::Alerting:
      return headset::BTHF_CALL_STATE_ALERTING;
    case rusty::CallState::Active:
      return headset::BTHF_CALL_STATE_ACTIVE;
    case rusty::CallState::Held:
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ pub mod ffi {
        Idle,
        Incoming,
        Dialing,
        Alerting,
        Active, // Only used by CLCC response
        Held,   // Only used by CLCC response
    }