From c3d873a6844d40e1b63c00a5ca0c27bc2a9311a8 Mon Sep 17 00:00:00 2001 From: solvd Date: Wed, 22 Nov 2023 22:14:24 -0300 Subject: [PATCH 1/6] Lock screen until swipe is finished --- lib/units/ios-device/plugins/wda/WdaClient.js | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/units/ios-device/plugins/wda/WdaClient.js b/lib/units/ios-device/plugins/wda/WdaClient.js index b59c77fa..045a8431 100644 --- a/lib/units/ios-device/plugins/wda/WdaClient.js +++ b/lib/units/ios-device/plugins/wda/WdaClient.js @@ -25,12 +25,12 @@ module.exports = syrup.serial() deviceSize: null, orientation: null, touchDownParams: {}, - isMove: false, tapStartAt: 0, typeKeyActions: [], typeKeyTimerId: null, typeKeyDelay: 250, upperCase: false, + isSwiping: false, startSession: function() { log.info('verifying wda session status...') @@ -249,7 +249,6 @@ module.exports = syrup.serial() tap: function(params) { this.tapStartAt = (new Date()).getTime() this.touchDownParams = params - this.isMove = false }, homeBtn: function() { if (options.deviceType !== 'tvOS') { @@ -289,21 +288,29 @@ module.exports = syrup.serial() ], } - this.isMove = true - if (options.deviceType === 'tvOS') { return log.error('Swipe is not supported') } - return this.handleRequest({ - method: 'POST', - uri: `${this.baseUrl}/session/${this.sessionId}/actions`, - body, - json: true, - }) + let swipeOperation = () => { + if (!this.isSwiping) { + this.isSwiping = true + this.handleRequest({ + method: 'POST', + uri: `${this.baseUrl}/session/${this.sessionId}/actions`, + body, + json: true, + }).then((response) => { + log.info('swipe response: ', response) + this.isSwiping = false + }) + } + } + + return swipeOperation() }, touchUp: function() { - if (!this.isMove) { + if (!this.isSwiping && this.deviceSize) { let {x, y} = this.touchDownParams x *= this.deviceSize.width @@ -428,7 +435,7 @@ module.exports = syrup.serial() }) }, doubleClick: function() { - if(!this.isMove) { + if(!this.isSwiping && this.deviceSize) { const {x, y} = this.touchDownParams const params = { x: x * this.deviceSize.width, From 7e93b94a40a0c957564e64be2e59029b94ba4c97 Mon Sep 17 00:00:00 2001 From: solvd Date: Thu, 23 Nov 2023 15:55:09 -0300 Subject: [PATCH 2/6] Disabling for ios < 17 --- res/app/control-panes/dashboard/navigation/navigation.pug | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/app/control-panes/dashboard/navigation/navigation.pug b/res/app/control-panes/dashboard/navigation/navigation.pug index 27319d89..dec04745 100755 --- a/res/app/control-panes/dashboard/navigation/navigation.pug +++ b/res/app/control-panes/dashboard/navigation/navigation.pug @@ -13,9 +13,9 @@ //i.fa.fa-step-forward.pull-right(ng-click='forward()', title='{{"Go Forward"|translate}}') //i.fa.fa-step-backward.pull-right(ng-click='back()', title='{{"Go Back"|translate}}') .widget-content.padded - form(enable-autofill, ng-submit='openUrl()', ng-disabled='device.ios && device.version >= 17') + form(enable-autofill, ng-submit='openUrl()', ng-disabled='device.ios && device.version < 17') .input-group.url-input-container - input.form-control(type='text', name='textURL', placeholder='http://...', ng-disabled='device.ios && device.version >= 17', + input.form-control(type='text', name='textURL', placeholder='http://...', ng-disabled='device.ios && device.version < 17', autocomplete='url', ng-model='textURL', text-focus-select, autocapitalize='off', spellcheck='false', blur-element='blurUrl' accesskey='N', tabindex='10', ng-change='textUrlChanged()', From 1457534c9d1eefec767c13c89711c078fd6649dd Mon Sep 17 00:00:00 2001 From: solvd Date: Thu, 23 Nov 2023 16:59:32 -0300 Subject: [PATCH 3/6] Catch register error and exit process --- lib/units/provider/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/units/provider/index.js b/lib/units/provider/index.js index 4b200a4a..23714f39 100755 --- a/lib/units/provider/index.js +++ b/lib/units/provider/index.js @@ -177,6 +177,10 @@ module.exports = function(options) { privateTracker.once('register', resolve) }) + register.catch(function(err) { + log.error('Register error', err) + process.exit(1) + }) // Spawn a device worker function spawn() { From 700ae3fe4e6f243ceaf0f960c00d3771e4ed7b25 Mon Sep 17 00:00:00 2001 From: solvd Date: Tue, 28 Nov 2023 09:28:00 -0300 Subject: [PATCH 4/6] Catching adb client --- lib/units/provider/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/units/provider/index.js b/lib/units/provider/index.js index 23714f39..37609fa6 100755 --- a/lib/units/provider/index.js +++ b/lib/units/provider/index.js @@ -114,7 +114,8 @@ module.exports = function(options) { }) // Track and manage devices - client.trackDevices().then(function(tracker) { + client.trackDevices() + .then(function(tracker) { // This can happen when ADB doesn't have a good connection to // the device function isWeirdUnusableDevice(device) { @@ -432,6 +433,10 @@ module.exports = function(options) { lifecycle.share('Tracker', tracker) }) + .catch(function(err) { + log.error('trackDevices error', err) + process.exit(1) + }) lifecycle.observe(function() { [push, sub].forEach(function(sock) { From 1506649871f179592c0b84c19233a15e18933f1b Mon Sep 17 00:00:00 2001 From: solvd Date: Tue, 28 Nov 2023 12:54:49 -0300 Subject: [PATCH 5/6] Set Unhealthy status from API --- lib/units/api/controllers/devices.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/units/api/controllers/devices.js b/lib/units/api/controllers/devices.js index ef1bfddc..d7b69450 100755 --- a/lib/units/api/controllers/devices.js +++ b/lib/units/api/controllers/devices.js @@ -479,6 +479,9 @@ function putDeviceInfoBySerial(req, res) { case "Disconnected": updates.push(dbapi.setDeviceAbsent(serial)); break; + case "Unhealthy": + updates.push(dbapi.saveDeviceStatus(serial, 7)); + break; default: apiutil.respond(res, 400, "Unknown status requested"); break; From 184f708b5e4141f7d99b64d17b37ff3840fefe27 Mon Sep 17 00:00:00 2001 From: Ignacio Narvaja <85379690+ignacionar@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:00:55 -0300 Subject: [PATCH 6/6] Replacing process.exit with default exit --- lib/units/provider/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/units/provider/index.js b/lib/units/provider/index.js index 37609fa6..7a0bc9fe 100755 --- a/lib/units/provider/index.js +++ b/lib/units/provider/index.js @@ -179,8 +179,8 @@ module.exports = function(options) { }) register.catch(function(err) { - log.error('Register error', err) - process.exit(1) + log.fatal('Register promise error', err) + lifecycle.fatal() }) // Spawn a device worker @@ -434,8 +434,8 @@ module.exports = function(options) { lifecycle.share('Tracker', tracker) }) .catch(function(err) { - log.error('trackDevices error', err) - process.exit(1) + log.fatal('Adb client error', err) + lifecycle.fatal() }) lifecycle.observe(function() {