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

Commit 4fb2f7ca authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

floss: Add checks to adapter command

Adapter commands should only be enabled when floss is enabled and
adapter show should check that the adapter is available before running.

Bug: 206832614
Tag: #floss
Test: btclient, adapter disable, adapter show
Change-Id: I02da1d12fe9497723b55ae286699ec0deb4b677c
parent 98cad5a2
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -238,6 +238,11 @@ impl CommandHandler {
    }

    fn cmd_adapter(&mut self, args: &Vec<String>) {
        if !self.context.lock().unwrap().manager_dbus.get_floss_enabled() {
            println!("Floss is not enabled. First run, `floss enable`");
            return;
        }

        let default_adapter = self.context.lock().unwrap().default_adapter;
        enforce_arg_len(args, 1, "adapter <enable|disable|show>", || match &args[0][0..] {
            "enable" => {
@@ -247,8 +252,8 @@ impl CommandHandler {
                self.context.lock().unwrap().manager_dbus.stop(default_adapter);
            }
            "show" => {
                if !self.context.lock().unwrap().manager_dbus.get_floss_enabled() {
                    println!("Floss is not enabled. First run, `floss enable`");
                if !self.context.lock().unwrap().adapter_ready {
                    self.adapter_not_ready();
                    return;
                }