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

Commit 10a4800c authored by Jeremy Wu's avatar Jeremy Wu
Browse files

floss: signal audio disconnection on device removal

When a start request is placed but the device is removed before it
completes, we need to reply to the audio server that the request failed,
so that it will not continue polling the state.

Bug: 333985418
Flag: EXEMPT floss-only
Test: m Bluetooth
Change-Id: I06e9940fec7a544b82fb0ccd1d4f09ae7dd744db
parent 0009eb31
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1254,6 +1254,12 @@ impl BluetoothMedia {
                    BtavConnectionState::Disconnected => {
                        info!("[{}]: a2dp disconnected.", DisplayAddress(&addr));

                        if self.a2dp_audio_connection_listener.is_some() {
                            let listener = self.a2dp_audio_connection_listener.take().unwrap();
                            let data: Vec<u8> = vec![0];
                            self.write_data_to_listener(listener, data);
                        }

                        self.a2dp_states.remove(&addr);
                        self.a2dp_caps.remove(&addr);
                        self.a2dp_audio_state.remove(&addr);
@@ -1484,6 +1490,13 @@ impl BluetoothMedia {
                    }
                    BthfConnectionState::Disconnected => {
                        info!("[{}]: hfp disconnected.", DisplayAddress(&addr));

                        if self.hfp_audio_connection_listener.is_some() {
                            let listener = self.hfp_audio_connection_listener.take().unwrap();
                            let data: Vec<u8> = vec![0];
                            self.write_data_to_listener(listener, data);
                        }

                        self.uhid_destroy(&addr);
                        self.hfp_states.remove(&addr);
                        self.hfp_cap.remove(&addr);