io.appium.settings 5.4.2 → 5.5.0
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 +8 -0
- package/apks/settings_apk-debug.apk +0 -0
- package/build/lib/client.d.ts +4 -2
- package/build/lib/client.d.ts.map +1 -1
- package/build/lib/client.js +2 -1
- package/build/lib/client.js.map +1 -1
- package/build/lib/commands/locale.d.ts +8 -8
- package/build/lib/commands/locale.d.ts.map +1 -1
- package/build/lib/commands/locale.js +52 -4
- package/build/lib/commands/locale.js.map +1 -1
- package/build/lib/commands/notifications.d.ts +8 -0
- package/build/lib/commands/notifications.d.ts.map +1 -1
- package/build/lib/commands/notifications.js +21 -1
- package/build/lib/commands/notifications.js.map +1 -1
- package/build/lib/constants.d.ts +1 -1
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +2 -2
- package/build/lib/constants.js.map +1 -1
- package/lib/client.js +4 -3
- package/lib/commands/locale.js +50 -2
- package/lib/commands/notifications.js +24 -1
- package/lib/constants.js +1 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [5.5.0](https://github.com/appium/io.appium.settings/compare/v5.4.2...v5.5.0) (2024-01-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add a helper to adjust notifications permissions ([#139](https://github.com/appium/io.appium.settings/issues/139)) ([e0b88e6](https://github.com/appium/io.appium.settings/commit/e0b88e6f4c3291c5932e9773aa2594280efe80ba))
|
|
7
|
+
* Update method to set device locale ([#136](https://github.com/appium/io.appium.settings/issues/136)) ([329c29f](https://github.com/appium/io.appium.settings/commit/329c29f31fcb1774a569820b06bf26b9462df6cd))
|
|
8
|
+
|
|
1
9
|
## [5.4.2](https://github.com/appium/io.appium.settings/compare/v5.4.1...v5.4.2) (2024-01-10)
|
|
2
10
|
|
|
3
11
|
|
|
Binary file
|
package/build/lib/client.d.ts
CHANGED
|
@@ -64,11 +64,12 @@ export class SettingsApp {
|
|
|
64
64
|
setGeoLocation: typeof setGeoLocation;
|
|
65
65
|
getGeoLocation: typeof getGeoLocation;
|
|
66
66
|
refreshGeoLocationCache: typeof refreshGeoLocationCache;
|
|
67
|
-
|
|
67
|
+
setDeviceLocale: typeof setDeviceLocale;
|
|
68
68
|
scanMedia: typeof scanMedia;
|
|
69
69
|
setDataState: typeof setDataState;
|
|
70
70
|
setWifiState: typeof setWifiState;
|
|
71
71
|
getNotifications: typeof getNotifications;
|
|
72
|
+
adjustNotificationsPermissions: typeof adjustNotificationsPermissions;
|
|
72
73
|
getSmsList: typeof getSmsList;
|
|
73
74
|
performEditorAction: typeof performEditorAction;
|
|
74
75
|
typeUnicode: typeof typeUnicode;
|
|
@@ -81,11 +82,12 @@ import { getClipboard } from './commands/clipboard';
|
|
|
81
82
|
import { setGeoLocation } from './commands/geolocation';
|
|
82
83
|
import { getGeoLocation } from './commands/geolocation';
|
|
83
84
|
import { refreshGeoLocationCache } from './commands/geolocation';
|
|
84
|
-
import {
|
|
85
|
+
import { setDeviceLocale } from './commands/locale';
|
|
85
86
|
import { scanMedia } from './commands/media';
|
|
86
87
|
import { setDataState } from './commands/network';
|
|
87
88
|
import { setWifiState } from './commands/network';
|
|
88
89
|
import { getNotifications } from './commands/notifications';
|
|
90
|
+
import { adjustNotificationsPermissions } from './commands/notifications';
|
|
89
91
|
import { getSmsList } from './commands/sms';
|
|
90
92
|
import { performEditorAction } from './commands/typing';
|
|
91
93
|
import { typeUnicode } from './commands/typing';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../lib/client.js"],"names":[],"mappings":"AAcA;;;GAGG;AAGH;IAOE;;OAEG;IACH,kBAFW,eAAe,EAKzB;IAZD,uCAAuC;IACvC,KADW,OAAO,YAAY,EAAE,GAAG,CAC/B;IAEJ,sCAAsC;IACtC,KADW,OAAO,QAAQ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}
|
package/build/lib/client.js
CHANGED
|
@@ -31,11 +31,12 @@ class SettingsApp {
|
|
|
31
31
|
this.setGeoLocation = geolocation_1.setGeoLocation;
|
|
32
32
|
this.getGeoLocation = geolocation_1.getGeoLocation;
|
|
33
33
|
this.refreshGeoLocationCache = geolocation_1.refreshGeoLocationCache;
|
|
34
|
-
this.
|
|
34
|
+
this.setDeviceLocale = locale_1.setDeviceLocale;
|
|
35
35
|
this.scanMedia = media_1.scanMedia;
|
|
36
36
|
this.setDataState = network_1.setDataState;
|
|
37
37
|
this.setWifiState = network_1.setWifiState;
|
|
38
38
|
this.getNotifications = notifications_1.getNotifications;
|
|
39
|
+
this.adjustNotificationsPermissions = notifications_1.adjustNotificationsPermissions;
|
|
39
40
|
this.getSmsList = sms_1.getSmsList;
|
|
40
41
|
this.performEditorAction = typing_1.performEditorAction;
|
|
41
42
|
this.typeUnicode = typing_1.typeUnicode;
|
package/build/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../lib/client.js"],"names":[],"mappings":";;;;;;AAAA,qCAA2C;AAC3C,oDAAuB;AACvB,uCAA4C;AAC5C,iDAAmF;AACnF,oDAAyD;AACzD,oDAAoD;AACpD,wDAAiG;AACjG,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../lib/client.js"],"names":[],"mappings":";;;;;;AAAA,qCAA2C;AAC3C,oDAAuB;AACvB,uCAA4C;AAC5C,iDAAmF;AACnF,oDAAyD;AACzD,oDAAoD;AACpD,wDAAiG;AACjG,8CAAoD;AACpD,4CAA6C;AAC7C,gDAAgE;AAChE,4DAA4F;AAC5F,wCAA4C;AAC5C,8CAAqE;AAErE;;;GAGG;AAGH,MAAa,WAAW;IAOtB;;OAEG;IACH,YAAa,IAAI;QA4HjB,sBAAiB,GAAG,6BAAiB,CAAC;QAEtC,iBAAY,GAAG,wBAAY,CAAC;QAE5B,mBAAc,GAAG,4BAAc,CAA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,CAAE,MAAM,EAAE,UAAU;QAChC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAU,EAAE,MAAM,CAAC,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,mBAAmB,UAAU,oBAAoB;gBACjD,uCAAuC,CACxC,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAU,EAAE,MAAM,CAAC,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,gBAAgB,UAAU,4BAA4B;gBACtD,uCAAuC,CACxC,CAAC;QACJ,CAAC;QACD,MAAM,OAAO,GAAG,gBAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,YAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,gBAAgB,UAAU,mCAAmC;gBAC7D,uCAAuC,CACxC,CAAC;QACJ,CAAC;IACH,CAAC;CAuBF;AA3JD,kCA2JC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This method sets an arbitrary locale following:
|
|
4
|
-
* https://developer.android.com/reference/java/util/Locale.html
|
|
5
|
-
* https://developer.android.com/reference/java/util/Locale.html#Locale(java.lang.String,%20java.lang.String)
|
|
2
|
+
* Set the locale name of the device under test.
|
|
6
3
|
*
|
|
7
4
|
* @this {import('../client').SettingsApp}
|
|
8
|
-
* @param {string} language - Language.
|
|
9
|
-
*
|
|
10
|
-
* @param {string
|
|
5
|
+
* @param {string} language - Language. The language field is case insensitive, but Locale always canonicalizes to lower case.
|
|
6
|
+
* format: [a-zA-Z]{2,8}. e.g. en, ja : https://developer.android.com/reference/java/util/Locale.html
|
|
7
|
+
* @param {string} country - Country. The country (region) field is case insensitive, but Locale always canonicalizes to upper case.
|
|
8
|
+
* format: [a-zA-Z]{2} | [0-9]{3}. e.g. US, JP : https://developer.android.com/reference/java/util/Locale.html
|
|
9
|
+
* @param {string?} [script=null] - Script. The script field is case insensitive but Locale always canonicalizes to title case.
|
|
10
|
+
* format: [a-zA-Z]{4}. e.g. Hans in zh-Hans-CN : https://developer.android.com/reference/java/util/Locale.html
|
|
11
11
|
*/
|
|
12
|
-
export function
|
|
12
|
+
export function setDeviceLocale(this: import("../client").SettingsApp, language: string, country: string, script?: string | null | undefined): Promise<void>;
|
|
13
13
|
//# sourceMappingURL=locale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../../lib/commands/locale.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../../lib/commands/locale.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;GAUG;AACH,iFAPW,MAAM,WAEN,MAAM,qDAqChB"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
6
|
+
exports.setDeviceLocale = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const logger_js_1 = require("../logger.js");
|
|
9
|
+
const bluebird_1 = __importDefault(require("bluebird"));
|
|
4
10
|
const constants_js_1 = require("../constants.js");
|
|
5
11
|
/**
|
|
6
12
|
* Change the locale on the device under test. Don't need to reboot the device after changing the locale.
|
|
@@ -13,7 +19,7 @@ const constants_js_1 = require("../constants.js");
|
|
|
13
19
|
* @param {string} country - Country. e.g. US, JP
|
|
14
20
|
* @param {string?} [script=null] - Script. e.g. Hans in `zh-Hans-CN`
|
|
15
21
|
*/
|
|
16
|
-
async function
|
|
22
|
+
async function setDeviceLocaleInternal(language, country, script = null) {
|
|
17
23
|
const params = [
|
|
18
24
|
'am', 'broadcast',
|
|
19
25
|
'-a', constants_js_1.LOCALE_SETTING_ACTION,
|
|
@@ -26,6 +32,48 @@ async function setDeviceSysLocale(language, country, script = null) {
|
|
|
26
32
|
}
|
|
27
33
|
await this.adb.shell(params);
|
|
28
34
|
}
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Set the locale name of the device under test.
|
|
37
|
+
*
|
|
38
|
+
* @this {import('../client').SettingsApp}
|
|
39
|
+
* @param {string} language - Language. The language field is case insensitive, but Locale always canonicalizes to lower case.
|
|
40
|
+
* format: [a-zA-Z]{2,8}. e.g. en, ja : https://developer.android.com/reference/java/util/Locale.html
|
|
41
|
+
* @param {string} country - Country. The country (region) field is case insensitive, but Locale always canonicalizes to upper case.
|
|
42
|
+
* format: [a-zA-Z]{2} | [0-9]{3}. e.g. US, JP : https://developer.android.com/reference/java/util/Locale.html
|
|
43
|
+
* @param {string?} [script=null] - Script. The script field is case insensitive but Locale always canonicalizes to title case.
|
|
44
|
+
* format: [a-zA-Z]{4}. e.g. Hans in zh-Hans-CN : https://developer.android.com/reference/java/util/Locale.html
|
|
45
|
+
*/
|
|
46
|
+
async function setDeviceLocale(language, country, script = null) {
|
|
47
|
+
if (lodash_1.default.isEmpty(language)) {
|
|
48
|
+
throw new Error('Language name must be provided');
|
|
49
|
+
}
|
|
50
|
+
if (lodash_1.default.isEmpty(country)) {
|
|
51
|
+
throw new Error('Country name must be provided');
|
|
52
|
+
}
|
|
53
|
+
const lcLanguage = language.toLowerCase();
|
|
54
|
+
const ucCountry = country.toUpperCase();
|
|
55
|
+
if (await this.adb.getApiLevel() < 23) {
|
|
56
|
+
const [curLanguageRaw, curCountryRaw] = await bluebird_1.default.all([
|
|
57
|
+
this.adb.getDeviceLanguage(),
|
|
58
|
+
this.adb.getDeviceCountry(),
|
|
59
|
+
]);
|
|
60
|
+
const curLanguage = curLanguageRaw.toLowerCase();
|
|
61
|
+
const curCountry = curCountryRaw.toUpperCase();
|
|
62
|
+
this.log.debug(logger_js_1.LOG_PREFIX, `Current language: '${curLanguage}'; requested language: '${lcLanguage}'`);
|
|
63
|
+
this.log.debug(logger_js_1.LOG_PREFIX, `Current country: '${curCountry}'; requested country: '${ucCountry}'`);
|
|
64
|
+
if (lcLanguage !== curLanguage || ucCountry !== curCountry) {
|
|
65
|
+
await setDeviceLocaleInternal.bind(this)(lcLanguage, ucCountry);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const curLocale = await this.adb.getDeviceLocale();
|
|
70
|
+
// zh-Hans-CN : zh-CN
|
|
71
|
+
const localeCode = script ? `${lcLanguage}-${script}-${ucCountry}` : `${lcLanguage}-${ucCountry}`;
|
|
72
|
+
this.log.debug(logger_js_1.LOG_PREFIX, `Current locale: '${curLocale}'; requested locale: '${localeCode}'`);
|
|
73
|
+
if (localeCode.toLowerCase() !== curLocale.toLowerCase()) {
|
|
74
|
+
await setDeviceLocaleInternal.bind(this)(lcLanguage, ucCountry, script);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.setDeviceLocale = setDeviceLocale;
|
|
31
79
|
//# sourceMappingURL=locale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../../lib/commands/locale.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../../lib/commands/locale.js"],"names":[],"mappings":";;;;;;AAAA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AI,CAAC,GAAG,CAAC,gBAAgB,EAAE;SAC5B,CAAC,CAAC;QACH,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;QACjD,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QAC/C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAU,EAAE,sBAAsB,WAAW,2BAA2B,UAAU,GAAG,CAAC,CAAC;QACtG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAU,EAAE,qBAAqB,UAAU,0BAA0B,SAAS,GAAG,CAAC,CAAC;QAClG,IAAI,UAAU,KAAK,WAAW,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;YAC3D,MAAM,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;QAEnD,qBAAqB;QACrB,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC;QAClG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAU,EAAE,oBAAoB,SAAS,yBAAyB,UAAU,GAAG,CAAC,CAAC;QAChG,IAAI,UAAU,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;YACzD,MAAM,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;AACH,CAAC;AAhCD,0CAgCC"}
|
|
@@ -47,4 +47,12 @@
|
|
|
47
47
|
* @throws {Error} If there was an error while getting the notifications list
|
|
48
48
|
*/
|
|
49
49
|
export function getNotifications(this: import("../client").SettingsApp): Promise<Record<string, any>>;
|
|
50
|
+
/**
|
|
51
|
+
* Adjusts the necessary permissions for the
|
|
52
|
+
* Notifications retreval service for Android API level 29+
|
|
53
|
+
*
|
|
54
|
+
* @this {import('../client').SettingsApp}
|
|
55
|
+
* @returns {Promise<boolean>} If permissions adjustment has been actually made
|
|
56
|
+
*/
|
|
57
|
+
export function adjustNotificationsPermissions(this: import("../client").SettingsApp): Promise<boolean>;
|
|
50
58
|
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../lib/commands/notifications.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../lib/commands/notifications.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,yEAjCa,QAAQ,OAAO,MAAM,EAAE,GAAG,CAAC,CAAC,CAoDxC;AAED;;;;;;GAMG;AACH,uFAFa,QAAQ,OAAO,CAAC,CAa5B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNotifications = void 0;
|
|
3
|
+
exports.adjustNotificationsPermissions = exports.getNotifications = void 0;
|
|
4
4
|
const logger_1 = require("../logger");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
/**
|
|
@@ -74,4 +74,24 @@ async function getNotifications() {
|
|
|
74
74
|
}
|
|
75
75
|
exports.getNotifications = getNotifications;
|
|
76
76
|
;
|
|
77
|
+
/**
|
|
78
|
+
* Adjusts the necessary permissions for the
|
|
79
|
+
* Notifications retreval service for Android API level 29+
|
|
80
|
+
*
|
|
81
|
+
* @this {import('../client').SettingsApp}
|
|
82
|
+
* @returns {Promise<boolean>} If permissions adjustment has been actually made
|
|
83
|
+
*/
|
|
84
|
+
async function adjustNotificationsPermissions() {
|
|
85
|
+
if (await this.adb.getApiLevel() >= 29) {
|
|
86
|
+
await this.adb.shell([
|
|
87
|
+
'cmd',
|
|
88
|
+
'notification',
|
|
89
|
+
'allow_listener',
|
|
90
|
+
constants_1.SETTING_NOTIFICATIONS_LISTENER_SERVICE,
|
|
91
|
+
]);
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
exports.adjustNotificationsPermissions = adjustNotificationsPermissions;
|
|
77
97
|
//# sourceMappingURL=notifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../lib/commands/notifications.js"],"names":[],"mappings":";;;AAAA,sCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../lib/commands/notifications.js"],"names":[],"mappings":";;;AAAA,sCAAuC;AACvC,4CAGsB;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACI,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAU,EAAE,0BAA0B,CAAC,CAAC;IACvD,wDAAwD;IACxD,wDAAwD;IACxD,8DAA8D;IAC9D,WAAW;IACX,MAAM,IAAI,CAAC,cAAc,CAAC,EAAC,uBAAuB,EAAE,IAAI,EAAC,CAAC,CAAC;IAC3D,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAC5B,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,0CAA8B;SACrC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iDAAiD;YAC/D,4EAA4E;YAC5E,mBAAmB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AACtD,CAAC;AAnBD,4CAmBC;AAAA,CAAC;AAEF;;;;;;GAMG;AACI,KAAK,UAAU,8BAA8B;IAClD,IAAI,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YACnB,KAAK;YACL,cAAc;YACd,gBAAgB;YAChB,kDAAsC;SACvC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAXD,wEAWC"}
|
package/build/lib/constants.d.ts
CHANGED
|
@@ -16,10 +16,10 @@ export const LOCALE_SETTING_ACTION: "io.appium.settings.locale";
|
|
|
16
16
|
export const LOCATION_SERVICE: "io.appium.settings/.LocationService";
|
|
17
17
|
export const LOCATION_RECEIVER: "io.appium.settings/.receivers.LocationInfoReceiver";
|
|
18
18
|
export const LOCATION_RETRIEVAL_ACTION: "io.appium.settings.location";
|
|
19
|
-
export const NOTIFICATIONS_RETRIEVAL_ACTION: "io.appium.settings.notifications";
|
|
20
19
|
export const SMS_LIST_RECEIVER: "io.appium.settings/.receivers.SmsReader";
|
|
21
20
|
export const SMS_LIST_RETRIEVAL_ACTION: "io.appium.settings.sms.read";
|
|
22
21
|
export const MEDIA_SCAN_RECEIVER: "io.appium.settings/.receivers.MediaScannerReceiver";
|
|
23
22
|
export const MEDIA_SCAN_ACTION: "io.appium.settings.scan_media";
|
|
24
23
|
export const SETTING_NOTIFICATIONS_LISTENER_SERVICE: "io.appium.settings/.NLService";
|
|
24
|
+
export const NOTIFICATIONS_RETRIEVAL_ACTION: "io.appium.settings.notifications";
|
|
25
25
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../lib/constants.js"],"names":[],"mappings":"AAAA,sDAAuD;AACvD,wDAAyD;AAEzD,mFAAuF;AACvF,4EAAgF;AAEhF,yDAA6D;AAC7D,2DAA+D;AAC/D,uDAA2D;AAE3D,6GAAiH;AACjH,uEAA2E;AAC3E,6GAAiH;AACjH,kFAAsF;AAEtF,kGAAsG;AACtG,sEAA0E;AAE1E,4FAAgG;AAChG,gEAAoE;AAEpE,qEAAyE;AACzE,qFAAyF;AACzF,sEAA0E;AAE1E,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../lib/constants.js"],"names":[],"mappings":"AAAA,sDAAuD;AACvD,wDAAyD;AAEzD,mFAAuF;AACvF,4EAAgF;AAEhF,yDAA6D;AAC7D,2DAA+D;AAC/D,uDAA2D;AAE3D,6GAAiH;AACjH,uEAA2E;AAC3E,6GAAiH;AACjH,kFAAsF;AAEtF,kGAAsG;AACtG,sEAA0E;AAE1E,4FAAgG;AAChG,gEAAoE;AAEpE,qEAAyE;AACzE,qFAAyF;AACzF,sEAA0E;AAE1E,0EAA8E;AAC9E,sEAA0E;AAE1E,uFAA2F;AAC3F,gEAAoE;AAEpE,qFAAyF;AACzF,gFAAoF"}
|
package/build/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SETTING_NOTIFICATIONS_LISTENER_SERVICE = exports.MEDIA_SCAN_ACTION = exports.MEDIA_SCAN_RECEIVER = exports.SMS_LIST_RETRIEVAL_ACTION = exports.SMS_LIST_RECEIVER = exports.
|
|
3
|
+
exports.NOTIFICATIONS_RETRIEVAL_ACTION = exports.SETTING_NOTIFICATIONS_LISTENER_SERVICE = exports.MEDIA_SCAN_ACTION = exports.MEDIA_SCAN_RECEIVER = exports.SMS_LIST_RETRIEVAL_ACTION = exports.SMS_LIST_RECEIVER = exports.LOCATION_RETRIEVAL_ACTION = exports.LOCATION_RECEIVER = exports.LOCATION_SERVICE = exports.LOCALE_SETTING_ACTION = exports.LOCALE_SETTING_RECEIVER = exports.ANIMATION_SETTING_ACTION = exports.ANIMATION_SETTING_RECEIVER = exports.DATA_CONNECTION_SETTING_ACTION = exports.DATA_CONNECTION_SETTING_RECEIVER = exports.WIFI_CONNECTION_SETTING_ACTION = exports.WIFI_CONNECTION_SETTING_RECEIVER = exports.EMPTY_IME = exports.UNICODE_IME = exports.APPIUM_IME = exports.CLIPBOARD_RETRIEVAL_ACTION = exports.CLIPBOARD_RECEIVER = exports.SETTINGS_HELPER_MAIN_ACTIVITY = exports.SETTINGS_HELPER_ID = void 0;
|
|
4
4
|
exports.SETTINGS_HELPER_ID = 'io.appium.settings';
|
|
5
5
|
exports.SETTINGS_HELPER_MAIN_ACTIVITY = '.Settings';
|
|
6
6
|
exports.CLIPBOARD_RECEIVER = `${exports.SETTINGS_HELPER_ID}/.receivers.ClipboardReceiver`;
|
|
@@ -19,10 +19,10 @@ exports.LOCALE_SETTING_ACTION = `${exports.SETTINGS_HELPER_ID}.locale`;
|
|
|
19
19
|
exports.LOCATION_SERVICE = `${exports.SETTINGS_HELPER_ID}/.LocationService`;
|
|
20
20
|
exports.LOCATION_RECEIVER = `${exports.SETTINGS_HELPER_ID}/.receivers.LocationInfoReceiver`;
|
|
21
21
|
exports.LOCATION_RETRIEVAL_ACTION = `${exports.SETTINGS_HELPER_ID}.location`;
|
|
22
|
-
exports.NOTIFICATIONS_RETRIEVAL_ACTION = `${exports.SETTINGS_HELPER_ID}.notifications`;
|
|
23
22
|
exports.SMS_LIST_RECEIVER = `${exports.SETTINGS_HELPER_ID}/.receivers.SmsReader`;
|
|
24
23
|
exports.SMS_LIST_RETRIEVAL_ACTION = `${exports.SETTINGS_HELPER_ID}.sms.read`;
|
|
25
24
|
exports.MEDIA_SCAN_RECEIVER = `${exports.SETTINGS_HELPER_ID}/.receivers.MediaScannerReceiver`;
|
|
26
25
|
exports.MEDIA_SCAN_ACTION = `${exports.SETTINGS_HELPER_ID}.scan_media`;
|
|
27
26
|
exports.SETTING_NOTIFICATIONS_LISTENER_SERVICE = `${exports.SETTINGS_HELPER_ID}/.NLService`;
|
|
27
|
+
exports.NOTIFICATIONS_RETRIEVAL_ACTION = `${exports.SETTINGS_HELPER_ID}.notifications`;
|
|
28
28
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../lib/constants.js"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAC1C,QAAA,6BAA6B,GAAG,WAAW,CAAC;AAE5C,QAAA,kBAAkB,GAAG,GAAG,0BAAkB,+BAA+B,CAAC;AAC1E,QAAA,0BAA0B,GAAG,GAAG,0BAAkB,gBAAgB,CAAC;AAEnE,QAAA,UAAU,GAAG,GAAG,0BAAkB,aAAa,CAAC;AAChD,QAAA,WAAW,GAAG,GAAG,0BAAkB,cAAc,CAAC;AAClD,QAAA,SAAS,GAAG,GAAG,0BAAkB,YAAY,CAAC;AAE9C,QAAA,gCAAgC,GAAG,GAAG,0BAAkB,2CAA2C,CAAC;AACpG,QAAA,8BAA8B,GAAG,GAAG,0BAAkB,OAAO,CAAC;AAC9D,QAAA,gCAAgC,GAAG,GAAG,0BAAkB,2CAA2C,CAAC;AACpG,QAAA,8BAA8B,GAAG,GAAG,0BAAkB,kBAAkB,CAAC;AAEzE,QAAA,0BAA0B,GAAG,GAAG,0BAAkB,sCAAsC,CAAC;AACzF,QAAA,wBAAwB,GAAG,GAAG,0BAAkB,YAAY,CAAC;AAE7D,QAAA,uBAAuB,GAAG,GAAG,0BAAkB,mCAAmC,CAAC;AACnF,QAAA,qBAAqB,GAAG,GAAG,0BAAkB,SAAS,CAAC;AAEvD,QAAA,gBAAgB,GAAG,GAAG,0BAAkB,mBAAmB,CAAC;AAC5D,QAAA,iBAAiB,GAAG,GAAG,0BAAkB,kCAAkC,CAAC;AAC5E,QAAA,yBAAyB,GAAG,GAAG,0BAAkB,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A,iBAAiB,GAAG,GAAG,0BAAkB,aAAa,CAAC;AAEvD,QAAA,sCAAsC,GAAG,GAAG,0BAAkB,aAAa,CAAC;AAC5E,QAAA,8BAA8B,GAAG,GAAG,0BAAkB,gBAAgB,CAAC"}
|
package/lib/client.js
CHANGED
|
@@ -5,10 +5,10 @@ import { SETTINGS_HELPER_ID, SETTINGS_HELPER_MAIN_ACTIVITY } from './constants.j
|
|
|
5
5
|
import { setAnimationState } from './commands/animation';
|
|
6
6
|
import { getClipboard } from './commands/clipboard';
|
|
7
7
|
import { setGeoLocation, getGeoLocation, refreshGeoLocationCache } from './commands/geolocation';
|
|
8
|
-
import {
|
|
8
|
+
import { setDeviceLocale } from './commands/locale';
|
|
9
9
|
import { scanMedia } from './commands/media';
|
|
10
10
|
import { setDataState, setWifiState } from './commands/network';
|
|
11
|
-
import { getNotifications } from './commands/notifications';
|
|
11
|
+
import { getNotifications, adjustNotificationsPermissions } from './commands/notifications';
|
|
12
12
|
import { getSmsList } from './commands/sms';
|
|
13
13
|
import { performEditorAction, typeUnicode } from './commands/typing';
|
|
14
14
|
|
|
@@ -160,7 +160,7 @@ export class SettingsApp {
|
|
|
160
160
|
getGeoLocation = getGeoLocation;
|
|
161
161
|
refreshGeoLocationCache = refreshGeoLocationCache;
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
setDeviceLocale = setDeviceLocale;
|
|
164
164
|
|
|
165
165
|
scanMedia = scanMedia;
|
|
166
166
|
|
|
@@ -168,6 +168,7 @@ export class SettingsApp {
|
|
|
168
168
|
setWifiState = setWifiState;
|
|
169
169
|
|
|
170
170
|
getNotifications = getNotifications;
|
|
171
|
+
adjustNotificationsPermissions = adjustNotificationsPermissions;
|
|
171
172
|
getSmsList = getSmsList;
|
|
172
173
|
|
|
173
174
|
performEditorAction = performEditorAction;
|
package/lib/commands/locale.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { LOG_PREFIX } from '../logger.js';
|
|
3
|
+
import B from 'bluebird';
|
|
1
4
|
import { LOCALE_SETTING_ACTION, LOCALE_SETTING_RECEIVER } from '../constants.js';
|
|
2
5
|
|
|
3
6
|
/**
|
|
@@ -11,7 +14,7 @@ import { LOCALE_SETTING_ACTION, LOCALE_SETTING_RECEIVER } from '../constants.js'
|
|
|
11
14
|
* @param {string} country - Country. e.g. US, JP
|
|
12
15
|
* @param {string?} [script=null] - Script. e.g. Hans in `zh-Hans-CN`
|
|
13
16
|
*/
|
|
14
|
-
|
|
17
|
+
async function setDeviceLocaleInternal (language, country, script = null) {
|
|
15
18
|
const params = [
|
|
16
19
|
'am', 'broadcast',
|
|
17
20
|
'-a', LOCALE_SETTING_ACTION,
|
|
@@ -25,4 +28,49 @@ export async function setDeviceSysLocale (language, country, script = null) {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
await this.adb.shell(params);
|
|
28
|
-
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Set the locale name of the device under test.
|
|
35
|
+
*
|
|
36
|
+
* @this {import('../client').SettingsApp}
|
|
37
|
+
* @param {string} language - Language. The language field is case insensitive, but Locale always canonicalizes to lower case.
|
|
38
|
+
* format: [a-zA-Z]{2,8}. e.g. en, ja : https://developer.android.com/reference/java/util/Locale.html
|
|
39
|
+
* @param {string} country - Country. The country (region) field is case insensitive, but Locale always canonicalizes to upper case.
|
|
40
|
+
* format: [a-zA-Z]{2} | [0-9]{3}. e.g. US, JP : https://developer.android.com/reference/java/util/Locale.html
|
|
41
|
+
* @param {string?} [script=null] - Script. The script field is case insensitive but Locale always canonicalizes to title case.
|
|
42
|
+
* format: [a-zA-Z]{4}. e.g. Hans in zh-Hans-CN : https://developer.android.com/reference/java/util/Locale.html
|
|
43
|
+
*/
|
|
44
|
+
export async function setDeviceLocale (language, country, script = null) {
|
|
45
|
+
if (_.isEmpty(language)) {
|
|
46
|
+
throw new Error('Language name must be provided');
|
|
47
|
+
}
|
|
48
|
+
if (_.isEmpty(country)) {
|
|
49
|
+
throw new Error('Country name must be provided');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const lcLanguage = language.toLowerCase();
|
|
53
|
+
const ucCountry = country.toUpperCase();
|
|
54
|
+
if (await this.adb.getApiLevel() < 23) {
|
|
55
|
+
const [curLanguageRaw, curCountryRaw] = await B.all([
|
|
56
|
+
this.adb.getDeviceLanguage(),
|
|
57
|
+
this.adb.getDeviceCountry(),
|
|
58
|
+
]);
|
|
59
|
+
const curLanguage = curLanguageRaw.toLowerCase();
|
|
60
|
+
const curCountry = curCountryRaw.toUpperCase();
|
|
61
|
+
this.log.debug(LOG_PREFIX, `Current language: '${curLanguage}'; requested language: '${lcLanguage}'`);
|
|
62
|
+
this.log.debug(LOG_PREFIX, `Current country: '${curCountry}'; requested country: '${ucCountry}'`);
|
|
63
|
+
if (lcLanguage !== curLanguage || ucCountry !== curCountry) {
|
|
64
|
+
await setDeviceLocaleInternal.bind(this)(lcLanguage, ucCountry);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
const curLocale = await this.adb.getDeviceLocale();
|
|
68
|
+
|
|
69
|
+
// zh-Hans-CN : zh-CN
|
|
70
|
+
const localeCode = script ? `${lcLanguage}-${script}-${ucCountry}` : `${lcLanguage}-${ucCountry}`;
|
|
71
|
+
this.log.debug(LOG_PREFIX, `Current locale: '${curLocale}'; requested locale: '${localeCode}'`);
|
|
72
|
+
if (localeCode.toLowerCase() !== curLocale.toLowerCase()) {
|
|
73
|
+
await setDeviceLocaleInternal.bind(this)(lcLanguage, ucCountry, script);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { LOG_PREFIX } from '../logger';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
NOTIFICATIONS_RETRIEVAL_ACTION,
|
|
4
|
+
SETTING_NOTIFICATIONS_LISTENER_SERVICE,
|
|
5
|
+
} from '../constants';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* Retrieves Android notifications via Appium Settings helper.
|
|
@@ -69,3 +72,23 @@ export async function getNotifications () {
|
|
|
69
72
|
}
|
|
70
73
|
return this._parseJsonData(output, 'notifications');
|
|
71
74
|
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Adjusts the necessary permissions for the
|
|
78
|
+
* Notifications retreval service for Android API level 29+
|
|
79
|
+
*
|
|
80
|
+
* @this {import('../client').SettingsApp}
|
|
81
|
+
* @returns {Promise<boolean>} If permissions adjustment has been actually made
|
|
82
|
+
*/
|
|
83
|
+
export async function adjustNotificationsPermissions() {
|
|
84
|
+
if (await this.adb.getApiLevel() >= 29) {
|
|
85
|
+
await this.adb.shell([
|
|
86
|
+
'cmd',
|
|
87
|
+
'notification',
|
|
88
|
+
'allow_listener',
|
|
89
|
+
SETTING_NOTIFICATIONS_LISTENER_SERVICE,
|
|
90
|
+
]);
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
package/lib/constants.js
CHANGED
|
@@ -23,8 +23,6 @@ export const LOCATION_SERVICE = `${SETTINGS_HELPER_ID}/.LocationService`;
|
|
|
23
23
|
export const LOCATION_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.LocationInfoReceiver`;
|
|
24
24
|
export const LOCATION_RETRIEVAL_ACTION = `${SETTINGS_HELPER_ID}.location`;
|
|
25
25
|
|
|
26
|
-
export const NOTIFICATIONS_RETRIEVAL_ACTION = `${SETTINGS_HELPER_ID}.notifications`;
|
|
27
|
-
|
|
28
26
|
export const SMS_LIST_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.SmsReader`;
|
|
29
27
|
export const SMS_LIST_RETRIEVAL_ACTION = `${SETTINGS_HELPER_ID}.sms.read`;
|
|
30
28
|
|
|
@@ -32,3 +30,4 @@ export const MEDIA_SCAN_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.MediaScanne
|
|
|
32
30
|
export const MEDIA_SCAN_ACTION = `${SETTINGS_HELPER_ID}.scan_media`;
|
|
33
31
|
|
|
34
32
|
export const SETTING_NOTIFICATIONS_LISTENER_SERVICE = `${SETTINGS_HELPER_ID}/.NLService`;
|
|
33
|
+
export const NOTIFICATIONS_RETRIEVAL_ACTION = `${SETTINGS_HELPER_ID}.notifications`;
|