Loading app/src/controller.manager.js +27 −36 Original line number Diff line number Diff line Loading @@ -115,7 +115,6 @@ export class Controller { WDebug.log("ControllerManager run command:", cmd); switch (cmd.type) { case Command.CMD_TYPE.download: let res = false; try { await this.deviceManager.downloadAll( (loaded, total, name) => { Loading @@ -133,7 +132,6 @@ export class Controller { `Cannot download <br/> ${e.message || e} <br/> ${proposal}`, ); } return false; case Command.CMD_TYPE.reboot: try { await this.deviceManager.reboot(cmd.mode); Loading @@ -143,24 +141,22 @@ export class Controller { return false; } return true; case Command.CMD_TYPE.connect: case Command.CMD_TYPE.connect: { const proposal = "Proposal: Check connection and that no other program is using the phone and retry."; try { const res = await this.deviceManager.connect(cmd.mode); if (res) { await this.deviceManager.connect(cmd.mode); await this.onDeviceConnected(); if (loader) { loader.style.display = "none"; } return true; } } catch (e) { throw new Error( `The device is not connected ${e.message || e} <br/> ${proposal}`, ); } throw new Error(`Cannot connect the device <br/> ${proposal}`); } case Command.CMD_TYPE.erase: return this.deviceManager.erase(cmd.partition); case Command.CMD_TYPE.flash: Loading @@ -171,12 +167,11 @@ export class Controller { this.view.onInstalling(cmd.file, done, total); }, ); case Command.CMD_TYPE.unlock: case Command.CMD_TYPE.unlock: { //check if unlocked to avoid unnecessary command let isUnlocked = false; let gotoStep = ""; if (cmd.partition) { try { if (cmd.partition.startsWith("goto_")) { gotoStep = cmd.partition.substring(5); WDebug.log("goto step", gotoStep); Loading @@ -184,7 +179,6 @@ export class Controller { } else { isUnlocked = await this.deviceManager.getUnlocked(cmd.partition); } } catch (e) {} } WDebug.log( "ControllerManager unlock: ", Loading @@ -198,8 +192,9 @@ export class Controller { } catch (e) { //on some device, check unlocked does not work but when we try the command, it throws an error with "already unlocked" if (e.bootloaderMessage?.includes("already")) { WDebug.log("device already unlocked"); } else if (e.bootloaderMessage?.includes("not allowed")) { //K1ZFP TODO WDebug.log("device unlock is not allowed"); } } } else { Loading @@ -222,12 +217,11 @@ export class Controller { } } return true; case Command.CMD_TYPE.lock: } case Command.CMD_TYPE.lock: { let isLocked = false; if (cmd.partition) { try { isLocked = !(await this.deviceManager.getUnlocked(cmd.partition)); } catch (e) {} } if (!isLocked) { try { Loading @@ -242,6 +236,7 @@ export class Controller { } } return true; } case Command.CMD_TYPE.sideload: try { await this.deviceManager.connect("recovery"); Loading @@ -264,11 +259,7 @@ export class Controller { default: WDebug.log(`try unknown command ${cmd.command}`); try { await this.deviceManager.runCommand(cmd.command); } catch (e) { // K1ZFP TODO... } return true; } } Loading Loading @@ -319,7 +310,7 @@ export class Controller { 10, ); WDebug.log("current_security_path_level", current_security_path_level); } catch (ee) { } catch { WDebug.log("Security patch Error"); current_security_path_level = null; } Loading Loading @@ -350,7 +341,7 @@ export class Controller { this.deviceManager.adb.webusb.device; throw new Error("Cannot find device resource", id); } } catch (e) { } catch { const id = "model " + this.deviceManager.adb.webusb.model + Loading @@ -363,14 +354,14 @@ export class Controller { " " + "device " + this.deviceManager.adb.webusb.device; throw new Error("Error on getting devcice resource", id); throw new Error("Error on getting device resource", id); } } if (model.includes("A015")) { try { this_model = "tetris"; } catch (e) { } catch { const id = "model " + this.deviceManager.adb.webusb.model + Loading Loading @@ -409,7 +400,7 @@ export class Controller { } } catch (e) { resources = null; WDebug.log("getRessources Error"); WDebug.log("getResources Error: " + e); throw Error("device-model-not-supported"); } Loading app/src/controller/device.manager.js +1 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ export class DeviceManager { return this.bootloader.runCommand(`erase:${partition}`); } format(argument) { format() { return true; // return this.bootloader.runCommand(`format ${argument}`); // the fastboot format md_udc is not supported evne by the official fastboot program Loading app/src/controller/device/adb.class.js +2 −7 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ export class ADB extends Device { } try { return this.device.getDevice(); } catch (e) { } catch { return false; } } Loading @@ -23,8 +23,7 @@ export class ADB extends Device { return true; } async connect(cb) { let res = false; async connect() { try { console.log("debug adb connect"); let adbWebBackend = await AdbWebBackend.requestDevice(); Loading @@ -40,14 +39,10 @@ export class ADB extends Device { WDebug.log("Name", adbDevice.name); WDebug.log(">Device (codename)", adbDevice.device); // codemane WDebug.log("----------------------------------"); res = true; } } catch (e) { this.device = null; throw new Error(`Cannot connect ADB ${e.message || e}`); } finally { return res; } } Loading app/src/controller/device/bootloader.class.js +13 −25 Original line number Diff line number Diff line Loading @@ -39,14 +39,10 @@ export class Bootloader extends Device { } async connect() { let connected = false; try { await this.device.connect(); connected = true; } catch (e) { throw new Error("Cannot connect Bootloader", `${e.message || e}`); } finally { return connected; } } Loading @@ -59,7 +55,6 @@ export class Bootloader extends Device { } async flashFactoryZip(blob, onProgress, onReconnect) { try { await this.device.flashFactoryZip( blob, false, Loading @@ -70,9 +65,6 @@ export class Bootloader extends Device { onProgress(userAction, item, progress); }, ); } catch (e) { throw e; } } async flashBlob(partition, blob, onProgress) { Loading Loading @@ -125,7 +117,7 @@ export class Bootloader extends Device { async unlock(command) { if (command) { const res = await this.device.runCommand(command); await this.device.runCommand(command); } else { throw Error("no unlock command configured"); //K1ZFP TODO } Loading @@ -133,12 +125,8 @@ export class Bootloader extends Device { async lock(command) { if (command) { try { const res = await this.device.runCommand(command); await this.device.runCommand(command); return !(await this.isUnlocked()); } catch (e) { throw e; } } else { throw Error("no lock command configured"); //K1ZFP TODO } Loading app/src/controller/device/device.class.js +5 −7 Original line number Diff line number Diff line Loading @@ -5,9 +5,7 @@ export class Device { async init() {} async connect() { return false; } async connect() {} isConnected() { return false; Loading @@ -29,11 +27,11 @@ export class Device { return false; } async flashBlob(partition, blob, onProgress) { async flashBlob() { return false; } async runCommand(cmd) { async runCommand() { return false; } Loading @@ -48,11 +46,11 @@ export class Device { return undefined; } reboot(mode) { reboot() { return undefined; } async bootBlob(blob) { async bootBlob() { return false; } } Loading
app/src/controller.manager.js +27 −36 Original line number Diff line number Diff line Loading @@ -115,7 +115,6 @@ export class Controller { WDebug.log("ControllerManager run command:", cmd); switch (cmd.type) { case Command.CMD_TYPE.download: let res = false; try { await this.deviceManager.downloadAll( (loaded, total, name) => { Loading @@ -133,7 +132,6 @@ export class Controller { `Cannot download <br/> ${e.message || e} <br/> ${proposal}`, ); } return false; case Command.CMD_TYPE.reboot: try { await this.deviceManager.reboot(cmd.mode); Loading @@ -143,24 +141,22 @@ export class Controller { return false; } return true; case Command.CMD_TYPE.connect: case Command.CMD_TYPE.connect: { const proposal = "Proposal: Check connection and that no other program is using the phone and retry."; try { const res = await this.deviceManager.connect(cmd.mode); if (res) { await this.deviceManager.connect(cmd.mode); await this.onDeviceConnected(); if (loader) { loader.style.display = "none"; } return true; } } catch (e) { throw new Error( `The device is not connected ${e.message || e} <br/> ${proposal}`, ); } throw new Error(`Cannot connect the device <br/> ${proposal}`); } case Command.CMD_TYPE.erase: return this.deviceManager.erase(cmd.partition); case Command.CMD_TYPE.flash: Loading @@ -171,12 +167,11 @@ export class Controller { this.view.onInstalling(cmd.file, done, total); }, ); case Command.CMD_TYPE.unlock: case Command.CMD_TYPE.unlock: { //check if unlocked to avoid unnecessary command let isUnlocked = false; let gotoStep = ""; if (cmd.partition) { try { if (cmd.partition.startsWith("goto_")) { gotoStep = cmd.partition.substring(5); WDebug.log("goto step", gotoStep); Loading @@ -184,7 +179,6 @@ export class Controller { } else { isUnlocked = await this.deviceManager.getUnlocked(cmd.partition); } } catch (e) {} } WDebug.log( "ControllerManager unlock: ", Loading @@ -198,8 +192,9 @@ export class Controller { } catch (e) { //on some device, check unlocked does not work but when we try the command, it throws an error with "already unlocked" if (e.bootloaderMessage?.includes("already")) { WDebug.log("device already unlocked"); } else if (e.bootloaderMessage?.includes("not allowed")) { //K1ZFP TODO WDebug.log("device unlock is not allowed"); } } } else { Loading @@ -222,12 +217,11 @@ export class Controller { } } return true; case Command.CMD_TYPE.lock: } case Command.CMD_TYPE.lock: { let isLocked = false; if (cmd.partition) { try { isLocked = !(await this.deviceManager.getUnlocked(cmd.partition)); } catch (e) {} } if (!isLocked) { try { Loading @@ -242,6 +236,7 @@ export class Controller { } } return true; } case Command.CMD_TYPE.sideload: try { await this.deviceManager.connect("recovery"); Loading @@ -264,11 +259,7 @@ export class Controller { default: WDebug.log(`try unknown command ${cmd.command}`); try { await this.deviceManager.runCommand(cmd.command); } catch (e) { // K1ZFP TODO... } return true; } } Loading Loading @@ -319,7 +310,7 @@ export class Controller { 10, ); WDebug.log("current_security_path_level", current_security_path_level); } catch (ee) { } catch { WDebug.log("Security patch Error"); current_security_path_level = null; } Loading Loading @@ -350,7 +341,7 @@ export class Controller { this.deviceManager.adb.webusb.device; throw new Error("Cannot find device resource", id); } } catch (e) { } catch { const id = "model " + this.deviceManager.adb.webusb.model + Loading @@ -363,14 +354,14 @@ export class Controller { " " + "device " + this.deviceManager.adb.webusb.device; throw new Error("Error on getting devcice resource", id); throw new Error("Error on getting device resource", id); } } if (model.includes("A015")) { try { this_model = "tetris"; } catch (e) { } catch { const id = "model " + this.deviceManager.adb.webusb.model + Loading Loading @@ -409,7 +400,7 @@ export class Controller { } } catch (e) { resources = null; WDebug.log("getRessources Error"); WDebug.log("getResources Error: " + e); throw Error("device-model-not-supported"); } Loading
app/src/controller/device.manager.js +1 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ export class DeviceManager { return this.bootloader.runCommand(`erase:${partition}`); } format(argument) { format() { return true; // return this.bootloader.runCommand(`format ${argument}`); // the fastboot format md_udc is not supported evne by the official fastboot program Loading
app/src/controller/device/adb.class.js +2 −7 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ export class ADB extends Device { } try { return this.device.getDevice(); } catch (e) { } catch { return false; } } Loading @@ -23,8 +23,7 @@ export class ADB extends Device { return true; } async connect(cb) { let res = false; async connect() { try { console.log("debug adb connect"); let adbWebBackend = await AdbWebBackend.requestDevice(); Loading @@ -40,14 +39,10 @@ export class ADB extends Device { WDebug.log("Name", adbDevice.name); WDebug.log(">Device (codename)", adbDevice.device); // codemane WDebug.log("----------------------------------"); res = true; } } catch (e) { this.device = null; throw new Error(`Cannot connect ADB ${e.message || e}`); } finally { return res; } } Loading
app/src/controller/device/bootloader.class.js +13 −25 Original line number Diff line number Diff line Loading @@ -39,14 +39,10 @@ export class Bootloader extends Device { } async connect() { let connected = false; try { await this.device.connect(); connected = true; } catch (e) { throw new Error("Cannot connect Bootloader", `${e.message || e}`); } finally { return connected; } } Loading @@ -59,7 +55,6 @@ export class Bootloader extends Device { } async flashFactoryZip(blob, onProgress, onReconnect) { try { await this.device.flashFactoryZip( blob, false, Loading @@ -70,9 +65,6 @@ export class Bootloader extends Device { onProgress(userAction, item, progress); }, ); } catch (e) { throw e; } } async flashBlob(partition, blob, onProgress) { Loading Loading @@ -125,7 +117,7 @@ export class Bootloader extends Device { async unlock(command) { if (command) { const res = await this.device.runCommand(command); await this.device.runCommand(command); } else { throw Error("no unlock command configured"); //K1ZFP TODO } Loading @@ -133,12 +125,8 @@ export class Bootloader extends Device { async lock(command) { if (command) { try { const res = await this.device.runCommand(command); await this.device.runCommand(command); return !(await this.isUnlocked()); } catch (e) { throw e; } } else { throw Error("no lock command configured"); //K1ZFP TODO } Loading
app/src/controller/device/device.class.js +5 −7 Original line number Diff line number Diff line Loading @@ -5,9 +5,7 @@ export class Device { async init() {} async connect() { return false; } async connect() {} isConnected() { return false; Loading @@ -29,11 +27,11 @@ export class Device { return false; } async flashBlob(partition, blob, onProgress) { async flashBlob() { return false; } async runCommand(cmd) { async runCommand() { return false; } Loading @@ -48,11 +46,11 @@ export class Device { return undefined; } reboot(mode) { reboot() { return undefined; } async bootBlob(blob) { async bootBlob() { return false; } }