From 2274045374e3df529b91db0c1e051f42f17837be Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Tue, 5 Nov 2019 23:35:14 +0100 Subject: [PATCH 1/2] Timeout wait steps --- package-lock.json | 6 +++--- package.json | 2 +- src/devices.js | 41 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 657182c3..947f88ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5200,9 +5200,9 @@ } }, "promise-android-tools": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/promise-android-tools/-/promise-android-tools-1.0.9.tgz", - "integrity": "sha512-p+6UnTrsXzRhJ0QclJvrCuqQIyO+FRTUQcnIVnEztpFAfrGcU4MMAlp1uicKJANJSsYty2JjdU8jVlpjN7CNbQ==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/promise-android-tools/-/promise-android-tools-1.0.10.tgz", + "integrity": "sha512-NOH6or5YmteFo66K6DSiQL0As2OlTLAPVDNa4RmJOjnV4KWBVu8Jw9n9pc7+i2ZjQ9+F/nMW+e6W58EMetqTKw==", "requires": { "chai": "^4.1.2", "chai-as-promised": "^7.1.1", diff --git a/package.json b/package.json index 43fd962e..b4b02406 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "jquery-i18next": "^1.2.0", "mkdirp": "^0.5.1", "popper.js": "^1.16.0", - "promise-android-tools": "^1.0.9", + "promise-android-tools": "^1.0.10", "ps-tree": "^1.2.0", "request": "^2.79.0", "system-image-node-module": "^1.0.10", diff --git a/src/devices.js b/src/devices.js index a0a5062f..f169dc2e 100644 --- a/src/devices.js +++ b/src/devices.js @@ -239,7 +239,46 @@ function installStep(step) { global.mainEvent.emit( "user:action", global.installConfig.user_actions[step.action], - resolve + () => { + switch (step.action) { + case "recovery": + case "system": + global.mainEvent.emit("user:write:working", "particles"); + global.mainEvent.emit( + "user:write:status", + "Waiting for device", + true + ); + global.mainEvent.emit( + "user:write:under", + "Adb is scanning for devices" + ); + adb + .waitForDevice() + .then(resolve) + .catch(() => mainEvent.emit("user:connection-lost", resolve)); + break; + case "bootloader": + global.mainEvent.emit("user:write:working", "particles"); + global.mainEvent.emit( + "user:write:status", + "Waiting for device", + true + ); + global.mainEvent.emit( + "user:write:under", + "Fastboot is scanning for devices" + ); + fastboot + .waitForDevice() + .then(resolve) + .catch(() => mainEvent.emit("user:connection-lost", resolve)); + break; + default: + resolve(); + break; + } + } ); }); default: From d416a31425346bffba7259176521ac909575d3c0 Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Wed, 6 Nov 2019 15:20:26 +0100 Subject: [PATCH 2/2] Allow multiple connection retries after user actions --- src/devices.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/devices.js b/src/devices.js index f169dc2e..cc228b2b 100644 --- a/src/devices.js +++ b/src/devices.js @@ -253,11 +253,14 @@ function installStep(step) { "user:write:under", "Adb is scanning for devices" ); - adb - .waitForDevice() - .then(resolve) - .catch(() => mainEvent.emit("user:connection-lost", resolve)); - break; + function adbWait() { + return adb + .waitForDevice() + .catch(() => + mainEvent.emit("user:connection-lost", adbWait) + ); + } + return adbWait(); case "bootloader": global.mainEvent.emit("user:write:working", "particles"); global.mainEvent.emit( @@ -269,11 +272,14 @@ function installStep(step) { "user:write:under", "Fastboot is scanning for devices" ); - fastboot - .waitForDevice() - .then(resolve) - .catch(() => mainEvent.emit("user:connection-lost", resolve)); - break; + function fastbootWait() { + return fastboot + .waitForDevice() + .catch(() => + mainEvent.emit("user:connection-lost", fastbootWait) + ); + } + return fastbootWait(); default: resolve(); break;