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

Commit 3d679ab6 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Abhishek Pandit-Subedi
Browse files

floss: Add bond remove and cancel to btclient

Refactors the bond command to take "add|remove|cancel" and wires the
command to take any of those actions by calling the correct dbus
methods.

Bug: 196887009
Tag: #floss
Test: btclient on ChromeOS
Change-Id: Icfee9edba495f0e13791414485cf124d6b2d952a
parent 923593ad
Loading
Loading
Loading
Loading
+40 −13
Original line number Diff line number Diff line
@@ -328,9 +328,10 @@ impl CommandHandler {
            return;
        }

        enforce_arg_len(args, 1, "bond <address>", || {
        enforce_arg_len(args, 2, "bond <add|remove|cancel> <address>", || match &args[0][0..] {
            "add" => {
                let device = BluetoothDevice {
                address: String::from(&args[0]),
                    address: String::from(&args[1]),
                    name: String::from("Classic Device"),
                };

@@ -341,6 +342,32 @@ impl CommandHandler {
                    .as_ref()
                    .unwrap()
                    .create_bond(device, BluetoothTransport::from_i32(0).unwrap());
            }
            "remove" => {
                let device = BluetoothDevice {
                    address: String::from(&args[1]),
                    name: String::from("Classic Device"),
                };

                self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().remove_bond(device);
            }
            "cancel" => {
                let device = BluetoothDevice {
                    address: String::from(&args[1]),
                    name: String::from("Classic Device"),
                };

                self.context
                    .lock()
                    .unwrap()
                    .adapter_dbus
                    .as_ref()
                    .unwrap()
                    .cancel_bond_process(device);
            }
            _ => {
                println!("Invalid argument '{}'", args[0]);
            }
        });
    }