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

Commit d6e70fca authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor Committed by Jackeagle
Browse files

Fix isConnected to be sync and return boolean

isConnected() in ADB and Recovery classes was marked async but never
awaited anything, and returned the device object directly instead of
a boolean. This caused two issues:

1. Unnecessary async overhead for a synchronous check
2. Return type inconsistency - callers expect boolean, got object

Remove async keyword to match base Device class and Bootloader
implementation. Use double-negation (!!) to coerce getDevice() result
to boolean explicitly.
parent de1d37e3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -13,12 +13,12 @@ export class ADB extends Device {
    this.webusb = null;
  }

  async isConnected() {
  isConnected() {
    if (!this.device) {
      return false;
    }
    try {
      return this.device.getDevice();
      return !!this.device.getDevice();
    } catch {
      return false;
    }
+2 −2
Original line number Diff line number Diff line
@@ -12,12 +12,12 @@ export class Recovery extends Device {
    this.adbDaemonWebUsbDevice = null;
  }

  async isConnected() {
  isConnected() {
    if (!this.device) {
      return false;
    }
    try {
      return this.device.getDevice();
      return !!this.device.getDevice();
    } catch {
      return false;
    }