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

Commit 21f3c380 authored by Whale Chang's avatar Whale Chang Committed by Automerger Merge Worker
Browse files

Merge "Floss: Prevent phone state desync with AG when answering/hanging up by...

Merge "Floss: Prevent phone state desync with AG when answering/hanging up by HF." into main am: dfbf5260 am: 15969c25

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/3058085



Change-Id: If79244f9cb14cc225fdf6eadcc9e56a8266d3755
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c30458fb 15969c25
Loading
Loading
Loading
Loading
+28 −6
Original line number Original line Diff line number Diff line
@@ -849,12 +849,14 @@ impl BluetoothMedia {


                if let Some(uhid) = self.uhid.get_mut(&addr) {
                if let Some(uhid) = self.uhid.get_mut(&addr) {
                    if volume == 0 && !uhid.muted {
                    if volume == 0 && !uhid.muted {
                        uhid.muted = true;
                        // We expect the application to send back UHID output report and
                        // update uhid.mute in dispatch_uhid_hfp_output_callback later.
                        self.uhid_send_phone_mute_input_report(&addr, true);
                        self.uhid_send_phone_mute_input_report(&addr, true);
                    } else if volume > 0 {
                    } else if volume > 0 {
                        uhid.volume = volume;
                        uhid.volume = volume;
                        if uhid.muted {
                        if uhid.muted {
                            uhid.muted = false;
                            // We expect the application to send back UHID output report and
                            // update uhid.mute in dispatch_uhid_hfp_output_callback later.
                            self.uhid_send_phone_mute_input_report(&addr, false);
                            self.uhid_send_phone_mute_input_report(&addr, false);
                        }
                        }
                    }
                    }
@@ -1005,9 +1007,19 @@ impl BluetoothMedia {
                    warn!("Unexpected answer call. phone_ops_enabled and mps_qualification_enabled does not enabled.");
                    warn!("Unexpected answer call. phone_ops_enabled and mps_qualification_enabled does not enabled.");
                    return;
                    return;
                }
                }
                self.answer_call_impl();
                if self.mps_qualification_enabled {
                    // In qualification mode we expect no application to interact with.
                    // So we just jump right in to the telephony ops implementation.
                    let id = BLUETOOTH_TELEPHONY_UHID_REPORT_ID;
                    let mut data = UHID_OUTPUT_NONE;
                    data |= UHID_OUTPUT_OFF_HOOK;
                    self.dispatch_uhid_hfp_output_callback(addr.to_string(), id, data);
                } else {
                    // We expect the application to send back UHID output report and
                    // trigger dispatch_uhid_hfp_output_callback later.
                    self.uhid_send_hook_switch_input_report(&addr, true);
                    self.uhid_send_hook_switch_input_report(&addr, true);
                }
                }
            }
            HfpCallbacks::HangupCall(addr) => {
            HfpCallbacks::HangupCall(addr) => {
                if !self.phone_ops_enabled && !self.mps_qualification_enabled {
                if !self.phone_ops_enabled && !self.mps_qualification_enabled {
                    warn!("Unexpected hangup call. phone_ops_enabled and mps_qualification_enabled does not enabled.");
                    warn!("Unexpected hangup call. phone_ops_enabled and mps_qualification_enabled does not enabled.");
@@ -1022,9 +1034,19 @@ impl BluetoothMedia {
                    );
                    );
                    return;
                    return;
                }
                }
                self.hangup_call_impl();
                if self.mps_qualification_enabled {
                    // In qualification mode we expect no application to interact with.
                    // So we just jump right in to the telephony ops implementation.
                    let id = BLUETOOTH_TELEPHONY_UHID_REPORT_ID;
                    let mut data = UHID_OUTPUT_NONE;
                    data &= !UHID_OUTPUT_OFF_HOOK;
                    self.dispatch_uhid_hfp_output_callback(addr.to_string(), id, data);
                } else {
                    // We expect the application to send back UHID output report and
                    // trigger dispatch_uhid_hfp_output_callback later.
                    self.uhid_send_hook_switch_input_report(&addr, false);
                    self.uhid_send_hook_switch_input_report(&addr, false);
                }
                }
            }
            HfpCallbacks::DialCall(number, addr) => {
            HfpCallbacks::DialCall(number, addr) => {
                if !self.mps_qualification_enabled {
                if !self.mps_qualification_enabled {
                    warn!("Unexpected dail call. mps_qualification_enabled does not enabled.");
                    warn!("Unexpected dail call. mps_qualification_enabled does not enabled.");