Skip to content

Commit

Permalink
feat: add disableSuppressAccessibilityService (#376)
Browse files Browse the repository at this point in the history
* add disableSuppressAccessibilityService

* make this.disableSuppressAccessibilityService optional

* tune

* tune

* use isBoolean

* switch to array

* bump server version

* bump the server version
  • Loading branch information
KazuCocoa authored Mar 30, 2020
1 parent d6cadbb commit c41986b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/desired-caps.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ let uiautomatorCapConstraints = {
},
appWaitForLaunch: {
isBoolean: true
},
disableSuppressAccessibilityService: {
isBoolean: true
}
};

Expand Down
1 change: 1 addition & 0 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions lib/uiautomator2.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class UiAutomator2Server {
}
this[req] = opts[req];
}
this.disableSuppressAccessibilityService = opts.disableSuppressAccessibilityService;
this.jwproxy = new JWProxy({
server: this.host,
port: this.systemPort,
Expand Down Expand Up @@ -252,6 +253,9 @@ class UiAutomator2Server {
if (this.disableWindowAnimation) {
cmd.push('--no-window-animation');
}
if (_.isBoolean(this.disableSuppressAccessibilityService)) {
cmd.push('-e', 'DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES', this.disableSuppressAccessibilityService);
}
cmd.push(INSTRUMENTATION_TARGET);
const instrumentationProcess = this.adb.createSubProcess(['shell', ...cmd]);
instrumentationProcess.on('output', (stdout, stderr) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.1",
"async-lock": "^1.2.2",
"asyncbox": "^2.3.1",
"bluebird": "^3.5.1",
Expand Down
8 changes: 7 additions & 1 deletion test/unit/driver-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
9 changes: 7 additions & 2 deletions test/unit/uiautomator2-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit c41986b

Please sign in to comment.