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

Commit 9ee8e76d authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor
Browse files

Fix null reference in `getProductName` and `getSerialNumber`

getProductName() and getSerialNumber() access this.webusb which is
declared in the constructor but never assigned during connect(). This
causes TypeError when these methods are called.

The connect() method stores the USB device in this.adbDaemonWebUsbDevice,
not this.webusb. Fix the getters to use the correct property and access
the standard WebUSB device attributes (productName, serialNumber).

Also remove unused webusb and adbWebBackend properties from constructor,
and initialize adbDaemonWebUsbDevice to null for clarity.
parent 8786b35d
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -8,9 +8,8 @@ import { ADB } from "./adb.class.js";
export class Recovery extends Device {
  constructor(device) {
    super(device);
    this.webusb = null;
    this.count = 0;
    this.adbWebBackend = null;
    this.adbDaemonWebUsbDevice = null;
  }

  async isConnected() {
@@ -211,11 +210,11 @@ export class Recovery extends Device {
  }

  getProductName() {
    return this.webusb.name;
    return this.adbDaemonWebUsbDevice?.productName;
  }

  getSerialNumber() {
    return this.webusb.product;
    return this.adbDaemonWebUsbDevice?.serialNumber;
  }

  async adbOpen(blob) {