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

Commit 4521995f authored by Michael Sun's avatar Michael Sun
Browse files

floss: avrcp: handle set active device request from AVRCP interface

Handle the much less frequent case that AVRCP was connected alone or
before A2DP profile and the set specific device to active request comes
directly from the AVRCP interface. Propagate such request to uinput
when received.

Bug: 240780817
Tag: #floss
Test: emerge-${BOARD} floss
Change-Id: Ice0807b6a01ac9bcf6f3783d63931881b47e480c
parent 34cae6f5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -270,6 +270,9 @@ impl BluetoothMedia {
                    Err(e) => warn!("{}", e),
                }
            }
            AvrcpCallbacks::AvrcpSetActiveDevice(addr) => {
                self.uinput.set_active_device(addr.to_string());
            }
        }
    }

+4 −1
Original line number Diff line number Diff line
@@ -62,7 +62,10 @@ class AvrcpMediaInterfaceImpl : public MediaInterface {
      [[maybe_unused]] bool now_playing,
      [[maybe_unused]] std::string media_id) override {}

  void SetActiveDevice([[maybe_unused]] const RawAddress& address) override {}
  void SetActiveDevice(const RawAddress& address) override {
    topshim::rust::RustRawAddress addr = rusty::CopyToRustAddress(address);
    rusty::avrcp_set_active_device(addr);
  }
};

class VolumeInterfaceImpl : public VolumeInterface {
+11 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ pub mod ffi {
        fn avrcp_device_disconnected(addr: RustRawAddress);
        fn avrcp_absolute_volume_update(volume: u8);
        fn avrcp_send_key_event(key: u8, state: u8);
        fn avrcp_set_active_device(addr: RustRawAddress);
    }
}

@@ -59,6 +60,9 @@ pub enum AvrcpCallbacks {
    /// Emitted when received a key event from a connected AVRCP device
    /// Params: Key, Value
    AvrcpSendKeyEvent(u8, u8),
    /// Emitted when received request from AVRCP interface to set a device to active
    /// Params: Device address
    AvrcpSetActiveDevice(RawAddress),
}

pub struct AvrcpCallbacksDispatcher {
@@ -93,6 +97,13 @@ cb_variant!(
    u8, u8, {}
);

cb_variant!(
    AvrcpCb,
    avrcp_set_active_device -> AvrcpCallbacks::AvrcpSetActiveDevice,
    ffi::RustRawAddress -> RawAddress, {
        let _0 = _0.into();
});

pub struct Avrcp {
    internal: cxx::UniquePtr<ffi::AvrcpIntf>,
    _is_init: bool,