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

Commit 7147235e authored by En-Shuo Hsu's avatar En-Shuo Hsu
Browse files

floss: Align the SetVolume signature

BUG: 194853979
Tag: #floss
Test: build, deploy, connect and test by sending DBus message
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 char lines

Change-Id: Ifd8139e514eedd9abf5f2bd00930046aafdaf1ea
parent 80b4d5b4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
    }

    #[dbus_method("SetVolume")]
    fn set_volume(&mut self, volume: i32) {
    fn set_volume(&mut self, volume: u8) {
        dbus_generated!()
    }

+8 −4
Original line number Diff line number Diff line
@@ -48,7 +48,10 @@ pub trait IBluetoothMedia {
        bits_per_sample: i32,
        channel_mode: i32,
    ) -> bool;
    fn set_volume(&mut self, volume: i32);

    // Set the A2DP/AVRCP volume. Valid volume specified by the spec should be
    // in the range of 0-127.
    fn set_volume(&mut self, volume: u8);

    // Set the HFP speaker volume. Valid volume specified by the HFP spec should
    // be in the range of 0-15.
@@ -531,11 +534,12 @@ impl IBluetoothMedia for BluetoothMedia {
        true
    }

    fn set_volume(&mut self, volume: i32) {
    fn set_volume(&mut self, volume: u8) {
        // Guard the range 0-127 by the try_from cast from u8 to i8.
        match i8::try_from(volume) {
            Ok(val) => self.avrcp.as_mut().unwrap().set_volume(val),
            _ => (),
        };
            _ => warn!("Ignore invalid volume {}", volume),
        }
    }

    fn set_hfp_volume(&mut self, volume: u8, address: String) {