appium-android-driver 5.14.7 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/build/lib/commands/actions.d.ts +6 -224
- package/build/lib/commands/actions.d.ts.map +1 -1
- package/build/lib/commands/actions.js +306 -405
- package/build/lib/commands/actions.js.map +1 -1
- package/build/lib/commands/alert.d.ts +7 -9
- package/build/lib/commands/alert.d.ts.map +1 -1
- package/build/lib/commands/alert.js +24 -18
- package/build/lib/commands/alert.js.map +1 -1
- package/build/lib/commands/app-management.d.ts +7 -313
- package/build/lib/commands/app-management.d.ts.map +1 -1
- package/build/lib/commands/app-management.js +135 -293
- package/build/lib/commands/app-management.js.map +1 -1
- package/build/lib/commands/context.d.ts +8 -92
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +381 -439
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/element.d.ts +8 -35
- package/build/lib/commands/element.d.ts.map +1 -1
- package/build/lib/commands/element.js +153 -136
- package/build/lib/commands/element.js.map +1 -1
- package/build/lib/commands/emu-console.d.ts +6 -48
- package/build/lib/commands/emu-console.d.ts.map +1 -1
- package/build/lib/commands/emu-console.js +19 -34
- package/build/lib/commands/emu-console.js.map +1 -1
- package/build/lib/commands/execute.d.ts +6 -5
- package/build/lib/commands/execute.d.ts.map +1 -1
- package/build/lib/commands/execute.js +77 -66
- package/build/lib/commands/execute.js.map +1 -1
- package/build/lib/commands/file-actions.d.ts +7 -128
- package/build/lib/commands/file-actions.d.ts.map +1 -1
- package/build/lib/commands/file-actions.js +183 -219
- package/build/lib/commands/file-actions.js.map +1 -1
- package/build/lib/commands/find.d.ts +8 -12
- package/build/lib/commands/find.d.ts.map +1 -1
- package/build/lib/commands/find.js +19 -23
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/commands/general.d.ts +9 -132
- package/build/lib/commands/general.d.ts.map +1 -1
- package/build/lib/commands/general.js +281 -312
- package/build/lib/commands/general.js.map +1 -1
- package/build/lib/commands/ime.d.ts +7 -10
- package/build/lib/commands/ime.d.ts.map +1 -1
- package/build/lib/commands/ime.js +47 -35
- package/build/lib/commands/ime.js.map +1 -1
- package/build/lib/commands/index.d.ts +27 -2
- package/build/lib/commands/index.d.ts.map +1 -1
- package/build/lib/commands/index.js +41 -19
- package/build/lib/commands/index.js.map +1 -1
- package/build/lib/commands/intent.d.ts +7 -417
- package/build/lib/commands/intent.d.ts.map +1 -1
- package/build/lib/commands/intent.js +104 -216
- package/build/lib/commands/intent.js.map +1 -1
- package/build/lib/commands/keyboard.d.ts +6 -5
- package/build/lib/commands/keyboard.d.ts.map +1 -1
- package/build/lib/commands/keyboard.js +16 -8
- package/build/lib/commands/keyboard.js.map +1 -1
- package/build/lib/commands/log.d.ts +7 -44
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +146 -108
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/commands/media-projection.d.ts +7 -143
- package/build/lib/commands/media-projection.d.ts.map +1 -1
- package/build/lib/commands/media-projection.js +113 -140
- package/build/lib/commands/media-projection.js.map +1 -1
- package/build/lib/commands/mixins.d.ts +740 -0
- package/build/lib/commands/mixins.d.ts.map +1 -0
- package/build/lib/commands/mixins.js +19 -0
- package/build/lib/commands/mixins.js.map +1 -0
- package/build/lib/commands/network.d.ts +7 -138
- package/build/lib/commands/network.d.ts.map +1 -1
- package/build/lib/commands/network.js +212 -254
- package/build/lib/commands/network.js.map +1 -1
- package/build/lib/commands/performance.d.ts +24 -70
- package/build/lib/commands/performance.d.ts.map +1 -1
- package/build/lib/commands/performance.js +144 -100
- package/build/lib/commands/performance.js.map +1 -1
- package/build/lib/commands/permissions.d.ts +8 -92
- package/build/lib/commands/permissions.d.ts.map +1 -1
- package/build/lib/commands/permissions.js +75 -87
- package/build/lib/commands/permissions.js.map +1 -1
- package/build/lib/commands/recordscreen.d.ts +7 -193
- package/build/lib/commands/recordscreen.d.ts.map +1 -1
- package/build/lib/commands/recordscreen.js +151 -182
- package/build/lib/commands/recordscreen.js.map +1 -1
- package/build/lib/commands/shell.d.ts +7 -7
- package/build/lib/commands/shell.d.ts.map +1 -1
- package/build/lib/commands/shell.js +40 -33
- package/build/lib/commands/shell.js.map +1 -1
- package/build/lib/commands/streamscreen.d.ts +9 -103
- package/build/lib/commands/streamscreen.d.ts.map +1 -1
- package/build/lib/commands/streamscreen.js +261 -218
- package/build/lib/commands/streamscreen.js.map +1 -1
- package/build/lib/commands/system-bars.d.ts +22 -90
- package/build/lib/commands/system-bars.d.ts.map +1 -1
- package/build/lib/commands/system-bars.js +76 -74
- package/build/lib/commands/system-bars.js.map +1 -1
- package/build/lib/commands/touch.d.ts +10 -29
- package/build/lib/commands/touch.d.ts.map +1 -1
- package/build/lib/commands/touch.js +301 -285
- package/build/lib/commands/touch.js.map +1 -1
- package/build/lib/commands/types.d.ts +978 -0
- package/build/lib/commands/types.d.ts.map +1 -0
- package/build/lib/commands/types.js +3 -0
- package/build/lib/commands/types.js.map +1 -0
- package/build/lib/constraints.d.ts +291 -0
- package/build/lib/constraints.d.ts.map +1 -0
- package/build/lib/{desired-caps.js → constraints.js} +103 -102
- package/build/lib/constraints.js.map +1 -0
- package/build/lib/driver.d.ts +68 -37
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +123 -80
- package/build/lib/driver.js.map +1 -1
- package/build/lib/helpers/android.d.ts +164 -0
- package/build/lib/helpers/android.d.ts.map +1 -0
- package/build/lib/helpers/android.js +819 -0
- package/build/lib/helpers/android.js.map +1 -0
- package/build/lib/helpers/index.d.ts +7 -0
- package/build/lib/helpers/index.d.ts.map +1 -0
- package/build/lib/helpers/index.js +29 -0
- package/build/lib/helpers/index.js.map +1 -0
- package/build/lib/helpers/types.d.ts +121 -0
- package/build/lib/helpers/types.d.ts.map +1 -0
- package/build/lib/helpers/types.js +3 -0
- package/build/lib/helpers/types.js.map +1 -0
- package/build/lib/helpers/unlock.d.ts +32 -0
- package/build/lib/helpers/unlock.d.ts.map +1 -0
- package/build/lib/helpers/unlock.js +273 -0
- package/build/lib/helpers/unlock.js.map +1 -0
- package/build/lib/helpers/webview.d.ts +74 -0
- package/build/lib/helpers/webview.d.ts.map +1 -0
- package/build/lib/helpers/webview.js +421 -0
- package/build/lib/helpers/webview.js.map +1 -0
- package/build/lib/index.d.ts +9 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/lib/index.js +37 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/method-map.d.ts +0 -8
- package/build/lib/method-map.d.ts.map +1 -1
- package/build/lib/method-map.js +63 -74
- package/build/lib/method-map.js.map +1 -1
- package/build/lib/stubs.d.ts +0 -1
- package/build/lib/stubs.d.ts.map +1 -1
- package/build/lib/stubs.js +1 -0
- package/build/lib/stubs.js.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/lib/commands/actions.js +351 -464
- package/lib/commands/alert.js +27 -17
- package/lib/commands/app-management.js +156 -314
- package/lib/commands/context.js +457 -441
- package/lib/commands/element.js +201 -157
- package/lib/commands/emu-console.js +25 -45
- package/lib/commands/execute.js +106 -90
- package/lib/commands/file-actions.js +222 -240
- package/lib/commands/find.ts +103 -0
- package/lib/commands/general.js +327 -339
- package/lib/commands/ime.js +50 -34
- package/lib/commands/{index.js → index.ts} +20 -24
- package/lib/commands/intent.js +108 -249
- package/lib/commands/keyboard.js +20 -8
- package/lib/commands/log.js +172 -116
- package/lib/commands/media-projection.js +134 -161
- package/lib/commands/mixins.ts +966 -0
- package/lib/commands/network.js +252 -281
- package/lib/commands/performance.js +203 -132
- package/lib/commands/permissions.js +108 -109
- package/lib/commands/recordscreen.js +212 -209
- package/lib/commands/shell.js +51 -40
- package/lib/commands/streamscreen.js +355 -289
- package/lib/commands/system-bars.js +92 -83
- package/lib/commands/touch.js +357 -294
- package/lib/commands/types.ts +1097 -0
- package/lib/{desired-caps.js → constraints.ts} +106 -103
- package/lib/{driver.js → driver.ts} +278 -132
- package/lib/helpers/android.ts +1143 -0
- package/lib/helpers/index.ts +6 -0
- package/lib/helpers/types.ts +134 -0
- package/lib/helpers/unlock.ts +329 -0
- package/lib/helpers/webview.ts +582 -0
- package/lib/index.ts +18 -0
- package/lib/method-map.js +87 -98
- package/lib/stubs.ts +0 -1
- package/package.json +26 -19
- package/build/index.js +0 -51
- package/build/lib/android-helpers.d.ts +0 -136
- package/build/lib/android-helpers.d.ts.map +0 -1
- package/build/lib/android-helpers.js +0 -855
- package/build/lib/android-helpers.js.map +0 -1
- package/build/lib/commands/coverage.d.ts +0 -5
- package/build/lib/commands/coverage.d.ts.map +0 -1
- package/build/lib/commands/coverage.js +0 -19
- package/build/lib/commands/coverage.js.map +0 -1
- package/build/lib/desired-caps.d.ts +0 -353
- package/build/lib/desired-caps.d.ts.map +0 -1
- package/build/lib/desired-caps.js.map +0 -1
- package/build/lib/unlock-helpers.d.ts +0 -38
- package/build/lib/unlock-helpers.d.ts.map +0 -1
- package/build/lib/unlock-helpers.js +0 -266
- package/build/lib/unlock-helpers.js.map +0 -1
- package/build/lib/webview-helpers.d.ts +0 -224
- package/build/lib/webview-helpers.d.ts.map +0 -1
- package/build/lib/webview-helpers.js +0 -528
- package/build/lib/webview-helpers.js.map +0 -1
- package/index.js +0 -24
- package/lib/android-helpers.js +0 -983
- package/lib/commands/coverage.js +0 -18
- package/lib/commands/find.js +0 -82
- package/lib/unlock-helpers.js +0 -278
- package/lib/webview-helpers.js +0 -602
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { errors } from 'appium/driver';
|
|
3
|
-
import B from 'bluebird';
|
|
4
|
-
import { ADB_SHELL_FEATURE } from '../utils';
|
|
1
|
+
// @ts-check
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
import {errors} from 'appium/driver';
|
|
4
|
+
import B from 'bluebird';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
import {ADB_SHELL_FEATURE} from '../utils';
|
|
7
|
+
import {mixin} from './mixins';
|
|
7
8
|
|
|
8
9
|
const ALL_PERMISSIONS_MAGIC = 'all';
|
|
9
10
|
const PM_ACTION = Object.freeze({
|
|
@@ -26,18 +27,28 @@ const PERMISSIONS_TYPE = Object.freeze({
|
|
|
26
27
|
REQUESTED: 'requested',
|
|
27
28
|
});
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @this {AndroidDriver}
|
|
32
|
+
* @param {*} permissions
|
|
33
|
+
* @param {*} appPackage
|
|
34
|
+
* @param {*} action
|
|
35
|
+
* @todo FIXME: type this
|
|
36
|
+
*/
|
|
37
|
+
async function changePermissionsViaPm(permissions, appPackage, action) {
|
|
30
38
|
if (!_.values(PM_ACTION).includes(action)) {
|
|
31
|
-
throw new errors.InvalidArgumentError(
|
|
32
|
-
`
|
|
39
|
+
throw new errors.InvalidArgumentError(
|
|
40
|
+
`Unknown action '${action}'. ` +
|
|
41
|
+
`Only ${JSON.stringify(_.values(PM_ACTION))} actions are supported`
|
|
42
|
+
);
|
|
33
43
|
}
|
|
44
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
34
45
|
|
|
35
46
|
let affectedPermissions = _.isArray(permissions) ? permissions : [permissions];
|
|
36
47
|
if (_.toLower(permissions) === ALL_PERMISSIONS_MAGIC) {
|
|
37
|
-
const dumpsys = await
|
|
38
|
-
const grantedPermissions = await
|
|
48
|
+
const dumpsys = await adb.shell(['dumpsys', 'package', appPackage]);
|
|
49
|
+
const grantedPermissions = await adb.getGrantedPermissions(appPackage, dumpsys);
|
|
39
50
|
if (action === PM_ACTION.GRANT) {
|
|
40
|
-
const reqPermissons = await
|
|
51
|
+
const reqPermissons = await adb.getReqPermissions(appPackage, dumpsys);
|
|
41
52
|
affectedPermissions = _.difference(reqPermissons, grantedPermissions);
|
|
42
53
|
} else {
|
|
43
54
|
affectedPermissions = grantedPermissions;
|
|
@@ -49,121 +60,109 @@ async function changePermissionsViaPm (permissions, appPackage, action) {
|
|
|
49
60
|
}
|
|
50
61
|
|
|
51
62
|
if (action === PM_ACTION.GRANT) {
|
|
52
|
-
await
|
|
63
|
+
await adb.grantPermissions(appPackage, affectedPermissions);
|
|
53
64
|
} else {
|
|
54
|
-
await B.all(affectedPermissions.map((name) =>
|
|
65
|
+
await B.all(affectedPermissions.map((name) => adb.revokePermission(appPackage, name)));
|
|
55
66
|
}
|
|
56
67
|
}
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
/**
|
|
69
|
+
* @this {AndroidDriver}
|
|
70
|
+
* @param {*} permissions
|
|
71
|
+
* @param {*} appPackage
|
|
72
|
+
* @param {*} action
|
|
73
|
+
* @todo FIXME: type this
|
|
74
|
+
*/
|
|
75
|
+
async function changePermissionsViaAppops(permissions, appPackage, action) {
|
|
59
76
|
if (!_.values(APPOPS_ACTION).includes(action)) {
|
|
60
|
-
throw new errors.InvalidArgumentError(
|
|
61
|
-
`
|
|
77
|
+
throw new errors.InvalidArgumentError(
|
|
78
|
+
`Unknown action '${action}'. ` +
|
|
79
|
+
`Only ${JSON.stringify(_.values(APPOPS_ACTION))} actions are supported`
|
|
80
|
+
);
|
|
62
81
|
}
|
|
63
82
|
if (_.toLower(permissions) === ALL_PERMISSIONS_MAGIC) {
|
|
64
|
-
throw new errors.InvalidArgumentError(
|
|
65
|
-
`'${
|
|
66
|
-
|
|
83
|
+
throw new errors.InvalidArgumentError(
|
|
84
|
+
`'${ALL_PERMISSIONS_MAGIC}' permission is only supported for ` +
|
|
85
|
+
`'${PERMISSION_TARGET.PM}' target. ` +
|
|
86
|
+
`Check AppOpsManager.java from Android platform sources to get the full list of supported AppOps permissions`
|
|
87
|
+
);
|
|
67
88
|
}
|
|
68
89
|
|
|
69
|
-
const promises = (_.isArray(permissions) ? permissions : [permissions])
|
|
70
|
-
|
|
90
|
+
const promises = (_.isArray(permissions) ? permissions : [permissions]).map((permission) =>
|
|
91
|
+
/** @type {ADB} */ (this.adb).shell(['appops', 'set', appPackage, permission, action])
|
|
92
|
+
);
|
|
71
93
|
await B.all(promises);
|
|
72
94
|
}
|
|
73
95
|
|
|
74
96
|
/**
|
|
75
|
-
* @
|
|
76
|
-
* @
|
|
77
|
-
* If `target` is set to 'pm':
|
|
78
|
-
* The full name of the permission to be changed
|
|
79
|
-
* or a list of permissions. Check https://developer.android.com/reference/android/Manifest.permission
|
|
80
|
-
* to get the full list of standard Android permssion names. Mandatory argument.
|
|
81
|
-
* If 'all' magic string is passed then the chosen action is going to be applied to all
|
|
82
|
-
* permisisons requested/granted by 'appPackage'.
|
|
83
|
-
* If `target` is set to 'appops':
|
|
84
|
-
* The full name of the appops permission to be changed
|
|
85
|
-
* or a list of permissions. Check AppOpsManager.java sources to get the full list of
|
|
86
|
-
* supported appops permission names for the given Android pklatform.
|
|
87
|
-
* Examples: 'ACTIVITY_RECOGNITION', 'SMS_FINANCIAL_TRANSACTIONS', 'READ_SMS', 'ACCESS_NOTIFICATIONS'.
|
|
88
|
-
* The 'all' magic string is unsupported.
|
|
89
|
-
* @property {string} appPackage [this.opts.appPackage] The application package to set change
|
|
90
|
-
* permissions on. Defaults to the package name under test.
|
|
91
|
-
* @property {string} action [grant|allow] One of `PM_ACTION` values if `target` is set to 'pm',
|
|
92
|
-
* otherwise one of `APPOPS_ACTION` values
|
|
93
|
-
* @property {string} target [pm] Either 'pm' or 'appops'. The 'appops' one requires
|
|
94
|
-
* 'adb_shell' server security option to be enabled.
|
|
97
|
+
* @type {import('./mixins').PermissionsMixin & ThisType<import('../driver').AndroidDriver>}
|
|
98
|
+
* @satisfies {import('@appium/types').ExternalDriver}
|
|
95
99
|
*/
|
|
100
|
+
const PermissionsMixin = {
|
|
101
|
+
async mobileChangePermissions(opts) {
|
|
102
|
+
const {
|
|
103
|
+
permissions,
|
|
104
|
+
appPackage = this.opts.appPackage,
|
|
105
|
+
action = _.toLower(opts.target) === PERMISSION_TARGET.APPOPS
|
|
106
|
+
? APPOPS_ACTION.ALLOW
|
|
107
|
+
: PM_ACTION.GRANT,
|
|
108
|
+
target = PERMISSION_TARGET.PM,
|
|
109
|
+
} = opts;
|
|
110
|
+
if (_.isNil(permissions)) {
|
|
111
|
+
throw new errors.InvalidArgumentError(`'permissions' argument is required`);
|
|
112
|
+
}
|
|
113
|
+
if (_.isEmpty(permissions)) {
|
|
114
|
+
throw new errors.InvalidArgumentError(`'permissions' argument must not be empty`);
|
|
115
|
+
}
|
|
96
116
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
if (_.isEmpty(permissions)) {
|
|
114
|
-
throw new errors.InvalidArgumentError(`'permissions' argument must not be empty`);
|
|
115
|
-
}
|
|
117
|
+
switch (_.toLower(target)) {
|
|
118
|
+
case PERMISSION_TARGET.PM:
|
|
119
|
+
return await changePermissionsViaPm.bind(this)(permissions, appPackage, _.toLower(action));
|
|
120
|
+
case PERMISSION_TARGET.APPOPS:
|
|
121
|
+
this.ensureFeatureEnabled(ADB_SHELL_FEATURE);
|
|
122
|
+
return await changePermissionsViaAppops.bind(this)(
|
|
123
|
+
permissions,
|
|
124
|
+
appPackage,
|
|
125
|
+
_.toLower(action)
|
|
126
|
+
);
|
|
127
|
+
default:
|
|
128
|
+
throw new errors.InvalidArgumentError(
|
|
129
|
+
`'target' argument must be one of: ${_.values(PERMISSION_TARGET)}`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
116
133
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
134
|
+
async mobileGetPermissions(opts = {}) {
|
|
135
|
+
const {type = PERMISSIONS_TYPE.REQUESTED, appPackage = this.opts.appPackage} = opts;
|
|
136
|
+
const adb = /** @type {ADB} */ (this.adb);
|
|
137
|
+
/**
|
|
138
|
+
* @type {(pkg: string) => Promise<string[]>}
|
|
139
|
+
*/
|
|
140
|
+
let actionFunc;
|
|
141
|
+
switch (_.toLower(type)) {
|
|
142
|
+
case PERMISSIONS_TYPE.REQUESTED:
|
|
143
|
+
actionFunc = (pkg) => adb.getReqPermissions(pkg);
|
|
144
|
+
break;
|
|
145
|
+
case PERMISSIONS_TYPE.GRANTED:
|
|
146
|
+
actionFunc = (pkg) => adb.getGrantedPermissions(pkg);
|
|
147
|
+
break;
|
|
148
|
+
case PERMISSIONS_TYPE.DENIED:
|
|
149
|
+
actionFunc = (pkg) => adb.getDeniedPermissions(pkg);
|
|
150
|
+
break;
|
|
151
|
+
default:
|
|
152
|
+
throw new errors.InvalidArgumentError(
|
|
153
|
+
`Unknown permissions type '${type}'. ` +
|
|
154
|
+
`Only ${JSON.stringify(_.values(PERMISSIONS_TYPE))} types are supported`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
return await actionFunc(/** @type {string} */ (appPackage));
|
|
158
|
+
},
|
|
126
159
|
};
|
|
127
160
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
* Can be any of `PERMISSIONS_TYPE` values.
|
|
132
|
-
* @property {string} appPackage [this.opts.appPackage] - The application package to set change
|
|
133
|
-
* permissions on. Defaults to the package name under test.
|
|
134
|
-
*/
|
|
161
|
+
mixin(PermissionsMixin);
|
|
162
|
+
|
|
163
|
+
export default PermissionsMixin;
|
|
135
164
|
|
|
136
165
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* @param {GetPermissionsOptions} opts - Available options mapping.
|
|
140
|
-
* @returns {Array<string>} The list of retrieved permissions for the given type
|
|
141
|
-
* (can also be empty).
|
|
142
|
-
* @throws {Error} if there was an error while getting permissions.
|
|
166
|
+
* @typedef {import('appium-adb').ADB} ADB
|
|
167
|
+
* @typedef {import('../driver').AndroidDriver} AndroidDriver
|
|
143
168
|
*/
|
|
144
|
-
commands.mobileGetPermissions = async function mobileGetPermissions (opts = {}) {
|
|
145
|
-
const {
|
|
146
|
-
type = PERMISSIONS_TYPE.REQUESTED,
|
|
147
|
-
appPackage = this.opts.appPackage,
|
|
148
|
-
} = opts;
|
|
149
|
-
|
|
150
|
-
let actionFunc;
|
|
151
|
-
switch (_.toLower(type)) {
|
|
152
|
-
case PERMISSIONS_TYPE.REQUESTED:
|
|
153
|
-
actionFunc = (pkg) => this.adb.getReqPermissions(pkg);
|
|
154
|
-
break;
|
|
155
|
-
case PERMISSIONS_TYPE.GRANTED:
|
|
156
|
-
actionFunc = (pkg) => this.adb.getGrantedPermissions(pkg);
|
|
157
|
-
break;
|
|
158
|
-
case PERMISSIONS_TYPE.DENIED:
|
|
159
|
-
actionFunc = (pkg) => this.adb.getDeniedPermissions(pkg);
|
|
160
|
-
break;
|
|
161
|
-
default:
|
|
162
|
-
throw new errors.InvalidArgumentError(`Unknown permissions type '${type}'. ` +
|
|
163
|
-
`Only ${JSON.stringify(_.values(PERMISSIONS_TYPE))} types are supported`);
|
|
164
|
-
}
|
|
165
|
-
return await actionFunc(appPackage);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export { commands };
|
|
169
|
-
export default commands;
|