From 4cd78c20cb06a36103432925a3a0fb7800043bfb Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sat, 28 Mar 2020 23:26:40 +0900 Subject: [PATCH 1/8] add disableSuppressAccessibilityService --- lib/desired-caps.js | 3 +++ lib/driver.js | 1 + lib/uiautomator2.js | 5 ++++- test/unit/driver-specs.js | 8 +++++++- test/unit/uiautomator2-specs.js | 9 +++++++-- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/desired-caps.js b/lib/desired-caps.js index e816026ca..3345af856 100644 --- a/lib/desired-caps.js +++ b/lib/desired-caps.js @@ -43,6 +43,9 @@ let uiautomatorCapConstraints = { }, appWaitForLaunch: { isBoolean: true + }, + disableSuppressAccessibilityService: { + isBoolean: true } }; diff --git a/lib/driver.js b/lib/driver.js index c2e435ccf..2aebb8e7c 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -431,6 +431,7 @@ class AndroidUiautomator2Driver extends BaseDriver { appPackage: this.opts.appPackage, appActivity: this.opts.appActivity, disableWindowAnimation: !!this.opts.disableWindowAnimation, + disableSuppressAccessibilityService: !!this.opts.disableSuppressAccessibilityService, }); this.proxyReqRes = this.uiautomator2.proxyReqRes.bind(this.uiautomator2); diff --git a/lib/uiautomator2.js b/lib/uiautomator2.js index ba6d3b478..fe53943ef 100644 --- a/lib/uiautomator2.js +++ b/lib/uiautomator2.js @@ -9,7 +9,7 @@ import helpers from './helpers'; import request from 'request-promise'; import path from 'path'; -const REQD_PARAMS = ['adb', 'tmpDir', 'host', 'systemPort', 'devicePort', 'disableWindowAnimation']; +const REQD_PARAMS = ['adb', 'tmpDir', 'host', 'systemPort', 'devicePort', 'disableWindowAnimation', 'disableSuppressAccessibilityService']; const SERVER_LAUNCH_TIMEOUT = 30000; const SERVER_INSTALL_RETRIES = 20; const SERVICES_LAUNCH_TIMEOUT = 30000; @@ -252,6 +252,9 @@ class UiAutomator2Server { if (this.disableWindowAnimation) { cmd.push('--no-window-animation'); } + if (this.disableSuppressAccessibilityService) { + cmd.push('-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES true'); + } cmd.push(INSTRUMENTATION_TARGET); const instrumentationProcess = this.adb.createSubProcess(['shell', ...cmd]); instrumentationProcess.on('output', (stdout, stderr) => { diff --git a/test/unit/driver-specs.js b/test/unit/driver-specs.js index bc40e2720..7d09ce5f7 100644 --- a/test/unit/driver-specs.js +++ b/test/unit/driver-specs.js @@ -229,7 +229,13 @@ describe('driver.js', function () { sandbox.stub(driver, 'addDeviceInfoToCaps'); driver.uiautomator2 = new UiAutomator2Server({ - adb: ADB.createADB(), tmpDir: 'tmp', systemPort: 4724, host: 'localhost', devicePort: 6790, disableWindowAnimation: false + adb: ADB.createADB(), + tmpDir: 'tmp', + systemPort: 4724, + host: 'localhost', + devicePort: 6790, + disableWindowAnimation: false, + disableSuppressAccessibilityService: false, }); sandbox.stub(driver.uiautomator2, 'startSession'); }); diff --git a/test/unit/uiautomator2-specs.js b/test/unit/uiautomator2-specs.js index f09e9f02a..7319e0816 100644 --- a/test/unit/uiautomator2-specs.js +++ b/test/unit/uiautomator2-specs.js @@ -15,8 +15,13 @@ describe('UiAutomator2', function () { let uiautomator2; beforeEach(function () { uiautomator2 = new UiAutomator2Server({ - adb, tmpDir: 'tmp', systemPort: 4724, - host: 'localhost', devicePort: 6790, disableWindowAnimation: false + adb, + tmpDir: 'tmp', + systemPort: 4724, + host: 'localhost', + devicePort: 6790, + disableWindowAnimation: false, + disableSuppressAccessibilityService: false }); }); afterEach(function () { From 4bd3952a5f0d9604c4f405677a1e7fa5b07c2c59 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sun, 29 Mar 2020 19:37:52 +0900 Subject: [PATCH 2/8] make this.disableSuppressAccessibilityService optional --- lib/driver.js | 2 +- lib/uiautomator2.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/driver.js b/lib/driver.js index 2aebb8e7c..af4390e53 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -431,7 +431,7 @@ class AndroidUiautomator2Driver extends BaseDriver { appPackage: this.opts.appPackage, appActivity: this.opts.appActivity, disableWindowAnimation: !!this.opts.disableWindowAnimation, - disableSuppressAccessibilityService: !!this.opts.disableSuppressAccessibilityService, + disableSuppressAccessibilityService: this.opts.disableSuppressAccessibilityService, }); this.proxyReqRes = this.uiautomator2.proxyReqRes.bind(this.uiautomator2); diff --git a/lib/uiautomator2.js b/lib/uiautomator2.js index fe53943ef..0a9da9291 100644 --- a/lib/uiautomator2.js +++ b/lib/uiautomator2.js @@ -9,7 +9,7 @@ import helpers from './helpers'; import request from 'request-promise'; import path from 'path'; -const REQD_PARAMS = ['adb', 'tmpDir', 'host', 'systemPort', 'devicePort', 'disableWindowAnimation', 'disableSuppressAccessibilityService']; +const REQD_PARAMS = ['adb', 'tmpDir', 'host', 'systemPort', 'devicePort', 'disableWindowAnimation']; const SERVER_LAUNCH_TIMEOUT = 30000; const SERVER_INSTALL_RETRIES = 20; const SERVICES_LAUNCH_TIMEOUT = 30000; @@ -26,6 +26,7 @@ class UiAutomator2Server { } this[req] = opts[req]; } + this.disableSuppressAccessibilityService = opts.disableSuppressAccessibilityService; this.jwproxy = new JWProxy({ server: this.host, port: this.systemPort, @@ -252,8 +253,12 @@ class UiAutomator2Server { if (this.disableWindowAnimation) { cmd.push('--no-window-animation'); } - if (this.disableSuppressAccessibilityService) { - cmd.push('-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES true'); + if (util.hasValue(this.disableSuppressAccessibilityService)) { + if (this.disableSuppressAccessibilityService) { + cmd.push('-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES true'); + } else { + cmd.push('-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES false'); + } } cmd.push(INSTRUMENTATION_TARGET); const instrumentationProcess = this.adb.createSubProcess(['shell', ...cmd]); From d0522d9e7647f55044e5f483e1cda95515a7793e Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sun, 29 Mar 2020 19:41:02 +0900 Subject: [PATCH 3/8] tune --- lib/uiautomator2.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/uiautomator2.js b/lib/uiautomator2.js index 0a9da9291..120e8b618 100644 --- a/lib/uiautomator2.js +++ b/lib/uiautomator2.js @@ -254,11 +254,7 @@ class UiAutomator2Server { cmd.push('--no-window-animation'); } if (util.hasValue(this.disableSuppressAccessibilityService)) { - if (this.disableSuppressAccessibilityService) { - cmd.push('-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES true'); - } else { - cmd.push('-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES false'); - } + cmd.push(`-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES ${this.disableSuppressAccessibilityService ? 'true' : 'false'}`); } cmd.push(INSTRUMENTATION_TARGET); const instrumentationProcess = this.adb.createSubProcess(['shell', ...cmd]); From 4a81c9440822efb8e9bb670d1c7651e7da310757 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sun, 29 Mar 2020 20:16:18 +0900 Subject: [PATCH 4/8] tune --- lib/uiautomator2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uiautomator2.js b/lib/uiautomator2.js index 120e8b618..135df58ac 100644 --- a/lib/uiautomator2.js +++ b/lib/uiautomator2.js @@ -254,7 +254,7 @@ class UiAutomator2Server { cmd.push('--no-window-animation'); } if (util.hasValue(this.disableSuppressAccessibilityService)) { - cmd.push(`-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES ${this.disableSuppressAccessibilityService ? 'true' : 'false'}`); + cmd.push(`-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES ${this.disableSuppressAccessibilityService}`); } cmd.push(INSTRUMENTATION_TARGET); const instrumentationProcess = this.adb.createSubProcess(['shell', ...cmd]); From eeed119d66492c7423d81a8e626ab934c5e4c9fc Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sun, 29 Mar 2020 20:19:59 +0900 Subject: [PATCH 5/8] use isBoolean --- lib/uiautomator2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uiautomator2.js b/lib/uiautomator2.js index 135df58ac..4bd2c1680 100644 --- a/lib/uiautomator2.js +++ b/lib/uiautomator2.js @@ -253,7 +253,7 @@ class UiAutomator2Server { if (this.disableWindowAnimation) { cmd.push('--no-window-animation'); } - if (util.hasValue(this.disableSuppressAccessibilityService)) { + if (_.isBoolean(this.disableSuppressAccessibilityService)) { cmd.push(`-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES ${this.disableSuppressAccessibilityService}`); } cmd.push(INSTRUMENTATION_TARGET); From 1956374b716c809f752e3aa8a7e670b973f43a7d Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sun, 29 Mar 2020 22:49:24 +0900 Subject: [PATCH 6/8] switch to array --- lib/uiautomator2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uiautomator2.js b/lib/uiautomator2.js index 4bd2c1680..04617e6fe 100644 --- a/lib/uiautomator2.js +++ b/lib/uiautomator2.js @@ -254,7 +254,7 @@ class UiAutomator2Server { cmd.push('--no-window-animation'); } if (_.isBoolean(this.disableSuppressAccessibilityService)) { - cmd.push(`-e DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES ${this.disableSuppressAccessibilityService}`); + cmd.push('-e', 'DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES', this.disableSuppressAccessibilityService); } cmd.push(INSTRUMENTATION_TARGET); const instrumentationProcess = this.adb.createSubProcess(['shell', ...cmd]); From ec3ea7a6ff7f768bba65b323cbb095426de2c9a5 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Mon, 30 Mar 2020 00:15:31 +0900 Subject: [PATCH 7/8] bump server version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6798ab66f..2d4d9682d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "appium-android-driver": "^4.27.0", "appium-base-driver": "^5.0.0", "appium-support": "^2.37.0", - "appium-uiautomator2-server": "^4.5.7", + "appium-uiautomator2-server": "^4.6.0", "async-lock": "^1.2.2", "asyncbox": "^2.3.1", "bluebird": "^3.5.1", From 2c03025808667e1f110393bc4713706f812b2570 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Mon, 30 Mar 2020 16:55:48 +0900 Subject: [PATCH 8/8] bump the server version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2d4d9682d..54b59fccb 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "appium-android-driver": "^4.27.0", "appium-base-driver": "^5.0.0", "appium-support": "^2.37.0", - "appium-uiautomator2-server": "^4.6.0", + "appium-uiautomator2-server": "^4.6.1", "async-lock": "^1.2.2", "asyncbox": "^2.3.1", "bluebird": "^3.5.1",