appium-adb 9.10.11 → 9.10.13

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.
Files changed (35) hide show
  1. package/build/index.js +1 -5
  2. package/build/lib/adb.js +1 -26
  3. package/build/lib/adb.js.map +1 -1
  4. package/build/lib/helpers.js +7 -211
  5. package/build/lib/helpers.js.map +1 -1
  6. package/build/lib/logcat.js +1 -46
  7. package/build/lib/logcat.js.map +1 -1
  8. package/build/lib/logger.js +1 -5
  9. package/build/lib/logger.js.map +1 -1
  10. package/build/lib/tools/aab-utils.js +1 -42
  11. package/build/lib/tools/aab-utils.js.map +1 -1
  12. package/build/lib/tools/adb-commands.js +6 -163
  13. package/build/lib/tools/adb-commands.js.map +1 -1
  14. package/build/lib/tools/adb-emu-commands.js +2 -66
  15. package/build/lib/tools/adb-emu-commands.js.map +1 -1
  16. package/build/lib/tools/android-manifest.js +1 -60
  17. package/build/lib/tools/android-manifest.js.map +1 -1
  18. package/build/lib/tools/apk-signing.js +1 -77
  19. package/build/lib/tools/apk-signing.js.map +1 -1
  20. package/build/lib/tools/apk-utils.js +4 -229
  21. package/build/lib/tools/apk-utils.js.map +1 -1
  22. package/build/lib/tools/apks-utils.js +1 -53
  23. package/build/lib/tools/apks-utils.js.map +1 -1
  24. package/build/lib/tools/index.js +1 -17
  25. package/build/lib/tools/index.js.map +1 -1
  26. package/build/lib/tools/keyboard-commands.js +1 -12
  27. package/build/lib/tools/keyboard-commands.js.map +1 -1
  28. package/build/lib/tools/lockmgmt.js +1 -46
  29. package/build/lib/tools/lockmgmt.js.map +1 -1
  30. package/build/lib/tools/settings-client-commands.js +3 -71
  31. package/build/lib/tools/settings-client-commands.js.map +1 -1
  32. package/build/lib/tools/system-calls.js +5 -190
  33. package/build/lib/tools/system-calls.js.map +1 -1
  34. package/lib/tools/settings-client-commands.js +2 -2
  35. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"adb-commands.js","names":["MAX_SHELL_BUFFER_LENGTH","NOT_CHANGEABLE_PERM_ERROR","IGNORED_PERM_ERRORS","MAX_PGREP_PATTERN_LEN","HIDDEN_API_POLICY_KEYS","PID_COLUMN_TITLE","PROCESS_NAME_COLUMN_TITLE","PS_TITLE_PATTERN","RegExp","MIN_API_LEVEL_WITH_PERMS_SUPPORT","methods","shellChunks","argTransformer","args","commands","cmdChunk","arg","nextCmd","_","isArray","Error","last","push","join","length","isEmpty","log","debug","JSON","stringify","lastError","cmd","shell","e","getAdbWithCorrectAdbPath","executable","path","getSdkBinaryPath","adb","initAapt","initAapt2","initZipAlign","initBundletool","binaries","bundletool","fs","which","err","getApiLevel","isInteger","_apiLevel","strOutput","getDeviceProperty","apiLevel","parseInt","trim","charCodeQ","charCodeAt","apiLevelDiff","codename","String","fromCharCode","getPlatformVersion","toLowerCase","toUpperCase","isNaN","message","info","isDeviceConnected","devices","getConnectedDevices","mkdir","remotePath","isValidClass","classString","matchComponentName","resolveLaunchableActivity","pkg","opts","preferCmd","stdout","names","parseLaunchableActivityNames","tmpRoot","tempDir","openDir","tmpApp","pullApk","apkActivity","packageAndLaunchActivityFromManifest","stack","warn","rimraf","stderr","outputFormat","EXEC_OUTPUT_FORMAT","FULL","line","split","map","forceStop","killPackage","clear","grantAllPermissions","apk","targetSdk","dumpsysOutput","targetSdkVersionUsingPKG","targetSdkVersionFromManifest","requestedPermissions","getReqPermissions","grantedPermissions","getGrantedPermissions","permissionsToGrant","difference","grantPermissions","permissions","perm","some","pattern","test","grantPermission","permission","revokePermission","cmdOutput","extractMatchingPermissions","getDeniedPermissions","getLocationProviders","getSetting","p","filter","Boolean","toggleGPSLocationProvider","enabled","setSetting","setHiddenApiPolicy","value","ignoreError","k","setDefaultHiddenApiPolicy","stopAndClear","availableIMEs","getIMEListFromOutput","enabledIMEs","enableIME","imeId","disableIME","setIME","defaultIME","engine","keyevent","keycode","code","inputText","text","originalStr","escapedText","replace","adbInputEscapePattern","every","c","includes","q","clearTextField","i","lock","isScreenLocked","timeoutMs","waitForCondition","waitMs","intervalMs","back","goToHome","getAdbPath","getScreenOrientation","getSurfaceOrientation","sendTelnetCommand","command","execEmuConsoleCommand","port","getEmulatorPort","isAirplaneModeOn","setAirplaneMode","on","broadcastAirplaneMode","privileged","ign","isWifiOn","isDataOn","setWifiAndData","wifi","data","isEmulator","util","hasValue","setWifiState","setDataState","isAnimationOn","animator_duration_scale","transition_animation_scale","window_animation_scale","setting","localPath","posix","dirname","adbExec","pull","timeout","processExists","processName","getPIDsByName","getForwardList","connections","EOL","forwardPort","systemPort","devicePort","removePortForward","getReverseList","reversePort","removePortReverse","forwardAbstractPort","ping","indexOf","restart","stopLogcat","restartAdb","waitForDevice","startLogcat","_logcatStartupParams","logcat","Logcat","debugTrace","clearDeviceLogsOnStart","startCapture","stopCapture","getLogcatLogs","getLogs","setLogcatListener","listener","removeLogcatListener","removeListener","listProcessStatus","isBoolean","_doesPsSupportAOption","getNameByPid","pid","titleMatch","exec","allTitles","pidIndex","nameOffset","pidRegex","matchedLine","items","name","_isPgrepAvailable","pgrepOutput","_canPgrepUseFullCmdLineSearch","_isPidofAvailable","shellCommand","escapeRegExp","slice","x","pids","processNameRegex","killProcessesByName","B","all","killProcessByPID","noProcessFlag","e1","broadcastProcessEnd","intent","broadcast","start","Date","now","sleep","endAndroidCoverage","instrumentProc","isRunning","stop","instrument","activity","instrumentWith","pkgActivity","androidCoverage","instrumentClass","waitPkg","waitActivity","resolve","reject","defaultArgs","concat","SubProcess","waitForActivity","property","val","setDeviceProperty","prop","getDeviceSysLanguage","getDeviceSysCountry","getDeviceSysLocale","getDeviceProductLanguage","getDeviceProductCountry","getDeviceProductLocale","getModel","getManufacturer","getScreenSize","size","getScreenDensity","density","densityNumber","setHttpProxy","proxyHost","proxyPort","proxy","isUndefined","httpProxySettins","settingKey","settingValue","deleteHttpProxy","namespace","bugreport","screenrecord","destination","options","videoSize","bitRate","timeLimit","bugReport","fullCmd","quote","runInImeContext","ime","fn","originalIme","delay","getTimeZone","listFeatures","_memoizedFeatures","memoize","curDeviceId","isStreamedInstallSupported","proto","Object","getPrototypeOf","_helpOutput","isIncrementalInstallSupported","binary","getVersion","compareVersions","version","getDeviceIdleWhitelist","output","addToDeviceIdleWhitelist","packages","pluralize"],"sources":["../../../lib/tools/adb-commands.js"],"sourcesContent":["import log from '../logger.js';\nimport {\n getIMEListFromOutput, getSurfaceOrientation, extractMatchingPermissions,\n parseLaunchableActivityNames, matchComponentName,\n} from '../helpers.js';\nimport path from 'path';\nimport _ from 'lodash';\nimport { fs, util, tempDir } from '@appium/support';\nimport { EOL } from 'os';\nimport Logcat from '../logcat';\nimport { sleep, waitForCondition } from 'asyncbox';\nimport { SubProcess } from 'teen_process';\nimport B from 'bluebird';\n\nconst MAX_SHELL_BUFFER_LENGTH = 1000;\nconst NOT_CHANGEABLE_PERM_ERROR = /not a changeable permission type/i;\nconst IGNORED_PERM_ERRORS = [\n NOT_CHANGEABLE_PERM_ERROR,\n /Unknown permission/i,\n];\nconst MAX_PGREP_PATTERN_LEN = 15;\nconst HIDDEN_API_POLICY_KEYS = [\n 'hidden_api_policy_pre_p_apps',\n 'hidden_api_policy_p_apps',\n 'hidden_api_policy'\n];\nconst PID_COLUMN_TITLE = 'PID';\nconst PROCESS_NAME_COLUMN_TITLE = 'NAME';\nconst PS_TITLE_PATTERN = new RegExp(`^(.*\\\\b${PID_COLUMN_TITLE}\\\\b.*\\\\b${PROCESS_NAME_COLUMN_TITLE}\\\\b.*)$`, 'm');\nconst MIN_API_LEVEL_WITH_PERMS_SUPPORT = 23;\n\nconst methods = {};\n\n/**\n * Creates chunks for the given arguments and executes them in `adb shell`.\n * This is faster than calling `adb shell` separately for each arg, however\n * there is a limit for a maximum length of a single adb command. that is why\n * we need all this complicated logic.\n *\n * @param {Function} argTransformer A function, that receives single argument\n * from the `args` array and transforms it into a shell command. The result\n * of the function must be an array, where each item is a part of a single command.\n * The last item of the array could be ';'. If this is not a semicolon then it is going to\n * be added automatically.\n * @param {Array<number|string>} args Array of argument values to create chunks for\n * @throws {Error} If any of the chunks returns non-zero exit code after being executed\n */\nmethods.shellChunks = async function shellChunks (argTransformer, args) {\n const commands = [];\n let cmdChunk = [];\n for (const arg of args) {\n const nextCmd = argTransformer(arg);\n if (!_.isArray(nextCmd)) {\n throw new Error('Argument transformer must result in an array');\n }\n if (_.last(nextCmd) !== ';') {\n nextCmd.push(';');\n }\n if (nextCmd.join(' ').length + cmdChunk.join(' ').length >= MAX_SHELL_BUFFER_LENGTH) {\n commands.push(cmdChunk);\n cmdChunk = [];\n }\n cmdChunk = [...cmdChunk, ...nextCmd];\n }\n if (!_.isEmpty(cmdChunk)) {\n commands.push(cmdChunk);\n }\n log.debug(`Got the following command chunks to execute: ${JSON.stringify(commands)}`);\n let lastError = null;\n for (const cmd of commands) {\n try {\n await this.shell(cmd);\n } catch (e) {\n lastError = e;\n }\n }\n if (lastError) {\n throw lastError;\n }\n};\n\n/**\n * Get the path to adb executable amd assign it\n * to this.executable.path and this.binaries.adb properties.\n *\n * @return {ADB} ADB instance.\n */\nmethods.getAdbWithCorrectAdbPath = async function getAdbWithCorrectAdbPath () {\n this.executable.path = await this.getSdkBinaryPath('adb');\n return this.adb;\n};\n\n/**\n * Get the full path to aapt tool and assign it to\n * this.binaries.aapt property\n */\nmethods.initAapt = async function initAapt () {\n await this.getSdkBinaryPath('aapt');\n};\n\n/**\n * Get the full path to aapt2 tool and assign it to\n * this.binaries.aapt2 property\n */\nmethods.initAapt2 = async function initAapt2 () {\n await this.getSdkBinaryPath('aapt2');\n};\n\n/**\n * Get the full path to zipalign tool and assign it to\n * this.binaries.zipalign property\n */\nmethods.initZipAlign = async function initZipAlign () {\n await this.getSdkBinaryPath('zipalign');\n};\n\n/**\n * Get the full path to bundletool binary and assign it to\n * this.binaries.bundletool property\n */\nmethods.initBundletool = async function initBundletool () {\n try {\n this.binaries.bundletool = await fs.which('bundletool.jar');\n } catch (err) {\n throw new Error('bundletool.jar binary is expected to be present in PATH. ' +\n 'Visit https://github.com/google/bundletool for more details.');\n }\n};\n\n/**\n * Retrieve the API level of the device under test.\n *\n * @return {number} The API level as integer number, for example 21 for\n * Android Lollipop. The result of this method is cached, so all the further\n * calls return the same value as the first one.\n */\nmethods.getApiLevel = async function getApiLevel () {\n if (!_.isInteger(this._apiLevel)) {\n try {\n const strOutput = await this.getDeviceProperty('ro.build.version.sdk');\n let apiLevel = parseInt(strOutput.trim(), 10);\n\n // Workaround for preview/beta platform API level\n const charCodeQ = 'q'.charCodeAt(0);\n // 28 is the first API Level, where Android SDK started returning letters in response to getPlatformVersion\n const apiLevelDiff = apiLevel - 28;\n const codename = String.fromCharCode(charCodeQ + apiLevelDiff);\n if (apiLevelDiff >= 0 && (await this.getPlatformVersion()).toLowerCase() === codename) {\n log.debug(`Release version is ${codename.toUpperCase()} but found API Level ${apiLevel}. Setting API Level to ${apiLevel + 1}`);\n apiLevel++;\n }\n\n this._apiLevel = apiLevel;\n log.debug(`Device API level: ${this._apiLevel}`);\n if (isNaN(this._apiLevel)) {\n throw new Error(`The actual output '${strOutput}' cannot be converted to an integer`);\n }\n } catch (e) {\n throw new Error(`Error getting device API level. Original error: ${e.message}`);\n }\n }\n return this._apiLevel;\n};\n\n/**\n * Retrieve the platform version of the device under test.\n *\n * @return {string} The platform version as a string, for example '5.0' for\n * Android Lollipop.\n */\nmethods.getPlatformVersion = async function getPlatformVersion () {\n log.info('Getting device platform version');\n try {\n return await this.getDeviceProperty('ro.build.version.release');\n } catch (e) {\n throw new Error(`Error getting device platform version. Original error: ${e.message}`);\n }\n};\n\n/**\n * Verify whether a device is connected.\n *\n * @return {boolean} True if at least one device is visible to adb.\n */\nmethods.isDeviceConnected = async function isDeviceConnected () {\n let devices = await this.getConnectedDevices();\n return devices.length > 0;\n};\n\n/**\n * Recursively create a new folder on the device under test.\n *\n * @param {string} remotePath - The new path to be created.\n * @return {string} mkdir command output.\n */\nmethods.mkdir = async function mkdir (remotePath) {\n return await this.shell(['mkdir', '-p', remotePath]);\n};\n\n/**\n * Verify whether the given argument is a\n * valid class name.\n *\n * @param {string} classString - The actual class name to be verified.\n * @return {?Array.<Match>} The result of Regexp.exec operation\n * or _null_ if no matches are found.\n */\nmethods.isValidClass = function isValidClass (classString) {\n // some.package/some.package.Activity\n return matchComponentName(classString);\n};\n\n/**\n * @typedef {Object} ResolveActivityOptions\n * @property {boolean?} preferCmd [true] Whether to prefer `cmd` tool usage for\n * launchable activity name detection. It might be useful to disable it if\n * `cmd package resolve-activity` returns 'android/com.android.internal.app.ResolverActivity',\n * which means the app has no default handler set in system settings.\n * See https://github.com/appium/appium/issues/17128 for more details.\n * This option has no effect if the target Android version is below 24 as there\n * the corresponding `cmd` subcommand is not implemented and dumpsys usage is the only\n * possible way to detect the launchable activity name.\n */\n\n/**\n * Fetches the fully qualified name of the launchable activity for the\n * given package. It is expected the package is already installed on\n * the device under test.\n *\n * @param {string} pkg - The target package identifier\n * @param {ResolveActivityOptions?} opts\n * @return {string} Fully qualified name of the launchable activity\n * @throws {Error} If there was an error while resolving the activity name\n */\nmethods.resolveLaunchableActivity = async function resolveLaunchableActivity (pkg, opts = {}) {\n const { preferCmd = true } = opts;\n if (!preferCmd || await this.getApiLevel() < 24) {\n const stdout = await this.shell(['dumpsys', 'package', pkg]);\n const names = parseLaunchableActivityNames(stdout);\n if (_.isEmpty(names)) {\n log.debug(stdout);\n throw new Error(`Unable to resolve the launchable activity of '${pkg}'. Is it installed on the device?`);\n }\n if (names.length === 1) {\n return names[0];\n }\n\n const tmpRoot = await tempDir.openDir();\n try {\n const tmpApp = await this.pullApk(pkg, tmpRoot);\n const {apkActivity} = await this.packageAndLaunchActivityFromManifest(tmpApp);\n return apkActivity;\n } catch (e) {\n log.debug(e.stack);\n log.warn(`Unable to resolve the launchable activity of '${pkg}'. ` +\n `The very first match of the dumpsys output is going to be used. ` +\n `Original error: ${e.message}`);\n return names[0];\n } finally {\n await fs.rimraf(tmpRoot);\n }\n }\n const {stdout, stderr} = await this.shell(['cmd', 'package', 'resolve-activity', '--brief', pkg], {\n outputFormat: this.EXEC_OUTPUT_FORMAT.FULL\n });\n for (const line of (stdout || '').split('\\n').map(_.trim)) {\n if (this.isValidClass(line)) {\n return line;\n }\n }\n throw new Error(`Unable to resolve the launchable activity of '${pkg}'. Original error: ${stderr || stdout}`);\n};\n\n/**\n * Force application to stop on the device under test.\n *\n * @param {string} pkg - The package name to be stopped.\n * @return {string} The output of the corresponding adb command.\n */\nmethods.forceStop = async function forceStop (pkg) {\n return await this.shell(['am', 'force-stop', pkg]);\n};\n\n/*\n * Kill application\n *\n * @param {string} pkg - The package name to be stopped.\n * @return {string} The output of the corresponding adb command.\n */\nmethods.killPackage = async function killPackage (pkg) {\n return await this.shell(['am', 'kill', pkg]);\n};\n\n/**\n * Clear the user data of the particular application on the device\n * under test.\n *\n * @param {string} pkg - The package name to be cleared.\n * @return {string} The output of the corresponding adb command.\n */\nmethods.clear = async function clear (pkg) {\n return await this.shell(['pm', 'clear', pkg]);\n};\n\n/**\n * Grant all permissions requested by the particular package.\n * This method is only useful on Android 6.0+ and for applications\n * that support components-based permissions setting.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} apk - The path to the actual apk file.\n * @throws {Error} If there was an error while granting permissions\n */\nmethods.grantAllPermissions = async function grantAllPermissions (pkg, apk) {\n const apiLevel = await this.getApiLevel();\n let targetSdk = 0;\n let dumpsysOutput = null;\n try {\n if (!apk) {\n /**\n * If apk not provided, considering apk already installed on the device\n * and fetching targetSdk using package name.\n */\n dumpsysOutput = await this.shell(['dumpsys', 'package', pkg]);\n targetSdk = await this.targetSdkVersionUsingPKG(pkg, dumpsysOutput);\n } else {\n targetSdk = await this.targetSdkVersionFromManifest(apk);\n }\n } catch (e) {\n //avoiding logging error stack, as calling library function would have logged\n log.warn(`Ran into problem getting target SDK version; ignoring...`);\n }\n if (apiLevel >= MIN_API_LEVEL_WITH_PERMS_SUPPORT && targetSdk >= MIN_API_LEVEL_WITH_PERMS_SUPPORT) {\n /**\n * If the device is running Android 6.0(API 23) or higher, and your app's target SDK is 23 or higher:\n * The app has to list the permissions in the manifest.\n * refer: https://developer.android.com/training/permissions/requesting.html\n */\n dumpsysOutput = dumpsysOutput || await this.shell(['dumpsys', 'package', pkg]);\n const requestedPermissions = await this.getReqPermissions(pkg, dumpsysOutput);\n const grantedPermissions = await this.getGrantedPermissions(pkg, dumpsysOutput);\n const permissionsToGrant = _.difference(requestedPermissions, grantedPermissions);\n if (_.isEmpty(permissionsToGrant)) {\n log.info(`${pkg} contains no permissions available for granting`);\n } else {\n await this.grantPermissions(pkg, permissionsToGrant);\n }\n } else if (targetSdk < MIN_API_LEVEL_WITH_PERMS_SUPPORT) {\n log.info(`It is only possible to grant permissions in runtime for ` +\n `apps whose targetSdkVersion in the manifest is set to ${MIN_API_LEVEL_WITH_PERMS_SUPPORT} or above. ` +\n `The current ${pkg} targetSdkVersion is ${targetSdk || 'unset'}.`);\n } else if (apiLevel < MIN_API_LEVEL_WITH_PERMS_SUPPORT) {\n log.info(`The device's OS API level is ${apiLevel}. ` +\n `It is only possible to grant permissions on devices running Android 6 or above.`);\n }\n};\n\n/**\n * Grant multiple permissions for the particular package.\n * This call is more performant than `grantPermission` one, since it combines\n * multiple `adb shell` calls into a single command.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {Array<string>} permissions - The list of permissions to be granted.\n * @throws {Error} If there was an error while changing permissions.\n */\nmethods.grantPermissions = async function grantPermissions (pkg, permissions) {\n // As it consumes more time for granting each permission,\n // trying to grant all permission by forming equivalent command.\n // Also, it is necessary to split long commands into chunks, since the maximum length of\n // adb shell buffer is limited\n log.debug(`Granting permissions ${JSON.stringify(permissions)} to '${pkg}'`);\n try {\n await this.shellChunks((perm) => ['pm', 'grant', pkg, perm], permissions);\n } catch (e) {\n if (!IGNORED_PERM_ERRORS.some((pattern) => pattern.test(e.stderr || e.message))) {\n throw e;\n }\n }\n};\n\n/**\n * Grant single permission for the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} permission - The full name of the permission to be granted.\n * @throws {Error} If there was an error while changing permissions.\n */\nmethods.grantPermission = async function grantPermission (pkg, permission) {\n try {\n await this.shell(['pm', 'grant', pkg, permission]);\n } catch (e) {\n if (!NOT_CHANGEABLE_PERM_ERROR.test(e.stderr || e.message)) {\n throw e;\n }\n }\n};\n\n/**\n * Revoke single permission from the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} permission - The full name of the permission to be revoked.\n * @throws {Error} If there was an error while changing permissions.\n */\nmethods.revokePermission = async function revokePermission (pkg, permission) {\n try {\n await this.shell(['pm', 'revoke', pkg, permission]);\n } catch (e) {\n if (!NOT_CHANGEABLE_PERM_ERROR.test(e.stderr || e.message)) {\n throw e;\n }\n }\n};\n\n/**\n * Retrieve the list of granted permissions for the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} cmdOutput [null] - Optional parameter containing command output of\n * _dumpsys package_ command. It may speed up the method execution.\n * @return {Array<String>} The list of granted permissions or an empty list.\n * @throws {Error} If there was an error while changing permissions.\n */\nmethods.getGrantedPermissions = async function getGrantedPermissions (pkg, cmdOutput = null) {\n log.debug('Retrieving granted permissions');\n const stdout = cmdOutput || await this.shell(['dumpsys', 'package', pkg]);\n return extractMatchingPermissions(stdout, ['install', 'runtime'], true);\n};\n\n/**\n * Retrieve the list of denied permissions for the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} cmdOutput [null] - Optional parameter containing command output of\n * _dumpsys package_ command. It may speed up the method execution.\n * @return {Array<String>} The list of denied permissions or an empty list.\n */\nmethods.getDeniedPermissions = async function getDeniedPermissions (pkg, cmdOutput = null) {\n log.debug('Retrieving denied permissions');\n const stdout = cmdOutput || await this.shell(['dumpsys', 'package', pkg]);\n return extractMatchingPermissions(stdout, ['install', 'runtime'], false);\n};\n\n/**\n * Retrieve the list of requested permissions for the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} cmdOutput [null] - Optional parameter containing command output of\n * _dumpsys package_ command. It may speed up the method execution.\n * @return {Array<String>} The list of requested permissions or an empty list.\n */\nmethods.getReqPermissions = async function getReqPermissions (pkg, cmdOutput = null) {\n log.debug('Retrieving requested permissions');\n const stdout = cmdOutput || await this.shell(['dumpsys', 'package', pkg]);\n return extractMatchingPermissions(stdout, ['requested']);\n};\n\n/**\n * Retrieve the list of location providers for the device under test.\n *\n * @return {Array.<String>} The list of available location providers or an empty list.\n */\nmethods.getLocationProviders = async function getLocationProviders () {\n let stdout = await this.getSetting('secure', 'location_providers_allowed');\n return stdout.trim().split(',')\n .map((p) => p.trim())\n .filter(Boolean);\n};\n\n/**\n * Toggle the state of GPS location provider.\n *\n * @param {boolean} enabled - Whether to enable (true) or disable (false) the GPS provider.\n */\nmethods.toggleGPSLocationProvider = async function toggleGPSLocationProvider (enabled) {\n await this.setSetting('secure', 'location_providers_allowed', `${enabled ? '+' : '-'}gps`);\n};\n\n/**\n * Set hidden api policy to manage access to non-SDK APIs.\n * https://developer.android.com/preview/restrictions-non-sdk-interfaces\n *\n * @param {number|string} value - The API enforcement policy.\n * For Android P\n * 0: Disable non-SDK API usage detection. This will also disable logging, and also break the strict mode API,\n * detectNonSdkApiUsage(). Not recommended.\n * 1: \"Just warn\" - permit access to all non-SDK APIs, but keep warnings in the log.\n * The strict mode API will keep working.\n * 2: Disallow usage of dark grey and black listed APIs.\n * 3: Disallow usage of blacklisted APIs, but allow usage of dark grey listed APIs.\n *\n * For Android Q\n * https://developer.android.com/preview/non-sdk-q#enable-non-sdk-access\n * 0: Disable all detection of non-SDK interfaces. Using this setting disables all log messages for non-SDK interface usage\n * and prevents you from testing your app using the StrictMode API. This setting is not recommended.\n * 1: Enable access to all non-SDK interfaces, but print log messages with warnings for any non-SDK interface usage.\n * Using this setting also allows you to test your app using the StrictMode API.\n * 2: Disallow usage of non-SDK interfaces that belong to either the black list\n * or to a restricted greylist for your target API level.\n *\n * @param {boolean} ignoreError [false] Whether to ignore an exception in 'adb shell settings put global' command\n * @throws {error} If there was an error and ignoreError was true while executing 'adb shell settings put global'\n * command on the device under test.\n */\nmethods.setHiddenApiPolicy = async function setHiddenApiPolicy (value, ignoreError = false) {\n try {\n await this.shell(HIDDEN_API_POLICY_KEYS.map((k) => `settings put global ${k} ${value}`).join(';'));\n } catch (e) {\n if (!ignoreError) {\n throw e;\n }\n log.info(`Failed to set setting keys '${HIDDEN_API_POLICY_KEYS}' to '${value}'. Original error: ${e.message}`);\n }\n};\n\n/**\n * Reset access to non-SDK APIs to its default setting.\n * https://developer.android.com/preview/restrictions-non-sdk-interfaces\n *\n * @param {boolean} ignoreError [false] Whether to ignore an exception in 'adb shell settings delete global' command\n * @throws {error} If there was an error and ignoreError was true while executing 'adb shell settings delete global'\n * command on the device under test.\n */\nmethods.setDefaultHiddenApiPolicy = async function setDefaultHiddenApiPolicy (ignoreError = false) {\n try {\n await this.shell(HIDDEN_API_POLICY_KEYS.map((k) => `settings delete global ${k}`).join(';'));\n } catch (e) {\n if (!ignoreError) {\n throw e;\n }\n log.info(`Failed to delete keys '${HIDDEN_API_POLICY_KEYS}'. Original error: ${e.message}`);\n }\n};\n\n/**\n * Stop the particular package if it is running and clears its application data.\n *\n * @param {string} pkg - The package name to be processed.\n */\nmethods.stopAndClear = async function stopAndClear (pkg) {\n try {\n await this.forceStop(pkg);\n await this.clear(pkg);\n } catch (e) {\n throw new Error(`Cannot stop and clear ${pkg}. Original error: ${e.message}`);\n }\n};\n\n/**\n * Retrieve the list of available input methods (IMEs) for the device under test.\n *\n * @return {Array.<String>} The list of IME names or an empty list.\n */\nmethods.availableIMEs = async function availableIMEs () {\n try {\n return getIMEListFromOutput(await this.shell(['ime', 'list', '-a']));\n } catch (e) {\n throw new Error(`Error getting available IME's. Original error: ${e.message}`);\n }\n};\n\n/**\n * Retrieve the list of enabled input methods (IMEs) for the device under test.\n *\n * @return {Array.<String>} The list of enabled IME names or an empty list.\n */\nmethods.enabledIMEs = async function enabledIMEs () {\n try {\n return getIMEListFromOutput(await this.shell(['ime', 'list']));\n } catch (e) {\n throw new Error(`Error getting enabled IME's. Original error: ${e.message}`);\n }\n};\n\n/**\n * Enable the particular input method on the device under test.\n *\n * @param {string} imeId - One of existing IME ids.\n */\nmethods.enableIME = async function enableIME (imeId) {\n await this.shell(['ime', 'enable', imeId]);\n};\n\n/**\n * Disable the particular input method on the device under test.\n *\n * @param {string} imeId - One of existing IME ids.\n */\nmethods.disableIME = async function disableIME (imeId) {\n await this.shell(['ime', 'disable', imeId]);\n};\n\n/**\n * Set the particular input method on the device under test.\n *\n * @param {string} imeId - One of existing IME ids.\n */\nmethods.setIME = async function setIME (imeId) {\n await this.shell(['ime', 'set', imeId]);\n};\n\n/**\n * Get the default input method on the device under test.\n *\n * @return {?string} The name of the default input method\n */\nmethods.defaultIME = async function defaultIME () {\n try {\n let engine = await this.getSetting('secure', 'default_input_method');\n if (engine === 'null') {\n return null;\n }\n return engine.trim();\n } catch (e) {\n throw new Error(`Error getting default IME. Original error: ${e.message}`);\n }\n};\n\n/**\n * Send the particular keycode to the device under test.\n *\n * @param {string|number} keycode - The actual key code to be sent.\n */\nmethods.keyevent = async function keyevent (keycode) {\n // keycode must be an int.\n let code = parseInt(keycode, 10);\n await this.shell(['input', 'keyevent', code]);\n};\n\n/**\n * Send the particular text or a number to the device under test.\n * The text gets properly escaped before being passed to ADB.\n * Noop if the text is empty.\n *\n * @param {string|number} text - The actual text to be sent.\n * @throws {Error} If it is impossible to escape the given string\n */\nmethods.inputText = async function inputText (text) {\n if (text === '') {\n return;\n }\n\n const originalStr = `${text}`;\n const escapedText = originalStr.replace(/\\$/g, '\\\\$').replace(/ /g, '%s');\n let args = ['input', 'text', originalStr];\n // https://stackoverflow.com/questions/25791423/adb-shell-input-text-does-not-take-ampersand-character/25791498\n const adbInputEscapePattern = /[()<>|;&*\\\\~^\"']/g;\n if (escapedText !== originalStr || adbInputEscapePattern.test(originalStr)) {\n if (_.every(['\"', `'`], (c) => originalStr.includes(c))) {\n throw new Error(\n `Did not know how to escape a string that contains both types of quotes (\" and ')`\n );\n }\n const q = originalStr.includes('\"') ? `'` : '\"';\n args = [`input text ${q}${escapedText}${q}`];\n }\n await this.shell(args);\n};\n\n/**\n * Clear the active text field on the device under test by sending\n * special keyevents to it.\n *\n * @param {number} length [100] - The maximum length of the text in the field to be cleared.\n */\nmethods.clearTextField = async function clearTextField (length = 100) {\n // assumes that the EditText field already has focus\n log.debug(`Clearing up to ${length} characters`);\n if (length === 0) {\n return;\n }\n let args = ['input', 'keyevent'];\n for (let i = 0; i < length; i++) {\n // we cannot know where the cursor is in the text field, so delete both before\n // and after so that we get rid of everything\n // https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DEL\n // https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_FORWARD_DEL\n args.push('67', '112');\n }\n await this.shell(args);\n};\n\n/**\n * Send the special keycode to the device under test in order to lock it.\n */\nmethods.lock = async function lock () {\n if (await this.isScreenLocked()) {\n log.debug('Screen is already locked. Doing nothing.');\n return;\n }\n log.debug('Pressing the KEYCODE_POWER button to lock screen');\n await this.keyevent(26);\n\n const timeoutMs = 5000;\n try {\n await waitForCondition(async () => await this.isScreenLocked(), {\n waitMs: timeoutMs,\n intervalMs: 500,\n });\n } catch (e) {\n throw new Error(`The device screen is still locked after ${timeoutMs}ms timeout`);\n }\n};\n\n/**\n * Send the special keycode to the device under test in order to emulate\n * Back button tap.\n */\nmethods.back = async function back () {\n log.debug('Pressing the BACK button');\n await this.keyevent(4);\n};\n\n/**\n * Send the special keycode to the device under test in order to emulate\n * Home button tap.\n */\nmethods.goToHome = async function goToHome () {\n log.debug('Pressing the HOME button');\n await this.keyevent(3);\n};\n\n/**\n * @return {string} the actual path to adb executable.\n */\nmethods.getAdbPath = function getAdbPath () {\n return this.executable.path;\n};\n\n/**\n * Retrieve current screen orientation of the device under test.\n *\n * @return {number} The current orientation encoded as an integer number.\n */\nmethods.getScreenOrientation = async function getScreenOrientation () {\n let stdout = await this.shell(['dumpsys', 'input']);\n return getSurfaceOrientation(stdout);\n};\n\n/**\n * Send an arbitrary Telnet command to the device under test.\n *\n * @param {string} command - The command to be sent.\n *\n * @return {string} The actual output of the given command.\n */\nmethods.sendTelnetCommand = async function sendTelnetCommand (command) {\n return await this.execEmuConsoleCommand(command, {port: await this.getEmulatorPort()});\n};\n\n/**\n * Check the state of Airplane mode on the device under test.\n *\n * @return {boolean} True if Airplane mode is enabled.\n */\nmethods.isAirplaneModeOn = async function isAirplaneModeOn () {\n let stdout = await this.getSetting('global', 'airplane_mode_on');\n return parseInt(stdout, 10) !== 0;\n};\n\n/**\n * Change the state of Airplane mode in Settings on the device under test.\n *\n * @param {boolean} on - True to enable the Airplane mode in Settings and false to disable it.\n */\nmethods.setAirplaneMode = async function setAirplaneMode (on) {\n await this.setSetting('global', 'airplane_mode_on', on ? 1 : 0);\n};\n\n/**\n * Broadcast the state of Airplane mode on the device under test.\n * This method should be called after {@link #setAirplaneMode}, otherwise\n * the mode change is not going to be applied for the device.\n *\n * @param {boolean} on - True to broadcast enable and false to broadcast disable.\n */\nmethods.broadcastAirplaneMode = async function broadcastAirplaneMode (on) {\n const args = [\n 'am', 'broadcast',\n '-a', 'android.intent.action.AIRPLANE_MODE',\n '--ez', 'state', on ? 'true' : 'false',\n ];\n try {\n await this.shell(args);\n } catch (e) {\n // https://github.com/appium/appium/issues/17422\n if (_.includes(e.stderr, 'SecurityException')) {\n try {\n await this.shell(args, {privileged: true});\n return;\n } catch (ign) {}\n }\n throw e;\n }\n};\n\n/**\n * Check the state of WiFi on the device under test.\n *\n * @return {boolean} True if WiFi is enabled.\n */\nmethods.isWifiOn = async function isWifiOn () {\n let stdout = await this.getSetting('global', 'wifi_on');\n return (parseInt(stdout, 10) !== 0);\n};\n\n/**\n * Check the state of Data transfer on the device under test.\n *\n * @return {boolean} True if Data transfer is enabled.\n */\nmethods.isDataOn = async function isDataOn () {\n let stdout = await this.getSetting('global', 'mobile_data');\n return (parseInt(stdout, 10) !== 0);\n};\n\n/**\n * Change the state of WiFi and/or Data transfer on the device under test.\n *\n * @param {boolean} wifi - True to enable and false to disable WiFi.\n * @param {boolean} data - True to enable and false to disable Data transfer.\n * @param {boolean} isEmulator [false] - Set it to true if the device under test\n * is an emulator rather than a real device.\n */\nmethods.setWifiAndData = async function setWifiAndData ({wifi, data}, isEmulator = false) {\n if (util.hasValue(wifi)) {\n await this.setWifiState(wifi, isEmulator);\n }\n if (util.hasValue(data)) {\n await this.setDataState(data, isEmulator);\n }\n};\n\n/**\n * Check the state of animation on the device under test.\n *\n * @return {boolean} True if at least one of animation scale settings\n * is not equal to '0.0'.\n */\nmethods.isAnimationOn = async function isAnimationOn () {\n let animator_duration_scale = await this.getSetting('global', 'animator_duration_scale');\n let transition_animation_scale = await this.getSetting('global', 'transition_animation_scale');\n let window_animation_scale = await this.getSetting('global', 'window_animation_scale');\n return _.some([animator_duration_scale, transition_animation_scale, window_animation_scale],\n (setting) => setting !== '0.0');\n};\n\n/**\n * Forcefully recursively remove a path on the device under test.\n * Be careful while calling this method.\n *\n * @param {string} path - The path to be removed recursively.\n */\nmethods.rimraf = async function rimraf (path) {\n await this.shell(['rm', '-rf', path]);\n};\n\n/**\n * Send a file to the device under test.\n *\n * @param {string} localPath - The path to the file on the local file system.\n * @param {string} remotePath - The destination path on the remote device.\n * @param {object} opts - Additional options mapping. See\n * https://github.com/appium/node-teen_process,\n * _exec_ method options, for more information about available\n * options.\n */\nmethods.push = async function push (localPath, remotePath, opts) {\n await this.mkdir(path.posix.dirname(remotePath));\n await this.adbExec(['push', localPath, remotePath], opts);\n};\n\n/**\n * Receive a file from the device under test.\n *\n * @param {string} remotePath - The source path on the remote device.\n * @param {string} localPath - The destination path to the file on the local file system.\n * @param {object} opts - Additional options mapping. See\n * https://github.com/appium/node-teen_process,\n * _exec_ method options, for more information about available\n * options.\n */\nmethods.pull = async function pull (remotePath, localPath, opts = {}) {\n // pull folder can take more time, increasing time out to 60 secs\n await this.adbExec(['pull', remotePath, localPath], {...opts, timeout: opts.timeout ?? 60000});\n};\n\n/**\n * Check whether the process with the particular name is running on the device\n * under test.\n *\n * @param {string} processName - The name of the process to be checked.\n * @return {boolean} True if the given process is running.\n * @throws {Error} If the given process name is not a valid class name.\n */\nmethods.processExists = async function processExists (processName) {\n return !_.isEmpty(await this.getPIDsByName(processName));\n};\n\n/**\n * Get TCP port forwarding with adb on the device under test.\n * @return {Array.<String>} The output of the corresponding adb command. An array contains each forwarding line of output\n */\nmethods.getForwardList = async function getForwardList () {\n log.debug(`List forwarding ports`);\n const connections = await this.adbExec(['forward', '--list']);\n return connections.split(EOL).filter((line) => Boolean(line.trim()));\n};\n\n/**\n * Setup TCP port forwarding with adb on the device under test.\n *\n * @param {string|number} systemPort - The number of the local system port.\n * @param {string|number} devicePort - The number of the remote device port.\n */\nmethods.forwardPort = async function forwardPort (systemPort, devicePort) {\n log.debug(`Forwarding system: ${systemPort} to device: ${devicePort}`);\n await this.adbExec(['forward', `tcp:${systemPort}`, `tcp:${devicePort}`]);\n};\n\n/**\n * Remove TCP port forwarding with adb on the device under test. The forwarding\n * for the given port should be setup with {@link #forwardPort} first.\n *\n * @param {string|number} systemPort - The number of the local system port\n * to remove forwarding on.\n */\nmethods.removePortForward = async function removePortForward (systemPort) {\n log.debug(`Removing forwarded port socket connection: ${systemPort} `);\n await this.adbExec(['forward', `--remove`, `tcp:${systemPort}`]);\n};\n\n/**\n * Get TCP port forwarding with adb on the device under test.\n * @return {Array.<String>} The output of the corresponding adb command. An array contains each forwarding line of output\n */\nmethods.getReverseList = async function getReverseList () {\n log.debug(`List reverse forwarding ports`);\n const connections = await this.adbExec(['reverse', '--list']);\n return connections.split(EOL).filter((line) => Boolean(line.trim()));\n};\n\n/**\n * Setup TCP port forwarding with adb on the device under test.\n * Only available for API 21+.\n *\n * @param {string|number} devicePort - The number of the remote device port.\n * @param {string|number} systemPort - The number of the local system port.\n */\nmethods.reversePort = async function reversePort (devicePort, systemPort) {\n log.debug(`Forwarding device: ${devicePort} to system: ${systemPort}`);\n await this.adbExec(['reverse', `tcp:${devicePort}`, `tcp:${systemPort}`]);\n};\n\n/**\n * Remove TCP port forwarding with adb on the device under test. The forwarding\n * for the given port should be setup with {@link #forwardPort} first.\n *\n * @param {string|number} devicePort - The number of the remote device port\n * to remove forwarding on.\n */\nmethods.removePortReverse = async function removePortReverse (devicePort) {\n log.debug(`Removing reverse forwarded port socket connection: ${devicePort} `);\n await this.adbExec(['reverse', `--remove`, `tcp:${devicePort}`]);\n};\n\n/**\n * Setup TCP port forwarding with adb on the device under test. The difference\n * between {@link #forwardPort} is that this method does setup for an abstract\n * local port.\n *\n * @param {string|number} systemPort - The number of the local system port.\n * @param {string|number} devicePort - The number of the remote device port.\n */\nmethods.forwardAbstractPort = async function forwardAbstractPort (systemPort, devicePort) {\n log.debug(`Forwarding system: ${systemPort} to abstract device: ${devicePort}`);\n await this.adbExec(['forward', `tcp:${systemPort}`, `localabstract:${devicePort}`]);\n};\n\n/**\n * Execute ping shell command on the device under test.\n *\n * @return {boolean} True if the command output contains 'ping' substring.\n * @throws {error} If there was an error while executing 'ping' command on the\n * device under test.\n */\nmethods.ping = async function ping () {\n let stdout = await this.shell(['echo', 'ping']);\n if (stdout.indexOf('ping') === 0) {\n return true;\n }\n throw new Error(`ADB ping failed, returned ${stdout}`);\n};\n\n/**\n * Restart the device under test using adb commands.\n *\n * @throws {error} If start fails.\n */\nmethods.restart = async function restart () {\n try {\n await this.stopLogcat();\n await this.restartAdb();\n await this.waitForDevice(60);\n await this.startLogcat(this._logcatStartupParams);\n } catch (e) {\n throw new Error(`Restart failed. Original error: ${e.message}`);\n }\n};\n\n/**\n * @typedef {Object} LogcatOpts\n * @property {string} format The log print format, where <format> is one of:\n * brief process tag thread raw time threadtime long\n * `threadtime` is the default value.\n * @property {Array<string>} filterSpecs Series of <tag>[:priority]\n * where <tag> is a log component tag (or * for all) and priority is:\n * V Verbose\n * D Debug\n * I Info\n * W Warn\n * E Error\n * F Fatal\n * S Silent (supress all output)\n *\n * '*' means '*:d' and <tag> by itself means <tag>:v\n *\n * If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS.\n * If no filterspec is found, filter defaults to '*:I'\n */\n\n/**\n * Start the logcat process to gather logs.\n *\n * @param {?LogcatOpts} opts\n * @throws {Error} If restart fails.\n */\nmethods.startLogcat = async function startLogcat (opts = {}) {\n if (!_.isEmpty(this.logcat)) {\n throw new Error(\"Trying to start logcat capture but it's already started!\");\n }\n\n this.logcat = new Logcat({\n adb: this.executable,\n debug: false,\n debugTrace: false,\n clearDeviceLogsOnStart: !!this.clearDeviceLogsOnStart,\n });\n await this.logcat.startCapture(opts);\n this._logcatStartupParams = opts;\n};\n\n/**\n * Stop the active logcat process which gathers logs.\n * The call will be ignored if no logcat process is running.\n */\nmethods.stopLogcat = async function stopLogcat () {\n if (_.isEmpty(this.logcat)) {\n return;\n }\n try {\n await this.logcat.stopCapture();\n } finally {\n this.logcat = null;\n }\n};\n\n/**\n * Retrieve the output from the currently running logcat process.\n * The logcat process should be executed by {2link #startLogcat} method.\n *\n * @return {string} The collected logcat output.\n * @throws {Error} If logcat process is not running.\n */\nmethods.getLogcatLogs = function getLogcatLogs () {\n if (_.isEmpty(this.logcat)) {\n throw new Error(\"Can't get logcat logs since logcat hasn't started\");\n }\n return this.logcat.getLogs();\n};\n\n/**\n * Set the callback for the logcat output event.\n *\n * @param {Function} listener - The listener function, which accepts one argument. The argument is\n * a log record object with `timestamp`, `level` and `message` properties.\n * @throws {Error} If logcat process is not running.\n */\nmethods.setLogcatListener = function setLogcatListener (listener) {\n if (_.isEmpty(this.logcat)) {\n throw new Error(\"Logcat process hasn't been started\");\n }\n this.logcat.on('output', listener);\n};\n\n/**\n * Removes the previously set callback for the logcat output event.\n *\n * @param {Function} listener - The listener function, which has been previously\n * passed to `setLogcatListener`\n * @throws {Error} If logcat process is not running.\n */\nmethods.removeLogcatListener = function removeLogcatListener (listener) {\n if (_.isEmpty(this.logcat)) {\n throw new Error(\"Logcat process hasn't been started\");\n }\n this.logcat.removeListener('output', listener);\n};\n\n/**\n * At some point of time Google has changed the default `ps` behaviour, so it only\n * lists processes that belong to the current shell user rather to all\n * users. It is necessary to execute ps with -A command line argument\n * to mimic the previous behaviour.\n *\n * @returns {string} the output of `ps` command where all processes are included\n */\nmethods.listProcessStatus = async function listProcessStatus () {\n if (!_.isBoolean(this._doesPsSupportAOption)) {\n try {\n this._doesPsSupportAOption = /^-A\\b/m.test(await this.shell(['ps', '--help']));\n } catch (e) {\n log.debug(e.stack);\n this._doesPsSupportAOption = false;\n }\n }\n return await this.shell(this._doesPsSupportAOption ? ['ps', '-A'] : ['ps']);\n};\n\n/**\n * Returns process name for the given process identifier\n *\n * @param {string|number} pid - The valid process identifier\n * @throws {Error} If the given PID is either invalid or is not present\n * in the active processes list\n * @returns {string} The process name\n */\nmethods.getNameByPid = async function getNameByPid (pid) {\n if (isNaN(pid)) {\n throw new Error(`The PID value must be a valid number. '${pid}' is given instead`);\n }\n pid = parseInt(pid, 10);\n\n const stdout = await this.listProcessStatus();\n const titleMatch = PS_TITLE_PATTERN.exec(stdout);\n if (!titleMatch) {\n log.debug(stdout);\n throw new Error(`Could not get the process name for PID '${pid}'`);\n }\n const allTitles = titleMatch[1].trim().split(/\\s+/);\n const pidIndex = allTitles.indexOf(PID_COLUMN_TITLE);\n // it might not be stable to take NAME by index, because depending on the\n // actual SDK the ps output might not contain an abbreviation for the S flag:\n // USER PID PPID VSIZE RSS WCHAN PC NAME\n // USER PID PPID VSIZE RSS WCHAN PC S NAME\n const nameOffset = allTitles.indexOf(PROCESS_NAME_COLUMN_TITLE) - allTitles.length;\n const pidRegex = new RegExp(`^(.*\\\\b${pid}\\\\b.*)$`, 'gm');\n let matchedLine;\n while ((matchedLine = pidRegex.exec(stdout))) {\n const items = matchedLine[1].trim().split(/\\s+/);\n if (parseInt(items[pidIndex], 10) === pid && items[items.length + nameOffset]) {\n return items[items.length + nameOffset];\n }\n }\n log.debug(stdout);\n throw new Error(`Could not get the process name for PID '${pid}'`);\n};\n\n/**\n * Get the list of process ids for the particular process on the device under test.\n *\n * @param {string} name - The part of process name.\n * @return {Array.<number>} The list of matched process IDs or an empty list.\n * @throws {Error} If the passed process name is not a valid one\n */\nmethods.getPIDsByName = async function getPIDsByName (name) {\n log.debug(`Getting IDs of all '${name}' processes`);\n if (!this.isValidClass(name)) {\n throw new Error(`Invalid process name: '${name}'`);\n }\n // https://github.com/appium/appium/issues/13567\n if (await this.getApiLevel() >= 23) {\n if (!_.isBoolean(this._isPgrepAvailable)) {\n // pgrep is in priority, since pidof has been reported of having bugs on some platforms\n const pgrepOutput = _.trim(await this.shell(['pgrep --help; echo $?']));\n this._isPgrepAvailable = parseInt(_.last(pgrepOutput.split(/\\s+/)), 10) === 0;\n if (this._isPgrepAvailable) {\n this._canPgrepUseFullCmdLineSearch = /^-f\\b/m.test(pgrepOutput);\n } else {\n this._isPidofAvailable = parseInt(await this.shell(['pidof --help > /dev/null; echo $?']), 10) === 0;\n }\n }\n if (this._isPgrepAvailable || this._isPidofAvailable) {\n const shellCommand = this._isPgrepAvailable\n ? (this._canPgrepUseFullCmdLineSearch\n ? ['pgrep', '-f', _.escapeRegExp(`([[:blank:]]|^)${name}([[:blank:]]|$)`)]\n // https://github.com/appium/appium/issues/13872\n : [`pgrep ^${_.escapeRegExp(name.slice(-MAX_PGREP_PATTERN_LEN))}$ ` +\n `|| pgrep ^${_.escapeRegExp(name.slice(0, MAX_PGREP_PATTERN_LEN))}$`])\n : ['pidof', name];\n try {\n return (await this.shell(shellCommand))\n .split(/\\s+/)\n .map((x) => parseInt(x, 10))\n .filter((x) => _.isInteger(x));\n } catch (e) {\n // error code 1 is returned if the utility did not find any processes\n // with the given name\n if (e.code !== 1) {\n throw new Error(`Could not extract process ID of '${name}': ${e.message}`);\n }\n if (_.includes(e.stderr || e.stdout, 'syntax error')) {\n log.warn(`Got an unexpected response from the shell interpreter: ${e.stderr || e.stdout}`);\n } else {\n return [];\n }\n }\n }\n }\n\n log.debug('Using ps-based PID detection');\n const stdout = await this.listProcessStatus();\n const titleMatch = PS_TITLE_PATTERN.exec(stdout);\n if (!titleMatch) {\n log.debug(stdout);\n throw new Error(`Could not extract PID of '${name}' from ps output`);\n }\n const allTitles = titleMatch[1].trim().split(/\\s+/);\n const pidIndex = allTitles.indexOf(PID_COLUMN_TITLE);\n const pids = [];\n const processNameRegex = new RegExp(`^(.*\\\\b\\\\d+\\\\b.*\\\\b${_.escapeRegExp(name)}\\\\b.*)$`, 'gm');\n let matchedLine;\n while ((matchedLine = processNameRegex.exec(stdout))) {\n const items = matchedLine[1].trim().split(/\\s+/);\n if (pidIndex >= allTitles.length || isNaN(items[pidIndex])) {\n log.debug(stdout);\n throw new Error(`Could not extract PID of '${name}' from '${matchedLine[1].trim()}'`);\n }\n pids.push(parseInt(items[pidIndex], 10));\n }\n return pids;\n};\n\n/**\n * Get the list of process ids for the particular process on the device under test.\n *\n * @param {string} name - The part of process name.\n * @return {Array.<number>} The list of matched process IDs or an empty list.\n */\nmethods.killProcessesByName = async function killProcessesByName (name) {\n try {\n log.debug(`Attempting to kill all ${name} processes`);\n const pids = await this.getPIDsByName(name);\n if (_.isEmpty(pids)) {\n log.info(`No '${name}' process has been found`);\n } else {\n await B.all(pids.map((p) => this.killProcessByPID(p)));\n }\n } catch (e) {\n throw new Error(`Unable to kill ${name} processes. Original error: ${e.message}`);\n }\n};\n\n/**\n * Kill the particular process on the device under test.\n * The current user is automatically switched to root if necessary in order\n * to properly kill the process.\n *\n * @param {string|number} pid - The ID of the process to be killed.\n * @throws {Error} If the process cannot be killed.\n */\nmethods.killProcessByPID = async function killProcessByPID (pid) {\n log.debug(`Attempting to kill process ${pid}`);\n const noProcessFlag = 'No such process';\n try {\n // Check if the process exists and throw an exception otherwise\n await this.shell(['kill', pid]);\n } catch (e) {\n if (_.includes(e.stderr, noProcessFlag)) {\n return;\n }\n if (!_.includes(e.stderr, 'Operation not permitted')) {\n throw e;\n }\n log.info(`Cannot kill PID ${pid} due to insufficient permissions. Retrying as root`);\n try {\n await this.shell(['kill', pid], {\n privileged: true\n });\n } catch (e1) {\n if (_.includes(e1.stderr, noProcessFlag)) {\n return;\n }\n throw e1;\n }\n }\n};\n\n/**\n * Broadcast process killing on the device under test.\n *\n * @param {string} intent - The name of the intent to broadcast to.\n * @param {string} processName - The name of the killed process.\n * @throws {error} If the process was not killed.\n */\nmethods.broadcastProcessEnd = async function broadcastProcessEnd (intent, processName) {\n // start the broadcast without waiting for it to finish.\n this.broadcast(intent);\n // wait for the process to end\n let start = Date.now();\n let timeoutMs = 40000;\n try {\n while ((Date.now() - start) < timeoutMs) {\n if (await this.processExists(processName)) {\n // cool down\n await sleep(400);\n continue;\n }\n return;\n }\n throw new Error(`Process never died within ${timeoutMs} ms`);\n } catch (e) {\n throw new Error(`Unable to broadcast process end. Original error: ${e.message}`);\n }\n};\n\n/**\n * Broadcast a message to the given intent.\n *\n * @param {string} intent - The name of the intent to broadcast to.\n * @throws {error} If intent name is not a valid class name.\n */\nmethods.broadcast = async function broadcast (intent) {\n if (!this.isValidClass(intent)) {\n throw new Error(`Invalid intent ${intent}`);\n }\n log.debug(`Broadcasting: ${intent}`);\n await this.shell(['am', 'broadcast', '-a', intent]);\n};\n\n/**\n * Kill Android instruments if they are currently running.\n */\nmethods.endAndroidCoverage = async function endAndroidCoverage () {\n if (this.instrumentProc && this.instrumentProc.isRunning) {\n await this.instrumentProc.stop();\n }\n};\n\n/**\n * Instrument the particular activity.\n *\n * @param {string} pkg - The name of the package to be instrumented.\n * @param {string} activity - The name of the main activity in this package.\n * @param {string} instrumentWith - The name of the package to instrument\n * the activity with.\n * @throws {error} If any exception is reported by adb shell.\n */\nmethods.instrument = async function instrument (pkg, activity, instrumentWith) {\n if (activity[0] !== '.') {\n pkg = '';\n }\n let pkgActivity = (pkg + activity).replace(/\\.+/g, '.'); // Fix pkg..activity error\n let stdout = await this.shell([\n 'am', 'instrument',\n '-e', 'main_activity',\n pkgActivity,\n instrumentWith,\n ]);\n if (stdout.indexOf('Exception') !== -1) {\n throw new Error(`Unknown exception during instrumentation. Original error ${stdout.split('\\n')[0]}`);\n }\n};\n\n/**\n * Collect Android coverage by instrumenting the particular activity.\n *\n * @param {string} instrumentClass - The name of the instrumentation class.\n * @param {string} waitPkg - The name of the package to be instrumented.\n * @param {string} waitActivity - The name of the main activity in this package.\n *\n * @return {promise} The promise is successfully resolved if the instrumentation starts\n * without errors.\n */\nmethods.androidCoverage = async function androidCoverage (instrumentClass, waitPkg, waitActivity) {\n if (!this.isValidClass(instrumentClass)) {\n throw new Error(`Invalid class ${instrumentClass}`);\n }\n return await new B(async (resolve, reject) => {\n let args = this.executable.defaultArgs\n .concat(['shell', 'am', 'instrument', '-e', 'coverage', 'true', '-w'])\n .concat([instrumentClass]);\n log.debug(`Collecting coverage data with: ${[this.executable.path].concat(args).join(' ')}`);\n try {\n // am instrument runs for the life of the app process.\n this.instrumentProc = new SubProcess(this.executable.path, args);\n await this.instrumentProc.start(0);\n this.instrumentProc.on('output', (stdout, stderr) => {\n if (stderr) {\n reject(new Error(`Failed to run instrumentation. Original error: ${stderr}`));\n }\n });\n await this.waitForActivity(waitPkg, waitActivity);\n resolve();\n } catch (e) {\n reject(new Error(`Android coverage failed. Original error: ${e.message}`));\n }\n });\n};\n\n/**\n * Get the particular property of the device under test.\n *\n * @param {string} property - The name of the property. This name should\n * be known to _adb shell getprop_ tool.\n *\n * @return {string} The value of the given property.\n */\nmethods.getDeviceProperty = async function getDeviceProperty (property) {\n let stdout = await this.shell(['getprop', property]);\n let val = stdout.trim();\n log.debug(`Current device property '${property}': ${val}`);\n return val;\n};\n\n/**\n * @typedef {object} setPropOpts\n * @property {boolean} privileged - Do we run setProp as a privileged command? Default true.\n */\n\n/**\n * Set the particular property of the device under test.\n *\n * @param {string} property - The name of the property. This name should\n * be known to _adb shell setprop_ tool.\n * @param {string} val - The new property value.\n * @param {setPropOpts} opts\n *\n * @throws {error} If _setprop_ utility fails to change property value.\n */\nmethods.setDeviceProperty = async function setDeviceProperty (prop, val, opts = {}) {\n const {privileged = true} = opts;\n log.debug(`Setting device property '${prop}' to '${val}'`);\n await this.shell(['setprop', prop, val], {\n privileged,\n });\n};\n\n/**\n * @return {string} Current system language on the device under test.\n */\nmethods.getDeviceSysLanguage = async function getDeviceSysLanguage () {\n return await this.getDeviceProperty('persist.sys.language');\n};\n\n/**\n * @return {string} Current country name on the device under test.\n */\nmethods.getDeviceSysCountry = async function getDeviceSysCountry () {\n return await this.getDeviceProperty('persist.sys.country');\n};\n\n/**\n * @return {string} Current system locale name on the device under test.\n */\nmethods.getDeviceSysLocale = async function getDeviceSysLocale () {\n return await this.getDeviceProperty('persist.sys.locale');\n};\n\n/**\n * @return {string} Current product language name on the device under test.\n */\nmethods.getDeviceProductLanguage = async function getDeviceProductLanguage () {\n return await this.getDeviceProperty('ro.product.locale.language');\n};\n\n/**\n * @return {string} Current product country name on the device under test.\n */\nmethods.getDeviceProductCountry = async function getDeviceProductCountry () {\n return await this.getDeviceProperty('ro.product.locale.region');\n};\n\n/**\n * @return {string} Current product locale name on the device under test.\n */\nmethods.getDeviceProductLocale = async function getDeviceProductLocale () {\n return await this.getDeviceProperty('ro.product.locale');\n};\n\n/**\n * @return {string} The model name of the device under test.\n */\nmethods.getModel = async function getModel () {\n return await this.getDeviceProperty('ro.product.model');\n};\n\n/**\n * @return {string} The manufacturer name of the device under test.\n */\nmethods.getManufacturer = async function getManufacturer () {\n return await this.getDeviceProperty('ro.product.manufacturer');\n};\n\n/**\n * Get the current screen size.\n *\n * @return {string} Device screen size as string in format 'WxH' or\n * _null_ if it cannot be determined.\n */\nmethods.getScreenSize = async function getScreenSize () {\n let stdout = await this.shell(['wm', 'size']);\n let size = new RegExp(/Physical size: ([^\\r?\\n]+)*/g).exec(stdout);\n if (size && size.length >= 2) {\n return size[1].trim();\n }\n return null;\n};\n\n/**\n * Get the current screen density in dpi\n *\n * @return {?number} Device screen density as a number or _null_ if it\n * cannot be determined\n */\nmethods.getScreenDensity = async function getScreenDensity () {\n let stdout = await this.shell(['wm', 'density']);\n let density = new RegExp(/Physical density: ([^\\r?\\n]+)*/g).exec(stdout);\n if (density && density.length >= 2) {\n let densityNumber = parseInt(density[1].trim(), 10);\n return isNaN(densityNumber) ? null : densityNumber;\n }\n return null;\n};\n\n/**\n * Setup HTTP proxy in device global settings.\n * Read https://android.googlesource.com/platform/frameworks/base/+/android-9.0.0_r21/core/java/android/provider/Settings.java for each property\n *\n * @param {string} proxyHost - The host name of the proxy.\n * @param {string|number} proxyPort - The port number to be set.\n */\nmethods.setHttpProxy = async function setHttpProxy (proxyHost, proxyPort) {\n let proxy = `${proxyHost}:${proxyPort}`;\n if (_.isUndefined(proxyHost)) {\n throw new Error(`Call to setHttpProxy method with undefined proxy_host: ${proxy}`);\n }\n if (_.isUndefined(proxyPort)) {\n throw new Error(`Call to setHttpProxy method with undefined proxy_port ${proxy}`);\n }\n\n const httpProxySettins = [\n ['http_proxy', proxy],\n ['global_http_proxy_host', proxyHost],\n ['global_http_proxy_port', proxyPort]\n ];\n for (const [settingKey, settingValue] of httpProxySettins) {\n await this.setSetting('global', settingKey, settingValue);\n }\n};\n\n/**\n * Delete HTTP proxy in device global settings.\n * Rebooting the test device is necessary to apply the change.\n */\nmethods.deleteHttpProxy = async function deleteHttpProxy () {\n const httpProxySettins = [\n 'http_proxy',\n 'global_http_proxy_host',\n 'global_http_proxy_port',\n 'global_http_proxy_exclusion_list' // `global_http_proxy_exclusion_list=` was generated by `settings global htto_proxy xxxx`\n ];\n for (const setting of httpProxySettins) {\n await this.shell(['settings', 'delete', 'global', setting]);\n }\n};\n\n/**\n * Set device property.\n * [android.provider.Settings]{@link https://developer.android.com/reference/android/provider/Settings.html}\n *\n * @param {string} namespace - one of {system, secure, global}, case-insensitive.\n * @param {string} setting - property name.\n * @param {string|number} value - property value.\n * @return {string} command output.\n */\nmethods.setSetting = async function setSetting (namespace, setting, value) {\n return await this.shell(['settings', 'put', namespace, setting, value]);\n};\n\n/**\n * Get device property.\n * [android.provider.Settings]{@link https://developer.android.com/reference/android/provider/Settings.html}\n *\n * @param {string} namespace - one of {system, secure, global}, case-insensitive.\n * @param {string} setting - property name.\n * @return {string} property value.\n */\nmethods.getSetting = async function getSetting (namespace, setting) {\n return await this.shell(['settings', 'get', namespace, setting]);\n};\n\n/**\n * Retrieve the `adb bugreport` command output. This\n * operation may take up to several minutes.\n *\n * @param {?number} timeout [120000] - Command timeout in milliseconds\n * @returns {string} Command stdout\n */\nmethods.bugreport = async function bugreport (timeout = 120000) {\n return await this.adbExec(['bugreport'], {timeout});\n};\n\n/**\n * @typedef {Object} ScreenrecordOptions\n * @property {?string} videoSize - The format is widthxheight.\n * The default value is the device's native display resolution (if supported),\n * 1280x720 if not. For best results,\n * use a size supported by your device's Advanced Video Coding (AVC) encoder.\n * For example, \"1280x720\"\n * @property {?boolean} bugReport - Set it to `true` in order to display additional information on the video overlay,\n * such as a timestamp, that is helpful in videos captured to illustrate bugs.\n * This option is only supported since API level 27 (Android P).\n * @property {?string|number} timeLimit - The maximum recording time, in seconds.\n * The default (and maximum) value is 180 (3 minutes).\n * @property {?string|number} bitRate - The video bit rate for the video, in megabits per second.\n * The default value is 4. You can increase the bit rate to improve video quality,\n * but doing so results in larger movie files.\n */\n\n/**\n * Initiate screenrecord utility on the device\n *\n * @param {string} destination - Full path to the writable media file destination\n * on the device file system.\n * @param {?ScreenrecordOptions} options [{}]\n * @returns {SubProcess} screenrecord process, which can be then controlled by the client code\n */\nmethods.screenrecord = function screenrecord (destination, options = {}) {\n const cmd = ['screenrecord'];\n const {\n videoSize,\n bitRate,\n timeLimit,\n bugReport,\n } = options;\n if (util.hasValue(videoSize)) {\n cmd.push('--size', videoSize);\n }\n if (util.hasValue(timeLimit)) {\n cmd.push('--time-limit', timeLimit);\n }\n if (util.hasValue(bitRate)) {\n cmd.push('--bit-rate', bitRate);\n }\n if (bugReport) {\n cmd.push('--bugreport');\n }\n cmd.push(destination);\n\n const fullCmd = [\n ...this.executable.defaultArgs,\n 'shell',\n ...cmd\n ];\n log.debug(`Building screenrecord process with the command line: adb ${util.quote(fullCmd)}`);\n return new SubProcess(this.executable.path, fullCmd);\n};\n\n/**\n * Executes the given function with the given input method context\n * and then restores the IME to the original value\n *\n * @param {string} ime - Valid IME identifier\n * @param {Function} fn - Function to execute\n * @returns {*} The result of the given function\n */\nmethods.runInImeContext = async function runInImeContext (ime, fn) {\n const originalIme = await this.defaultIME();\n if (originalIme === ime) {\n log.debug(`The original IME is the same as '${ime}'. There is no need to reset it`);\n } else {\n await this.enableIME(ime);\n await this.setIME(ime);\n // https://github.com/appium/appium/issues/15943\n await B.delay(500);\n }\n try {\n return await fn();\n } finally {\n if (originalIme !== ime) {\n await this.setIME(originalIme);\n }\n }\n};\n\n/**\n * Get tz database time zone formatted timezone\n *\n * @returns {string} TZ database Time Zones format\n *\n * @throws {error} If any exception is reported by adb shell.\n */\nmethods.getTimeZone = async function getTimeZone () {\n log.debug('Getting current timezone');\n try {\n return await this.getDeviceProperty('persist.sys.timezone');\n } catch (e) {\n throw new Error(`Error getting timezone. Original error: ${e.message}`);\n }\n};\n\n/**\n * Retrieves the list of features supported by the device under test\n *\n * @returns {Array<string>} the list of supported feature names or an empty list.\n * An example adb command output:\n * ```\n * cmd\n * ls_v2\n * fixed_push_mkdir\n * shell_v2\n * abb\n * stat_v2\n * apex\n * abb_exec\n * remount_shell\n * fixed_push_symlink_timestamp\n * ```\n * @throws {Error} if there was an error while retrieving the list\n */\nmethods.listFeatures = async function listFeatures () {\n this._memoizedFeatures = this._memoizedFeatures\n || _.memoize(async () => await this.adbExec(['features']), () => this.curDeviceId);\n try {\n return (await this._memoizedFeatures())\n .split(/\\s+/)\n .map((x) => x.trim())\n .filter(Boolean);\n } catch (e) {\n if (_.includes(e.stderr, 'unknown command')) {\n return [];\n }\n throw e;\n }\n};\n\n/**\n * Checks the state of streamed install feature.\n * This feature allows to speed up apk installation\n * since it does not require the original apk to be pushed to\n * the device under test first, which also saves space.\n * Although, it is required that both the device under test\n * and the adb server have the mentioned functionality.\n * See https://github.com/aosp-mirror/platform_system_core/blob/master/adb/client/adb_install.cpp\n * for more details\n *\n * @returns {boolean} `true` if the feature is supported by both adb and the\n * device under test\n */\nmethods.isStreamedInstallSupported = async function isStreamedInstallSupported () {\n const proto = Object.getPrototypeOf(this);\n proto._helpOutput = proto._helpOutput || await this.adbExec(['help']);\n return proto._helpOutput.includes('--streaming')\n && (await this.listFeatures()).includes('cmd');\n};\n\n/**\n * Checks whether incremental install feature is supported by ADB.\n * Read https://developer.android.com/preview/features#incremental\n * for more details on it.\n *\n * @returns {boolean} `true` if the feature is supported by both adb and the\n * device under test\n */\nmethods.isIncrementalInstallSupported = async function isIncrementalInstallSupported () {\n const {binary} = await this.getVersion();\n if (!binary) {\n return false;\n }\n return util.compareVersions(binary.version, '>=', '30.0.1')\n && (await this.listFeatures()).includes('abb_exec');\n};\n\n/**\n * Retrieves the list of packages from Doze whitelist on Android 8+\n *\n * @returns {Array<string>} The list of whitelisted packages. An example output:\n * system,com.android.shell,2000\n * system,com.google.android.cellbroadcastreceiver,10143\n * user,io.appium.settings,10157\n */\nmethods.getDeviceIdleWhitelist = async function getDeviceIdleWhitelist () {\n if (await this.getApiLevel() < 23) {\n // Doze mode has only been added since Android 6\n return [];\n }\n\n log.info('Listing packages in Doze whitelist');\n const output = await this.shell(['dumpsys', 'deviceidle', 'whitelist']);\n return _.trim(output).split(/\\n/)\n .map((line) => _.trim(line))\n .filter(Boolean);\n};\n\n/**\n * Adds an existing package(s) into the Doze whitelist on Android 8+\n *\n * @param {...string} packages One or more packages to add. If the package\n * already exists in the whitelist then it is only going to be added once.\n * If the package with the given name is not installed/not known then an error\n * will be thrown.\n * @returns {Boolean} `true` if the command to add package(s) has been executed\n */\nmethods.addToDeviceIdleWhitelist = async function addToDeviceIdleWhitelist (...packages) {\n if (_.isEmpty(packages) || await this.getApiLevel() < 23) {\n // Doze mode has only been added since Android 6\n return false;\n }\n\n log.info(`Adding ${util.pluralize('package', packages.length)} ${JSON.stringify(packages)} to Doze whitelist`);\n await this.shellChunks((pkg) => ['dumpsys', 'deviceidle', 'whitelist', `+${pkg}`], packages);\n return true;\n};\n\nexport default methods;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,uBAAuB,GAAG,IAAhC;AACA,MAAMC,yBAAyB,GAAG,mCAAlC;AACA,MAAMC,mBAAmB,GAAG,CAC1BD,yBAD0B,EAE1B,qBAF0B,CAA5B;AAIA,MAAME,qBAAqB,GAAG,EAA9B;AACA,MAAMC,sBAAsB,GAAG,CAC7B,8BAD6B,EAE7B,0BAF6B,EAG7B,mBAH6B,CAA/B;AAKA,MAAMC,gBAAgB,GAAG,KAAzB;AACA,MAAMC,yBAAyB,GAAG,MAAlC;AACA,MAAMC,gBAAgB,GAAG,IAAIC,MAAJ,CAAY,UAASH,gBAAiB,WAAUC,yBAA0B,SAA1E,EAAoF,GAApF,CAAzB;AACA,MAAMG,gCAAgC,GAAG,EAAzC;AAEA,MAAMC,OAAO,GAAG,EAAhB;;AAgBAA,OAAO,CAACC,WAAR,GAAsB,eAAeA,WAAf,CAA4BC,cAA5B,EAA4CC,IAA5C,EAAkD;EACtE,MAAMC,QAAQ,GAAG,EAAjB;EACA,IAAIC,QAAQ,GAAG,EAAf;;EACA,KAAK,MAAMC,GAAX,IAAkBH,IAAlB,EAAwB;IACtB,MAAMI,OAAO,GAAGL,cAAc,CAACI,GAAD,CAA9B;;IACA,IAAI,CAACE,eAAA,CAAEC,OAAF,CAAUF,OAAV,CAAL,EAAyB;MACvB,MAAM,IAAIG,KAAJ,CAAU,8CAAV,CAAN;IACD;;IACD,IAAIF,eAAA,CAAEG,IAAF,CAAOJ,OAAP,MAAoB,GAAxB,EAA6B;MAC3BA,OAAO,CAACK,IAAR,CAAa,GAAb;IACD;;IACD,IAAIL,OAAO,CAACM,IAAR,CAAa,GAAb,EAAkBC,MAAl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aAAA,CAAKqK,SAAL,CAAe,SAAf,EAA0BD,QAAQ,CAAC7U,MAAnC,CAA2C,IAAGI,IAAI,CAACC,SAAL,CAAewU,QAAf,CAAyB,oBAA1F;;EACA,MAAM,KAAK1V,WAAL,CAAkBkE,GAAD,IAAS,CAAC,SAAD,EAAY,YAAZ,EAA0B,WAA1B,EAAwC,IAAGA,GAAI,EAA/C,CAA1B,EAA6EwR,QAA7E,CAAN;EACA,OAAO,IAAP;AACD,CATD;;eAWe3V,O"}
1
+ {"version":3,"file":"adb-commands.js","names":["MAX_SHELL_BUFFER_LENGTH","NOT_CHANGEABLE_PERM_ERROR","IGNORED_PERM_ERRORS","MAX_PGREP_PATTERN_LEN","HIDDEN_API_POLICY_KEYS","PID_COLUMN_TITLE","PROCESS_NAME_COLUMN_TITLE","PS_TITLE_PATTERN","RegExp","MIN_API_LEVEL_WITH_PERMS_SUPPORT","methods","shellChunks","argTransformer","args","commands","cmdChunk","arg","nextCmd","_","isArray","Error","last","push","join","length","isEmpty","log","debug","JSON","stringify","lastError","cmd","shell","e","getAdbWithCorrectAdbPath","executable","path","getSdkBinaryPath","adb","initAapt","initAapt2","initZipAlign","initBundletool","binaries","bundletool","fs","which","err","getApiLevel","isInteger","_apiLevel","strOutput","getDeviceProperty","apiLevel","parseInt","trim","charCodeQ","charCodeAt","apiLevelDiff","codename","String","fromCharCode","getPlatformVersion","toLowerCase","toUpperCase","isNaN","message","info","isDeviceConnected","devices","getConnectedDevices","mkdir","remotePath","isValidClass","classString","matchComponentName","resolveLaunchableActivity","pkg","opts","preferCmd","stdout","names","parseLaunchableActivityNames","tmpRoot","tempDir","openDir","tmpApp","pullApk","apkActivity","packageAndLaunchActivityFromManifest","stack","warn","rimraf","stderr","outputFormat","EXEC_OUTPUT_FORMAT","FULL","line","split","map","forceStop","killPackage","clear","grantAllPermissions","apk","targetSdk","dumpsysOutput","targetSdkVersionUsingPKG","targetSdkVersionFromManifest","requestedPermissions","getReqPermissions","grantedPermissions","getGrantedPermissions","permissionsToGrant","difference","grantPermissions","permissions","perm","some","pattern","test","grantPermission","permission","revokePermission","cmdOutput","extractMatchingPermissions","getDeniedPermissions","getLocationProviders","getSetting","p","filter","Boolean","toggleGPSLocationProvider","enabled","setSetting","setHiddenApiPolicy","value","ignoreError","k","setDefaultHiddenApiPolicy","stopAndClear","availableIMEs","getIMEListFromOutput","enabledIMEs","enableIME","imeId","disableIME","setIME","defaultIME","engine","keyevent","keycode","code","inputText","text","originalStr","escapedText","replace","adbInputEscapePattern","every","c","includes","q","clearTextField","i","lock","isScreenLocked","timeoutMs","waitForCondition","waitMs","intervalMs","back","goToHome","getAdbPath","getScreenOrientation","getSurfaceOrientation","sendTelnetCommand","command","execEmuConsoleCommand","port","getEmulatorPort","isAirplaneModeOn","setAirplaneMode","on","broadcastAirplaneMode","privileged","ign","isWifiOn","isDataOn","setWifiAndData","wifi","data","isEmulator","util","hasValue","setWifiState","setDataState","isAnimationOn","animator_duration_scale","transition_animation_scale","window_animation_scale","setting","localPath","posix","dirname","adbExec","pull","timeout","processExists","processName","getPIDsByName","getForwardList","connections","EOL","forwardPort","systemPort","devicePort","removePortForward","getReverseList","reversePort","removePortReverse","forwardAbstractPort","ping","indexOf","restart","stopLogcat","restartAdb","waitForDevice","startLogcat","_logcatStartupParams","logcat","Logcat","debugTrace","clearDeviceLogsOnStart","startCapture","stopCapture","getLogcatLogs","getLogs","setLogcatListener","listener","removeLogcatListener","removeListener","listProcessStatus","isBoolean","_doesPsSupportAOption","getNameByPid","pid","titleMatch","exec","allTitles","pidIndex","nameOffset","pidRegex","matchedLine","items","name","_isPgrepAvailable","pgrepOutput","_canPgrepUseFullCmdLineSearch","_isPidofAvailable","shellCommand","escapeRegExp","slice","x","pids","processNameRegex","killProcessesByName","B","all","killProcessByPID","noProcessFlag","e1","broadcastProcessEnd","intent","broadcast","start","Date","now","sleep","endAndroidCoverage","instrumentProc","isRunning","stop","instrument","activity","instrumentWith","pkgActivity","androidCoverage","instrumentClass","waitPkg","waitActivity","resolve","reject","defaultArgs","concat","SubProcess","waitForActivity","property","val","setDeviceProperty","prop","getDeviceSysLanguage","getDeviceSysCountry","getDeviceSysLocale","getDeviceProductLanguage","getDeviceProductCountry","getDeviceProductLocale","getModel","getManufacturer","getScreenSize","size","getScreenDensity","density","densityNumber","setHttpProxy","proxyHost","proxyPort","proxy","isUndefined","httpProxySettins","settingKey","settingValue","deleteHttpProxy","namespace","bugreport","screenrecord","destination","options","videoSize","bitRate","timeLimit","bugReport","fullCmd","quote","runInImeContext","ime","fn","originalIme","delay","getTimeZone","listFeatures","_memoizedFeatures","memoize","curDeviceId","isStreamedInstallSupported","proto","Object","getPrototypeOf","_helpOutput","isIncrementalInstallSupported","binary","getVersion","compareVersions","version","getDeviceIdleWhitelist","output","addToDeviceIdleWhitelist","packages","pluralize"],"sources":["../../../lib/tools/adb-commands.js"],"sourcesContent":["import log from '../logger.js';\nimport {\n getIMEListFromOutput, getSurfaceOrientation, extractMatchingPermissions,\n parseLaunchableActivityNames, matchComponentName,\n} from '../helpers.js';\nimport path from 'path';\nimport _ from 'lodash';\nimport { fs, util, tempDir } from '@appium/support';\nimport { EOL } from 'os';\nimport Logcat from '../logcat';\nimport { sleep, waitForCondition } from 'asyncbox';\nimport { SubProcess } from 'teen_process';\nimport B from 'bluebird';\n\nconst MAX_SHELL_BUFFER_LENGTH = 1000;\nconst NOT_CHANGEABLE_PERM_ERROR = /not a changeable permission type/i;\nconst IGNORED_PERM_ERRORS = [\n NOT_CHANGEABLE_PERM_ERROR,\n /Unknown permission/i,\n];\nconst MAX_PGREP_PATTERN_LEN = 15;\nconst HIDDEN_API_POLICY_KEYS = [\n 'hidden_api_policy_pre_p_apps',\n 'hidden_api_policy_p_apps',\n 'hidden_api_policy'\n];\nconst PID_COLUMN_TITLE = 'PID';\nconst PROCESS_NAME_COLUMN_TITLE = 'NAME';\nconst PS_TITLE_PATTERN = new RegExp(`^(.*\\\\b${PID_COLUMN_TITLE}\\\\b.*\\\\b${PROCESS_NAME_COLUMN_TITLE}\\\\b.*)$`, 'm');\nconst MIN_API_LEVEL_WITH_PERMS_SUPPORT = 23;\n\nconst methods = {};\n\n/**\n * Creates chunks for the given arguments and executes them in `adb shell`.\n * This is faster than calling `adb shell` separately for each arg, however\n * there is a limit for a maximum length of a single adb command. that is why\n * we need all this complicated logic.\n *\n * @param {Function} argTransformer A function, that receives single argument\n * from the `args` array and transforms it into a shell command. The result\n * of the function must be an array, where each item is a part of a single command.\n * The last item of the array could be ';'. If this is not a semicolon then it is going to\n * be added automatically.\n * @param {Array<number|string>} args Array of argument values to create chunks for\n * @throws {Error} If any of the chunks returns non-zero exit code after being executed\n */\nmethods.shellChunks = async function shellChunks (argTransformer, args) {\n const commands = [];\n let cmdChunk = [];\n for (const arg of args) {\n const nextCmd = argTransformer(arg);\n if (!_.isArray(nextCmd)) {\n throw new Error('Argument transformer must result in an array');\n }\n if (_.last(nextCmd) !== ';') {\n nextCmd.push(';');\n }\n if (nextCmd.join(' ').length + cmdChunk.join(' ').length >= MAX_SHELL_BUFFER_LENGTH) {\n commands.push(cmdChunk);\n cmdChunk = [];\n }\n cmdChunk = [...cmdChunk, ...nextCmd];\n }\n if (!_.isEmpty(cmdChunk)) {\n commands.push(cmdChunk);\n }\n log.debug(`Got the following command chunks to execute: ${JSON.stringify(commands)}`);\n let lastError = null;\n for (const cmd of commands) {\n try {\n await this.shell(cmd);\n } catch (e) {\n lastError = e;\n }\n }\n if (lastError) {\n throw lastError;\n }\n};\n\n/**\n * Get the path to adb executable amd assign it\n * to this.executable.path and this.binaries.adb properties.\n *\n * @return {ADB} ADB instance.\n */\nmethods.getAdbWithCorrectAdbPath = async function getAdbWithCorrectAdbPath () {\n this.executable.path = await this.getSdkBinaryPath('adb');\n return this.adb;\n};\n\n/**\n * Get the full path to aapt tool and assign it to\n * this.binaries.aapt property\n */\nmethods.initAapt = async function initAapt () {\n await this.getSdkBinaryPath('aapt');\n};\n\n/**\n * Get the full path to aapt2 tool and assign it to\n * this.binaries.aapt2 property\n */\nmethods.initAapt2 = async function initAapt2 () {\n await this.getSdkBinaryPath('aapt2');\n};\n\n/**\n * Get the full path to zipalign tool and assign it to\n * this.binaries.zipalign property\n */\nmethods.initZipAlign = async function initZipAlign () {\n await this.getSdkBinaryPath('zipalign');\n};\n\n/**\n * Get the full path to bundletool binary and assign it to\n * this.binaries.bundletool property\n */\nmethods.initBundletool = async function initBundletool () {\n try {\n this.binaries.bundletool = await fs.which('bundletool.jar');\n } catch (err) {\n throw new Error('bundletool.jar binary is expected to be present in PATH. ' +\n 'Visit https://github.com/google/bundletool for more details.');\n }\n};\n\n/**\n * Retrieve the API level of the device under test.\n *\n * @return {number} The API level as integer number, for example 21 for\n * Android Lollipop. The result of this method is cached, so all the further\n * calls return the same value as the first one.\n */\nmethods.getApiLevel = async function getApiLevel () {\n if (!_.isInteger(this._apiLevel)) {\n try {\n const strOutput = await this.getDeviceProperty('ro.build.version.sdk');\n let apiLevel = parseInt(strOutput.trim(), 10);\n\n // Workaround for preview/beta platform API level\n const charCodeQ = 'q'.charCodeAt(0);\n // 28 is the first API Level, where Android SDK started returning letters in response to getPlatformVersion\n const apiLevelDiff = apiLevel - 28;\n const codename = String.fromCharCode(charCodeQ + apiLevelDiff);\n if (apiLevelDiff >= 0 && (await this.getPlatformVersion()).toLowerCase() === codename) {\n log.debug(`Release version is ${codename.toUpperCase()} but found API Level ${apiLevel}. Setting API Level to ${apiLevel + 1}`);\n apiLevel++;\n }\n\n this._apiLevel = apiLevel;\n log.debug(`Device API level: ${this._apiLevel}`);\n if (isNaN(this._apiLevel)) {\n throw new Error(`The actual output '${strOutput}' cannot be converted to an integer`);\n }\n } catch (e) {\n throw new Error(`Error getting device API level. Original error: ${e.message}`);\n }\n }\n return this._apiLevel;\n};\n\n/**\n * Retrieve the platform version of the device under test.\n *\n * @return {string} The platform version as a string, for example '5.0' for\n * Android Lollipop.\n */\nmethods.getPlatformVersion = async function getPlatformVersion () {\n log.info('Getting device platform version');\n try {\n return await this.getDeviceProperty('ro.build.version.release');\n } catch (e) {\n throw new Error(`Error getting device platform version. Original error: ${e.message}`);\n }\n};\n\n/**\n * Verify whether a device is connected.\n *\n * @return {boolean} True if at least one device is visible to adb.\n */\nmethods.isDeviceConnected = async function isDeviceConnected () {\n let devices = await this.getConnectedDevices();\n return devices.length > 0;\n};\n\n/**\n * Recursively create a new folder on the device under test.\n *\n * @param {string} remotePath - The new path to be created.\n * @return {string} mkdir command output.\n */\nmethods.mkdir = async function mkdir (remotePath) {\n return await this.shell(['mkdir', '-p', remotePath]);\n};\n\n/**\n * Verify whether the given argument is a\n * valid class name.\n *\n * @param {string} classString - The actual class name to be verified.\n * @return {?Array.<Match>} The result of Regexp.exec operation\n * or _null_ if no matches are found.\n */\nmethods.isValidClass = function isValidClass (classString) {\n // some.package/some.package.Activity\n return matchComponentName(classString);\n};\n\n/**\n * @typedef {Object} ResolveActivityOptions\n * @property {boolean?} preferCmd [true] Whether to prefer `cmd` tool usage for\n * launchable activity name detection. It might be useful to disable it if\n * `cmd package resolve-activity` returns 'android/com.android.internal.app.ResolverActivity',\n * which means the app has no default handler set in system settings.\n * See https://github.com/appium/appium/issues/17128 for more details.\n * This option has no effect if the target Android version is below 24 as there\n * the corresponding `cmd` subcommand is not implemented and dumpsys usage is the only\n * possible way to detect the launchable activity name.\n */\n\n/**\n * Fetches the fully qualified name of the launchable activity for the\n * given package. It is expected the package is already installed on\n * the device under test.\n *\n * @param {string} pkg - The target package identifier\n * @param {ResolveActivityOptions?} opts\n * @return {string} Fully qualified name of the launchable activity\n * @throws {Error} If there was an error while resolving the activity name\n */\nmethods.resolveLaunchableActivity = async function resolveLaunchableActivity (pkg, opts = {}) {\n const { preferCmd = true } = opts;\n if (!preferCmd || await this.getApiLevel() < 24) {\n const stdout = await this.shell(['dumpsys', 'package', pkg]);\n const names = parseLaunchableActivityNames(stdout);\n if (_.isEmpty(names)) {\n log.debug(stdout);\n throw new Error(`Unable to resolve the launchable activity of '${pkg}'. Is it installed on the device?`);\n }\n if (names.length === 1) {\n return names[0];\n }\n\n const tmpRoot = await tempDir.openDir();\n try {\n const tmpApp = await this.pullApk(pkg, tmpRoot);\n const {apkActivity} = await this.packageAndLaunchActivityFromManifest(tmpApp);\n return apkActivity;\n } catch (e) {\n log.debug(e.stack);\n log.warn(`Unable to resolve the launchable activity of '${pkg}'. ` +\n `The very first match of the dumpsys output is going to be used. ` +\n `Original error: ${e.message}`);\n return names[0];\n } finally {\n await fs.rimraf(tmpRoot);\n }\n }\n const {stdout, stderr} = await this.shell(['cmd', 'package', 'resolve-activity', '--brief', pkg], {\n outputFormat: this.EXEC_OUTPUT_FORMAT.FULL\n });\n for (const line of (stdout || '').split('\\n').map(_.trim)) {\n if (this.isValidClass(line)) {\n return line;\n }\n }\n throw new Error(`Unable to resolve the launchable activity of '${pkg}'. Original error: ${stderr || stdout}`);\n};\n\n/**\n * Force application to stop on the device under test.\n *\n * @param {string} pkg - The package name to be stopped.\n * @return {string} The output of the corresponding adb command.\n */\nmethods.forceStop = async function forceStop (pkg) {\n return await this.shell(['am', 'force-stop', pkg]);\n};\n\n/*\n * Kill application\n *\n * @param {string} pkg - The package name to be stopped.\n * @return {string} The output of the corresponding adb command.\n */\nmethods.killPackage = async function killPackage (pkg) {\n return await this.shell(['am', 'kill', pkg]);\n};\n\n/**\n * Clear the user data of the particular application on the device\n * under test.\n *\n * @param {string} pkg - The package name to be cleared.\n * @return {string} The output of the corresponding adb command.\n */\nmethods.clear = async function clear (pkg) {\n return await this.shell(['pm', 'clear', pkg]);\n};\n\n/**\n * Grant all permissions requested by the particular package.\n * This method is only useful on Android 6.0+ and for applications\n * that support components-based permissions setting.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} apk - The path to the actual apk file.\n * @throws {Error} If there was an error while granting permissions\n */\nmethods.grantAllPermissions = async function grantAllPermissions (pkg, apk) {\n const apiLevel = await this.getApiLevel();\n let targetSdk = 0;\n let dumpsysOutput = null;\n try {\n if (!apk) {\n /**\n * If apk not provided, considering apk already installed on the device\n * and fetching targetSdk using package name.\n */\n dumpsysOutput = await this.shell(['dumpsys', 'package', pkg]);\n targetSdk = await this.targetSdkVersionUsingPKG(pkg, dumpsysOutput);\n } else {\n targetSdk = await this.targetSdkVersionFromManifest(apk);\n }\n } catch (e) {\n //avoiding logging error stack, as calling library function would have logged\n log.warn(`Ran into problem getting target SDK version; ignoring...`);\n }\n if (apiLevel >= MIN_API_LEVEL_WITH_PERMS_SUPPORT && targetSdk >= MIN_API_LEVEL_WITH_PERMS_SUPPORT) {\n /**\n * If the device is running Android 6.0(API 23) or higher, and your app's target SDK is 23 or higher:\n * The app has to list the permissions in the manifest.\n * refer: https://developer.android.com/training/permissions/requesting.html\n */\n dumpsysOutput = dumpsysOutput || await this.shell(['dumpsys', 'package', pkg]);\n const requestedPermissions = await this.getReqPermissions(pkg, dumpsysOutput);\n const grantedPermissions = await this.getGrantedPermissions(pkg, dumpsysOutput);\n const permissionsToGrant = _.difference(requestedPermissions, grantedPermissions);\n if (_.isEmpty(permissionsToGrant)) {\n log.info(`${pkg} contains no permissions available for granting`);\n } else {\n await this.grantPermissions(pkg, permissionsToGrant);\n }\n } else if (targetSdk < MIN_API_LEVEL_WITH_PERMS_SUPPORT) {\n log.info(`It is only possible to grant permissions in runtime for ` +\n `apps whose targetSdkVersion in the manifest is set to ${MIN_API_LEVEL_WITH_PERMS_SUPPORT} or above. ` +\n `The current ${pkg} targetSdkVersion is ${targetSdk || 'unset'}.`);\n } else if (apiLevel < MIN_API_LEVEL_WITH_PERMS_SUPPORT) {\n log.info(`The device's OS API level is ${apiLevel}. ` +\n `It is only possible to grant permissions on devices running Android 6 or above.`);\n }\n};\n\n/**\n * Grant multiple permissions for the particular package.\n * This call is more performant than `grantPermission` one, since it combines\n * multiple `adb shell` calls into a single command.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {Array<string>} permissions - The list of permissions to be granted.\n * @throws {Error} If there was an error while changing permissions.\n */\nmethods.grantPermissions = async function grantPermissions (pkg, permissions) {\n // As it consumes more time for granting each permission,\n // trying to grant all permission by forming equivalent command.\n // Also, it is necessary to split long commands into chunks, since the maximum length of\n // adb shell buffer is limited\n log.debug(`Granting permissions ${JSON.stringify(permissions)} to '${pkg}'`);\n try {\n await this.shellChunks((perm) => ['pm', 'grant', pkg, perm], permissions);\n } catch (e) {\n if (!IGNORED_PERM_ERRORS.some((pattern) => pattern.test(e.stderr || e.message))) {\n throw e;\n }\n }\n};\n\n/**\n * Grant single permission for the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} permission - The full name of the permission to be granted.\n * @throws {Error} If there was an error while changing permissions.\n */\nmethods.grantPermission = async function grantPermission (pkg, permission) {\n try {\n await this.shell(['pm', 'grant', pkg, permission]);\n } catch (e) {\n if (!NOT_CHANGEABLE_PERM_ERROR.test(e.stderr || e.message)) {\n throw e;\n }\n }\n};\n\n/**\n * Revoke single permission from the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} permission - The full name of the permission to be revoked.\n * @throws {Error} If there was an error while changing permissions.\n */\nmethods.revokePermission = async function revokePermission (pkg, permission) {\n try {\n await this.shell(['pm', 'revoke', pkg, permission]);\n } catch (e) {\n if (!NOT_CHANGEABLE_PERM_ERROR.test(e.stderr || e.message)) {\n throw e;\n }\n }\n};\n\n/**\n * Retrieve the list of granted permissions for the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} cmdOutput [null] - Optional parameter containing command output of\n * _dumpsys package_ command. It may speed up the method execution.\n * @return {Array<String>} The list of granted permissions or an empty list.\n * @throws {Error} If there was an error while changing permissions.\n */\nmethods.getGrantedPermissions = async function getGrantedPermissions (pkg, cmdOutput = null) {\n log.debug('Retrieving granted permissions');\n const stdout = cmdOutput || await this.shell(['dumpsys', 'package', pkg]);\n return extractMatchingPermissions(stdout, ['install', 'runtime'], true);\n};\n\n/**\n * Retrieve the list of denied permissions for the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} cmdOutput [null] - Optional parameter containing command output of\n * _dumpsys package_ command. It may speed up the method execution.\n * @return {Array<String>} The list of denied permissions or an empty list.\n */\nmethods.getDeniedPermissions = async function getDeniedPermissions (pkg, cmdOutput = null) {\n log.debug('Retrieving denied permissions');\n const stdout = cmdOutput || await this.shell(['dumpsys', 'package', pkg]);\n return extractMatchingPermissions(stdout, ['install', 'runtime'], false);\n};\n\n/**\n * Retrieve the list of requested permissions for the particular package.\n *\n * @param {string} pkg - The package name to be processed.\n * @param {string} cmdOutput [null] - Optional parameter containing command output of\n * _dumpsys package_ command. It may speed up the method execution.\n * @return {Array<String>} The list of requested permissions or an empty list.\n */\nmethods.getReqPermissions = async function getReqPermissions (pkg, cmdOutput = null) {\n log.debug('Retrieving requested permissions');\n const stdout = cmdOutput || await this.shell(['dumpsys', 'package', pkg]);\n return extractMatchingPermissions(stdout, ['requested']);\n};\n\n/**\n * Retrieve the list of location providers for the device under test.\n *\n * @return {Array.<String>} The list of available location providers or an empty list.\n */\nmethods.getLocationProviders = async function getLocationProviders () {\n let stdout = await this.getSetting('secure', 'location_providers_allowed');\n return stdout.trim().split(',')\n .map((p) => p.trim())\n .filter(Boolean);\n};\n\n/**\n * Toggle the state of GPS location provider.\n *\n * @param {boolean} enabled - Whether to enable (true) or disable (false) the GPS provider.\n */\nmethods.toggleGPSLocationProvider = async function toggleGPSLocationProvider (enabled) {\n await this.setSetting('secure', 'location_providers_allowed', `${enabled ? '+' : '-'}gps`);\n};\n\n/**\n * Set hidden api policy to manage access to non-SDK APIs.\n * https://developer.android.com/preview/restrictions-non-sdk-interfaces\n *\n * @param {number|string} value - The API enforcement policy.\n * For Android P\n * 0: Disable non-SDK API usage detection. This will also disable logging, and also break the strict mode API,\n * detectNonSdkApiUsage(). Not recommended.\n * 1: \"Just warn\" - permit access to all non-SDK APIs, but keep warnings in the log.\n * The strict mode API will keep working.\n * 2: Disallow usage of dark grey and black listed APIs.\n * 3: Disallow usage of blacklisted APIs, but allow usage of dark grey listed APIs.\n *\n * For Android Q\n * https://developer.android.com/preview/non-sdk-q#enable-non-sdk-access\n * 0: Disable all detection of non-SDK interfaces. Using this setting disables all log messages for non-SDK interface usage\n * and prevents you from testing your app using the StrictMode API. This setting is not recommended.\n * 1: Enable access to all non-SDK interfaces, but print log messages with warnings for any non-SDK interface usage.\n * Using this setting also allows you to test your app using the StrictMode API.\n * 2: Disallow usage of non-SDK interfaces that belong to either the black list\n * or to a restricted greylist for your target API level.\n *\n * @param {boolean} ignoreError [false] Whether to ignore an exception in 'adb shell settings put global' command\n * @throws {error} If there was an error and ignoreError was true while executing 'adb shell settings put global'\n * command on the device under test.\n */\nmethods.setHiddenApiPolicy = async function setHiddenApiPolicy (value, ignoreError = false) {\n try {\n await this.shell(HIDDEN_API_POLICY_KEYS.map((k) => `settings put global ${k} ${value}`).join(';'));\n } catch (e) {\n if (!ignoreError) {\n throw e;\n }\n log.info(`Failed to set setting keys '${HIDDEN_API_POLICY_KEYS}' to '${value}'. Original error: ${e.message}`);\n }\n};\n\n/**\n * Reset access to non-SDK APIs to its default setting.\n * https://developer.android.com/preview/restrictions-non-sdk-interfaces\n *\n * @param {boolean} ignoreError [false] Whether to ignore an exception in 'adb shell settings delete global' command\n * @throws {error} If there was an error and ignoreError was true while executing 'adb shell settings delete global'\n * command on the device under test.\n */\nmethods.setDefaultHiddenApiPolicy = async function setDefaultHiddenApiPolicy (ignoreError = false) {\n try {\n await this.shell(HIDDEN_API_POLICY_KEYS.map((k) => `settings delete global ${k}`).join(';'));\n } catch (e) {\n if (!ignoreError) {\n throw e;\n }\n log.info(`Failed to delete keys '${HIDDEN_API_POLICY_KEYS}'. Original error: ${e.message}`);\n }\n};\n\n/**\n * Stop the particular package if it is running and clears its application data.\n *\n * @param {string} pkg - The package name to be processed.\n */\nmethods.stopAndClear = async function stopAndClear (pkg) {\n try {\n await this.forceStop(pkg);\n await this.clear(pkg);\n } catch (e) {\n throw new Error(`Cannot stop and clear ${pkg}. Original error: ${e.message}`);\n }\n};\n\n/**\n * Retrieve the list of available input methods (IMEs) for the device under test.\n *\n * @return {Array.<String>} The list of IME names or an empty list.\n */\nmethods.availableIMEs = async function availableIMEs () {\n try {\n return getIMEListFromOutput(await this.shell(['ime', 'list', '-a']));\n } catch (e) {\n throw new Error(`Error getting available IME's. Original error: ${e.message}`);\n }\n};\n\n/**\n * Retrieve the list of enabled input methods (IMEs) for the device under test.\n *\n * @return {Array.<String>} The list of enabled IME names or an empty list.\n */\nmethods.enabledIMEs = async function enabledIMEs () {\n try {\n return getIMEListFromOutput(await this.shell(['ime', 'list']));\n } catch (e) {\n throw new Error(`Error getting enabled IME's. Original error: ${e.message}`);\n }\n};\n\n/**\n * Enable the particular input method on the device under test.\n *\n * @param {string} imeId - One of existing IME ids.\n */\nmethods.enableIME = async function enableIME (imeId) {\n await this.shell(['ime', 'enable', imeId]);\n};\n\n/**\n * Disable the particular input method on the device under test.\n *\n * @param {string} imeId - One of existing IME ids.\n */\nmethods.disableIME = async function disableIME (imeId) {\n await this.shell(['ime', 'disable', imeId]);\n};\n\n/**\n * Set the particular input method on the device under test.\n *\n * @param {string} imeId - One of existing IME ids.\n */\nmethods.setIME = async function setIME (imeId) {\n await this.shell(['ime', 'set', imeId]);\n};\n\n/**\n * Get the default input method on the device under test.\n *\n * @return {?string} The name of the default input method\n */\nmethods.defaultIME = async function defaultIME () {\n try {\n let engine = await this.getSetting('secure', 'default_input_method');\n if (engine === 'null') {\n return null;\n }\n return engine.trim();\n } catch (e) {\n throw new Error(`Error getting default IME. Original error: ${e.message}`);\n }\n};\n\n/**\n * Send the particular keycode to the device under test.\n *\n * @param {string|number} keycode - The actual key code to be sent.\n */\nmethods.keyevent = async function keyevent (keycode) {\n // keycode must be an int.\n let code = parseInt(keycode, 10);\n await this.shell(['input', 'keyevent', code]);\n};\n\n/**\n * Send the particular text or a number to the device under test.\n * The text gets properly escaped before being passed to ADB.\n * Noop if the text is empty.\n *\n * @param {string|number} text - The actual text to be sent.\n * @throws {Error} If it is impossible to escape the given string\n */\nmethods.inputText = async function inputText (text) {\n if (text === '') {\n return;\n }\n\n const originalStr = `${text}`;\n const escapedText = originalStr.replace(/\\$/g, '\\\\$').replace(/ /g, '%s');\n let args = ['input', 'text', originalStr];\n // https://stackoverflow.com/questions/25791423/adb-shell-input-text-does-not-take-ampersand-character/25791498\n const adbInputEscapePattern = /[()<>|;&*\\\\~^\"']/g;\n if (escapedText !== originalStr || adbInputEscapePattern.test(originalStr)) {\n if (_.every(['\"', `'`], (c) => originalStr.includes(c))) {\n throw new Error(\n `Did not know how to escape a string that contains both types of quotes (\" and ')`\n );\n }\n const q = originalStr.includes('\"') ? `'` : '\"';\n args = [`input text ${q}${escapedText}${q}`];\n }\n await this.shell(args);\n};\n\n/**\n * Clear the active text field on the device under test by sending\n * special keyevents to it.\n *\n * @param {number} length [100] - The maximum length of the text in the field to be cleared.\n */\nmethods.clearTextField = async function clearTextField (length = 100) {\n // assumes that the EditText field already has focus\n log.debug(`Clearing up to ${length} characters`);\n if (length === 0) {\n return;\n }\n let args = ['input', 'keyevent'];\n for (let i = 0; i < length; i++) {\n // we cannot know where the cursor is in the text field, so delete both before\n // and after so that we get rid of everything\n // https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_DEL\n // https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_FORWARD_DEL\n args.push('67', '112');\n }\n await this.shell(args);\n};\n\n/**\n * Send the special keycode to the device under test in order to lock it.\n */\nmethods.lock = async function lock () {\n if (await this.isScreenLocked()) {\n log.debug('Screen is already locked. Doing nothing.');\n return;\n }\n log.debug('Pressing the KEYCODE_POWER button to lock screen');\n await this.keyevent(26);\n\n const timeoutMs = 5000;\n try {\n await waitForCondition(async () => await this.isScreenLocked(), {\n waitMs: timeoutMs,\n intervalMs: 500,\n });\n } catch (e) {\n throw new Error(`The device screen is still locked after ${timeoutMs}ms timeout`);\n }\n};\n\n/**\n * Send the special keycode to the device under test in order to emulate\n * Back button tap.\n */\nmethods.back = async function back () {\n log.debug('Pressing the BACK button');\n await this.keyevent(4);\n};\n\n/**\n * Send the special keycode to the device under test in order to emulate\n * Home button tap.\n */\nmethods.goToHome = async function goToHome () {\n log.debug('Pressing the HOME button');\n await this.keyevent(3);\n};\n\n/**\n * @return {string} the actual path to adb executable.\n */\nmethods.getAdbPath = function getAdbPath () {\n return this.executable.path;\n};\n\n/**\n * Retrieve current screen orientation of the device under test.\n *\n * @return {number} The current orientation encoded as an integer number.\n */\nmethods.getScreenOrientation = async function getScreenOrientation () {\n let stdout = await this.shell(['dumpsys', 'input']);\n return getSurfaceOrientation(stdout);\n};\n\n/**\n * Send an arbitrary Telnet command to the device under test.\n *\n * @param {string} command - The command to be sent.\n *\n * @return {string} The actual output of the given command.\n */\nmethods.sendTelnetCommand = async function sendTelnetCommand (command) {\n return await this.execEmuConsoleCommand(command, {port: await this.getEmulatorPort()});\n};\n\n/**\n * Check the state of Airplane mode on the device under test.\n *\n * @return {boolean} True if Airplane mode is enabled.\n */\nmethods.isAirplaneModeOn = async function isAirplaneModeOn () {\n let stdout = await this.getSetting('global', 'airplane_mode_on');\n return parseInt(stdout, 10) !== 0;\n};\n\n/**\n * Change the state of Airplane mode in Settings on the device under test.\n *\n * @param {boolean} on - True to enable the Airplane mode in Settings and false to disable it.\n */\nmethods.setAirplaneMode = async function setAirplaneMode (on) {\n await this.setSetting('global', 'airplane_mode_on', on ? 1 : 0);\n};\n\n/**\n * Broadcast the state of Airplane mode on the device under test.\n * This method should be called after {@link #setAirplaneMode}, otherwise\n * the mode change is not going to be applied for the device.\n *\n * @param {boolean} on - True to broadcast enable and false to broadcast disable.\n */\nmethods.broadcastAirplaneMode = async function broadcastAirplaneMode (on) {\n const args = [\n 'am', 'broadcast',\n '-a', 'android.intent.action.AIRPLANE_MODE',\n '--ez', 'state', on ? 'true' : 'false',\n ];\n try {\n await this.shell(args);\n } catch (e) {\n // https://github.com/appium/appium/issues/17422\n if (_.includes(e.stderr, 'SecurityException')) {\n try {\n await this.shell(args, {privileged: true});\n return;\n } catch (ign) {}\n }\n throw e;\n }\n};\n\n/**\n * Check the state of WiFi on the device under test.\n *\n * @return {boolean} True if WiFi is enabled.\n */\nmethods.isWifiOn = async function isWifiOn () {\n let stdout = await this.getSetting('global', 'wifi_on');\n return (parseInt(stdout, 10) !== 0);\n};\n\n/**\n * Check the state of Data transfer on the device under test.\n *\n * @return {boolean} True if Data transfer is enabled.\n */\nmethods.isDataOn = async function isDataOn () {\n let stdout = await this.getSetting('global', 'mobile_data');\n return (parseInt(stdout, 10) !== 0);\n};\n\n/**\n * Change the state of WiFi and/or Data transfer on the device under test.\n *\n * @param {boolean} wifi - True to enable and false to disable WiFi.\n * @param {boolean} data - True to enable and false to disable Data transfer.\n * @param {boolean} isEmulator [false] - Set it to true if the device under test\n * is an emulator rather than a real device.\n */\nmethods.setWifiAndData = async function setWifiAndData ({wifi, data}, isEmulator = false) {\n if (util.hasValue(wifi)) {\n await this.setWifiState(wifi, isEmulator);\n }\n if (util.hasValue(data)) {\n await this.setDataState(data, isEmulator);\n }\n};\n\n/**\n * Check the state of animation on the device under test.\n *\n * @return {boolean} True if at least one of animation scale settings\n * is not equal to '0.0'.\n */\nmethods.isAnimationOn = async function isAnimationOn () {\n let animator_duration_scale = await this.getSetting('global', 'animator_duration_scale');\n let transition_animation_scale = await this.getSetting('global', 'transition_animation_scale');\n let window_animation_scale = await this.getSetting('global', 'window_animation_scale');\n return _.some([animator_duration_scale, transition_animation_scale, window_animation_scale],\n (setting) => setting !== '0.0');\n};\n\n/**\n * Forcefully recursively remove a path on the device under test.\n * Be careful while calling this method.\n *\n * @param {string} path - The path to be removed recursively.\n */\nmethods.rimraf = async function rimraf (path) {\n await this.shell(['rm', '-rf', path]);\n};\n\n/**\n * Send a file to the device under test.\n *\n * @param {string} localPath - The path to the file on the local file system.\n * @param {string} remotePath - The destination path on the remote device.\n * @param {object} opts - Additional options mapping. See\n * https://github.com/appium/node-teen_process,\n * _exec_ method options, for more information about available\n * options.\n */\nmethods.push = async function push (localPath, remotePath, opts) {\n await this.mkdir(path.posix.dirname(remotePath));\n await this.adbExec(['push', localPath, remotePath], opts);\n};\n\n/**\n * Receive a file from the device under test.\n *\n * @param {string} remotePath - The source path on the remote device.\n * @param {string} localPath - The destination path to the file on the local file system.\n * @param {object} opts - Additional options mapping. See\n * https://github.com/appium/node-teen_process,\n * _exec_ method options, for more information about available\n * options.\n */\nmethods.pull = async function pull (remotePath, localPath, opts = {}) {\n // pull folder can take more time, increasing time out to 60 secs\n await this.adbExec(['pull', remotePath, localPath], {...opts, timeout: opts.timeout ?? 60000});\n};\n\n/**\n * Check whether the process with the particular name is running on the device\n * under test.\n *\n * @param {string} processName - The name of the process to be checked.\n * @return {boolean} True if the given process is running.\n * @throws {Error} If the given process name is not a valid class name.\n */\nmethods.processExists = async function processExists (processName) {\n return !_.isEmpty(await this.getPIDsByName(processName));\n};\n\n/**\n * Get TCP port forwarding with adb on the device under test.\n * @return {Array.<String>} The output of the corresponding adb command. An array contains each forwarding line of output\n */\nmethods.getForwardList = async function getForwardList () {\n log.debug(`List forwarding ports`);\n const connections = await this.adbExec(['forward', '--list']);\n return connections.split(EOL).filter((line) => Boolean(line.trim()));\n};\n\n/**\n * Setup TCP port forwarding with adb on the device under test.\n *\n * @param {string|number} systemPort - The number of the local system port.\n * @param {string|number} devicePort - The number of the remote device port.\n */\nmethods.forwardPort = async function forwardPort (systemPort, devicePort) {\n log.debug(`Forwarding system: ${systemPort} to device: ${devicePort}`);\n await this.adbExec(['forward', `tcp:${systemPort}`, `tcp:${devicePort}`]);\n};\n\n/**\n * Remove TCP port forwarding with adb on the device under test. The forwarding\n * for the given port should be setup with {@link #forwardPort} first.\n *\n * @param {string|number} systemPort - The number of the local system port\n * to remove forwarding on.\n */\nmethods.removePortForward = async function removePortForward (systemPort) {\n log.debug(`Removing forwarded port socket connection: ${systemPort} `);\n await this.adbExec(['forward', `--remove`, `tcp:${systemPort}`]);\n};\n\n/**\n * Get TCP port forwarding with adb on the device under test.\n * @return {Array.<String>} The output of the corresponding adb command. An array contains each forwarding line of output\n */\nmethods.getReverseList = async function getReverseList () {\n log.debug(`List reverse forwarding ports`);\n const connections = await this.adbExec(['reverse', '--list']);\n return connections.split(EOL).filter((line) => Boolean(line.trim()));\n};\n\n/**\n * Setup TCP port forwarding with adb on the device under test.\n * Only available for API 21+.\n *\n * @param {string|number} devicePort - The number of the remote device port.\n * @param {string|number} systemPort - The number of the local system port.\n */\nmethods.reversePort = async function reversePort (devicePort, systemPort) {\n log.debug(`Forwarding device: ${devicePort} to system: ${systemPort}`);\n await this.adbExec(['reverse', `tcp:${devicePort}`, `tcp:${systemPort}`]);\n};\n\n/**\n * Remove TCP port forwarding with adb on the device under test. The forwarding\n * for the given port should be setup with {@link #forwardPort} first.\n *\n * @param {string|number} devicePort - The number of the remote device port\n * to remove forwarding on.\n */\nmethods.removePortReverse = async function removePortReverse (devicePort) {\n log.debug(`Removing reverse forwarded port socket connection: ${devicePort} `);\n await this.adbExec(['reverse', `--remove`, `tcp:${devicePort}`]);\n};\n\n/**\n * Setup TCP port forwarding with adb on the device under test. The difference\n * between {@link #forwardPort} is that this method does setup for an abstract\n * local port.\n *\n * @param {string|number} systemPort - The number of the local system port.\n * @param {string|number} devicePort - The number of the remote device port.\n */\nmethods.forwardAbstractPort = async function forwardAbstractPort (systemPort, devicePort) {\n log.debug(`Forwarding system: ${systemPort} to abstract device: ${devicePort}`);\n await this.adbExec(['forward', `tcp:${systemPort}`, `localabstract:${devicePort}`]);\n};\n\n/**\n * Execute ping shell command on the device under test.\n *\n * @return {boolean} True if the command output contains 'ping' substring.\n * @throws {error} If there was an error while executing 'ping' command on the\n * device under test.\n */\nmethods.ping = async function ping () {\n let stdout = await this.shell(['echo', 'ping']);\n if (stdout.indexOf('ping') === 0) {\n return true;\n }\n throw new Error(`ADB ping failed, returned ${stdout}`);\n};\n\n/**\n * Restart the device under test using adb commands.\n *\n * @throws {error} If start fails.\n */\nmethods.restart = async function restart () {\n try {\n await this.stopLogcat();\n await this.restartAdb();\n await this.waitForDevice(60);\n await this.startLogcat(this._logcatStartupParams);\n } catch (e) {\n throw new Error(`Restart failed. Original error: ${e.message}`);\n }\n};\n\n/**\n * @typedef {Object} LogcatOpts\n * @property {string} format The log print format, where <format> is one of:\n * brief process tag thread raw time threadtime long\n * `threadtime` is the default value.\n * @property {Array<string>} filterSpecs Series of <tag>[:priority]\n * where <tag> is a log component tag (or * for all) and priority is:\n * V Verbose\n * D Debug\n * I Info\n * W Warn\n * E Error\n * F Fatal\n * S Silent (supress all output)\n *\n * '*' means '*:d' and <tag> by itself means <tag>:v\n *\n * If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS.\n * If no filterspec is found, filter defaults to '*:I'\n */\n\n/**\n * Start the logcat process to gather logs.\n *\n * @param {?LogcatOpts} opts\n * @throws {Error} If restart fails.\n */\nmethods.startLogcat = async function startLogcat (opts = {}) {\n if (!_.isEmpty(this.logcat)) {\n throw new Error(\"Trying to start logcat capture but it's already started!\");\n }\n\n this.logcat = new Logcat({\n adb: this.executable,\n debug: false,\n debugTrace: false,\n clearDeviceLogsOnStart: !!this.clearDeviceLogsOnStart,\n });\n await this.logcat.startCapture(opts);\n this._logcatStartupParams = opts;\n};\n\n/**\n * Stop the active logcat process which gathers logs.\n * The call will be ignored if no logcat process is running.\n */\nmethods.stopLogcat = async function stopLogcat () {\n if (_.isEmpty(this.logcat)) {\n return;\n }\n try {\n await this.logcat.stopCapture();\n } finally {\n this.logcat = null;\n }\n};\n\n/**\n * Retrieve the output from the currently running logcat process.\n * The logcat process should be executed by {2link #startLogcat} method.\n *\n * @return {string} The collected logcat output.\n * @throws {Error} If logcat process is not running.\n */\nmethods.getLogcatLogs = function getLogcatLogs () {\n if (_.isEmpty(this.logcat)) {\n throw new Error(\"Can't get logcat logs since logcat hasn't started\");\n }\n return this.logcat.getLogs();\n};\n\n/**\n * Set the callback for the logcat output event.\n *\n * @param {Function} listener - The listener function, which accepts one argument. The argument is\n * a log record object with `timestamp`, `level` and `message` properties.\n * @throws {Error} If logcat process is not running.\n */\nmethods.setLogcatListener = function setLogcatListener (listener) {\n if (_.isEmpty(this.logcat)) {\n throw new Error(\"Logcat process hasn't been started\");\n }\n this.logcat.on('output', listener);\n};\n\n/**\n * Removes the previously set callback for the logcat output event.\n *\n * @param {Function} listener - The listener function, which has been previously\n * passed to `setLogcatListener`\n * @throws {Error} If logcat process is not running.\n */\nmethods.removeLogcatListener = function removeLogcatListener (listener) {\n if (_.isEmpty(this.logcat)) {\n throw new Error(\"Logcat process hasn't been started\");\n }\n this.logcat.removeListener('output', listener);\n};\n\n/**\n * At some point of time Google has changed the default `ps` behaviour, so it only\n * lists processes that belong to the current shell user rather to all\n * users. It is necessary to execute ps with -A command line argument\n * to mimic the previous behaviour.\n *\n * @returns {string} the output of `ps` command where all processes are included\n */\nmethods.listProcessStatus = async function listProcessStatus () {\n if (!_.isBoolean(this._doesPsSupportAOption)) {\n try {\n this._doesPsSupportAOption = /^-A\\b/m.test(await this.shell(['ps', '--help']));\n } catch (e) {\n log.debug(e.stack);\n this._doesPsSupportAOption = false;\n }\n }\n return await this.shell(this._doesPsSupportAOption ? ['ps', '-A'] : ['ps']);\n};\n\n/**\n * Returns process name for the given process identifier\n *\n * @param {string|number} pid - The valid process identifier\n * @throws {Error} If the given PID is either invalid or is not present\n * in the active processes list\n * @returns {string} The process name\n */\nmethods.getNameByPid = async function getNameByPid (pid) {\n if (isNaN(pid)) {\n throw new Error(`The PID value must be a valid number. '${pid}' is given instead`);\n }\n pid = parseInt(pid, 10);\n\n const stdout = await this.listProcessStatus();\n const titleMatch = PS_TITLE_PATTERN.exec(stdout);\n if (!titleMatch) {\n log.debug(stdout);\n throw new Error(`Could not get the process name for PID '${pid}'`);\n }\n const allTitles = titleMatch[1].trim().split(/\\s+/);\n const pidIndex = allTitles.indexOf(PID_COLUMN_TITLE);\n // it might not be stable to take NAME by index, because depending on the\n // actual SDK the ps output might not contain an abbreviation for the S flag:\n // USER PID PPID VSIZE RSS WCHAN PC NAME\n // USER PID PPID VSIZE RSS WCHAN PC S NAME\n const nameOffset = allTitles.indexOf(PROCESS_NAME_COLUMN_TITLE) - allTitles.length;\n const pidRegex = new RegExp(`^(.*\\\\b${pid}\\\\b.*)$`, 'gm');\n let matchedLine;\n while ((matchedLine = pidRegex.exec(stdout))) {\n const items = matchedLine[1].trim().split(/\\s+/);\n if (parseInt(items[pidIndex], 10) === pid && items[items.length + nameOffset]) {\n return items[items.length + nameOffset];\n }\n }\n log.debug(stdout);\n throw new Error(`Could not get the process name for PID '${pid}'`);\n};\n\n/**\n * Get the list of process ids for the particular process on the device under test.\n *\n * @param {string} name - The part of process name.\n * @return {Array.<number>} The list of matched process IDs or an empty list.\n * @throws {Error} If the passed process name is not a valid one\n */\nmethods.getPIDsByName = async function getPIDsByName (name) {\n log.debug(`Getting IDs of all '${name}' processes`);\n if (!this.isValidClass(name)) {\n throw new Error(`Invalid process name: '${name}'`);\n }\n // https://github.com/appium/appium/issues/13567\n if (await this.getApiLevel() >= 23) {\n if (!_.isBoolean(this._isPgrepAvailable)) {\n // pgrep is in priority, since pidof has been reported of having bugs on some platforms\n const pgrepOutput = _.trim(await this.shell(['pgrep --help; echo $?']));\n this._isPgrepAvailable = parseInt(_.last(pgrepOutput.split(/\\s+/)), 10) === 0;\n if (this._isPgrepAvailable) {\n this._canPgrepUseFullCmdLineSearch = /^-f\\b/m.test(pgrepOutput);\n } else {\n this._isPidofAvailable = parseInt(await this.shell(['pidof --help > /dev/null; echo $?']), 10) === 0;\n }\n }\n if (this._isPgrepAvailable || this._isPidofAvailable) {\n const shellCommand = this._isPgrepAvailable\n ? (this._canPgrepUseFullCmdLineSearch\n ? ['pgrep', '-f', _.escapeRegExp(`([[:blank:]]|^)${name}([[:blank:]]|$)`)]\n // https://github.com/appium/appium/issues/13872\n : [`pgrep ^${_.escapeRegExp(name.slice(-MAX_PGREP_PATTERN_LEN))}$ ` +\n `|| pgrep ^${_.escapeRegExp(name.slice(0, MAX_PGREP_PATTERN_LEN))}$`])\n : ['pidof', name];\n try {\n return (await this.shell(shellCommand))\n .split(/\\s+/)\n .map((x) => parseInt(x, 10))\n .filter((x) => _.isInteger(x));\n } catch (e) {\n // error code 1 is returned if the utility did not find any processes\n // with the given name\n if (e.code !== 1) {\n throw new Error(`Could not extract process ID of '${name}': ${e.message}`);\n }\n if (_.includes(e.stderr || e.stdout, 'syntax error')) {\n log.warn(`Got an unexpected response from the shell interpreter: ${e.stderr || e.stdout}`);\n } else {\n return [];\n }\n }\n }\n }\n\n log.debug('Using ps-based PID detection');\n const stdout = await this.listProcessStatus();\n const titleMatch = PS_TITLE_PATTERN.exec(stdout);\n if (!titleMatch) {\n log.debug(stdout);\n throw new Error(`Could not extract PID of '${name}' from ps output`);\n }\n const allTitles = titleMatch[1].trim().split(/\\s+/);\n const pidIndex = allTitles.indexOf(PID_COLUMN_TITLE);\n const pids = [];\n const processNameRegex = new RegExp(`^(.*\\\\b\\\\d+\\\\b.*\\\\b${_.escapeRegExp(name)}\\\\b.*)$`, 'gm');\n let matchedLine;\n while ((matchedLine = processNameRegex.exec(stdout))) {\n const items = matchedLine[1].trim().split(/\\s+/);\n if (pidIndex >= allTitles.length || isNaN(items[pidIndex])) {\n log.debug(stdout);\n throw new Error(`Could not extract PID of '${name}' from '${matchedLine[1].trim()}'`);\n }\n pids.push(parseInt(items[pidIndex], 10));\n }\n return pids;\n};\n\n/**\n * Get the list of process ids for the particular process on the device under test.\n *\n * @param {string} name - The part of process name.\n * @return {Array.<number>} The list of matched process IDs or an empty list.\n */\nmethods.killProcessesByName = async function killProcessesByName (name) {\n try {\n log.debug(`Attempting to kill all ${name} processes`);\n const pids = await this.getPIDsByName(name);\n if (_.isEmpty(pids)) {\n log.info(`No '${name}' process has been found`);\n } else {\n await B.all(pids.map((p) => this.killProcessByPID(p)));\n }\n } catch (e) {\n throw new Error(`Unable to kill ${name} processes. Original error: ${e.message}`);\n }\n};\n\n/**\n * Kill the particular process on the device under test.\n * The current user is automatically switched to root if necessary in order\n * to properly kill the process.\n *\n * @param {string|number} pid - The ID of the process to be killed.\n * @throws {Error} If the process cannot be killed.\n */\nmethods.killProcessByPID = async function killProcessByPID (pid) {\n log.debug(`Attempting to kill process ${pid}`);\n const noProcessFlag = 'No such process';\n try {\n // Check if the process exists and throw an exception otherwise\n await this.shell(['kill', pid]);\n } catch (e) {\n if (_.includes(e.stderr, noProcessFlag)) {\n return;\n }\n if (!_.includes(e.stderr, 'Operation not permitted')) {\n throw e;\n }\n log.info(`Cannot kill PID ${pid} due to insufficient permissions. Retrying as root`);\n try {\n await this.shell(['kill', pid], {\n privileged: true\n });\n } catch (e1) {\n if (_.includes(e1.stderr, noProcessFlag)) {\n return;\n }\n throw e1;\n }\n }\n};\n\n/**\n * Broadcast process killing on the device under test.\n *\n * @param {string} intent - The name of the intent to broadcast to.\n * @param {string} processName - The name of the killed process.\n * @throws {error} If the process was not killed.\n */\nmethods.broadcastProcessEnd = async function broadcastProcessEnd (intent, processName) {\n // start the broadcast without waiting for it to finish.\n this.broadcast(intent);\n // wait for the process to end\n let start = Date.now();\n let timeoutMs = 40000;\n try {\n while ((Date.now() - start) < timeoutMs) {\n if (await this.processExists(processName)) {\n // cool down\n await sleep(400);\n continue;\n }\n return;\n }\n throw new Error(`Process never died within ${timeoutMs} ms`);\n } catch (e) {\n throw new Error(`Unable to broadcast process end. Original error: ${e.message}`);\n }\n};\n\n/**\n * Broadcast a message to the given intent.\n *\n * @param {string} intent - The name of the intent to broadcast to.\n * @throws {error} If intent name is not a valid class name.\n */\nmethods.broadcast = async function broadcast (intent) {\n if (!this.isValidClass(intent)) {\n throw new Error(`Invalid intent ${intent}`);\n }\n log.debug(`Broadcasting: ${intent}`);\n await this.shell(['am', 'broadcast', '-a', intent]);\n};\n\n/**\n * Kill Android instruments if they are currently running.\n */\nmethods.endAndroidCoverage = async function endAndroidCoverage () {\n if (this.instrumentProc && this.instrumentProc.isRunning) {\n await this.instrumentProc.stop();\n }\n};\n\n/**\n * Instrument the particular activity.\n *\n * @param {string} pkg - The name of the package to be instrumented.\n * @param {string} activity - The name of the main activity in this package.\n * @param {string} instrumentWith - The name of the package to instrument\n * the activity with.\n * @throws {error} If any exception is reported by adb shell.\n */\nmethods.instrument = async function instrument (pkg, activity, instrumentWith) {\n if (activity[0] !== '.') {\n pkg = '';\n }\n let pkgActivity = (pkg + activity).replace(/\\.+/g, '.'); // Fix pkg..activity error\n let stdout = await this.shell([\n 'am', 'instrument',\n '-e', 'main_activity',\n pkgActivity,\n instrumentWith,\n ]);\n if (stdout.indexOf('Exception') !== -1) {\n throw new Error(`Unknown exception during instrumentation. Original error ${stdout.split('\\n')[0]}`);\n }\n};\n\n/**\n * Collect Android coverage by instrumenting the particular activity.\n *\n * @param {string} instrumentClass - The name of the instrumentation class.\n * @param {string} waitPkg - The name of the package to be instrumented.\n * @param {string} waitActivity - The name of the main activity in this package.\n *\n * @return {promise} The promise is successfully resolved if the instrumentation starts\n * without errors.\n */\nmethods.androidCoverage = async function androidCoverage (instrumentClass, waitPkg, waitActivity) {\n if (!this.isValidClass(instrumentClass)) {\n throw new Error(`Invalid class ${instrumentClass}`);\n }\n return await new B(async (resolve, reject) => {\n let args = this.executable.defaultArgs\n .concat(['shell', 'am', 'instrument', '-e', 'coverage', 'true', '-w'])\n .concat([instrumentClass]);\n log.debug(`Collecting coverage data with: ${[this.executable.path].concat(args).join(' ')}`);\n try {\n // am instrument runs for the life of the app process.\n this.instrumentProc = new SubProcess(this.executable.path, args);\n await this.instrumentProc.start(0);\n this.instrumentProc.on('output', (stdout, stderr) => {\n if (stderr) {\n reject(new Error(`Failed to run instrumentation. Original error: ${stderr}`));\n }\n });\n await this.waitForActivity(waitPkg, waitActivity);\n resolve();\n } catch (e) {\n reject(new Error(`Android coverage failed. Original error: ${e.message}`));\n }\n });\n};\n\n/**\n * Get the particular property of the device under test.\n *\n * @param {string} property - The name of the property. This name should\n * be known to _adb shell getprop_ tool.\n *\n * @return {string} The value of the given property.\n */\nmethods.getDeviceProperty = async function getDeviceProperty (property) {\n let stdout = await this.shell(['getprop', property]);\n let val = stdout.trim();\n log.debug(`Current device property '${property}': ${val}`);\n return val;\n};\n\n/**\n * @typedef {object} setPropOpts\n * @property {boolean} privileged - Do we run setProp as a privileged command? Default true.\n */\n\n/**\n * Set the particular property of the device under test.\n *\n * @param {string} property - The name of the property. This name should\n * be known to _adb shell setprop_ tool.\n * @param {string} val - The new property value.\n * @param {setPropOpts} opts\n *\n * @throws {error} If _setprop_ utility fails to change property value.\n */\nmethods.setDeviceProperty = async function setDeviceProperty (prop, val, opts = {}) {\n const {privileged = true} = opts;\n log.debug(`Setting device property '${prop}' to '${val}'`);\n await this.shell(['setprop', prop, val], {\n privileged,\n });\n};\n\n/**\n * @return {string} Current system language on the device under test.\n */\nmethods.getDeviceSysLanguage = async function getDeviceSysLanguage () {\n return await this.getDeviceProperty('persist.sys.language');\n};\n\n/**\n * @return {string} Current country name on the device under test.\n */\nmethods.getDeviceSysCountry = async function getDeviceSysCountry () {\n return await this.getDeviceProperty('persist.sys.country');\n};\n\n/**\n * @return {string} Current system locale name on the device under test.\n */\nmethods.getDeviceSysLocale = async function getDeviceSysLocale () {\n return await this.getDeviceProperty('persist.sys.locale');\n};\n\n/**\n * @return {string} Current product language name on the device under test.\n */\nmethods.getDeviceProductLanguage = async function getDeviceProductLanguage () {\n return await this.getDeviceProperty('ro.product.locale.language');\n};\n\n/**\n * @return {string} Current product country name on the device under test.\n */\nmethods.getDeviceProductCountry = async function getDeviceProductCountry () {\n return await this.getDeviceProperty('ro.product.locale.region');\n};\n\n/**\n * @return {string} Current product locale name on the device under test.\n */\nmethods.getDeviceProductLocale = async function getDeviceProductLocale () {\n return await this.getDeviceProperty('ro.product.locale');\n};\n\n/**\n * @return {string} The model name of the device under test.\n */\nmethods.getModel = async function getModel () {\n return await this.getDeviceProperty('ro.product.model');\n};\n\n/**\n * @return {string} The manufacturer name of the device under test.\n */\nmethods.getManufacturer = async function getManufacturer () {\n return await this.getDeviceProperty('ro.product.manufacturer');\n};\n\n/**\n * Get the current screen size.\n *\n * @return {string} Device screen size as string in format 'WxH' or\n * _null_ if it cannot be determined.\n */\nmethods.getScreenSize = async function getScreenSize () {\n let stdout = await this.shell(['wm', 'size']);\n let size = new RegExp(/Physical size: ([^\\r?\\n]+)*/g).exec(stdout);\n if (size && size.length >= 2) {\n return size[1].trim();\n }\n return null;\n};\n\n/**\n * Get the current screen density in dpi\n *\n * @return {?number} Device screen density as a number or _null_ if it\n * cannot be determined\n */\nmethods.getScreenDensity = async function getScreenDensity () {\n let stdout = await this.shell(['wm', 'density']);\n let density = new RegExp(/Physical density: ([^\\r?\\n]+)*/g).exec(stdout);\n if (density && density.length >= 2) {\n let densityNumber = parseInt(density[1].trim(), 10);\n return isNaN(densityNumber) ? null : densityNumber;\n }\n return null;\n};\n\n/**\n * Setup HTTP proxy in device global settings.\n * Read https://android.googlesource.com/platform/frameworks/base/+/android-9.0.0_r21/core/java/android/provider/Settings.java for each property\n *\n * @param {string} proxyHost - The host name of the proxy.\n * @param {string|number} proxyPort - The port number to be set.\n */\nmethods.setHttpProxy = async function setHttpProxy (proxyHost, proxyPort) {\n let proxy = `${proxyHost}:${proxyPort}`;\n if (_.isUndefined(proxyHost)) {\n throw new Error(`Call to setHttpProxy method with undefined proxy_host: ${proxy}`);\n }\n if (_.isUndefined(proxyPort)) {\n throw new Error(`Call to setHttpProxy method with undefined proxy_port ${proxy}`);\n }\n\n const httpProxySettins = [\n ['http_proxy', proxy],\n ['global_http_proxy_host', proxyHost],\n ['global_http_proxy_port', proxyPort]\n ];\n for (const [settingKey, settingValue] of httpProxySettins) {\n await this.setSetting('global', settingKey, settingValue);\n }\n};\n\n/**\n * Delete HTTP proxy in device global settings.\n * Rebooting the test device is necessary to apply the change.\n */\nmethods.deleteHttpProxy = async function deleteHttpProxy () {\n const httpProxySettins = [\n 'http_proxy',\n 'global_http_proxy_host',\n 'global_http_proxy_port',\n 'global_http_proxy_exclusion_list' // `global_http_proxy_exclusion_list=` was generated by `settings global htto_proxy xxxx`\n ];\n for (const setting of httpProxySettins) {\n await this.shell(['settings', 'delete', 'global', setting]);\n }\n};\n\n/**\n * Set device property.\n * [android.provider.Settings]{@link https://developer.android.com/reference/android/provider/Settings.html}\n *\n * @param {string} namespace - one of {system, secure, global}, case-insensitive.\n * @param {string} setting - property name.\n * @param {string|number} value - property value.\n * @return {string} command output.\n */\nmethods.setSetting = async function setSetting (namespace, setting, value) {\n return await this.shell(['settings', 'put', namespace, setting, value]);\n};\n\n/**\n * Get device property.\n * [android.provider.Settings]{@link https://developer.android.com/reference/android/provider/Settings.html}\n *\n * @param {string} namespace - one of {system, secure, global}, case-insensitive.\n * @param {string} setting - property name.\n * @return {string} property value.\n */\nmethods.getSetting = async function getSetting (namespace, setting) {\n return await this.shell(['settings', 'get', namespace, setting]);\n};\n\n/**\n * Retrieve the `adb bugreport` command output. This\n * operation may take up to several minutes.\n *\n * @param {?number} timeout [120000] - Command timeout in milliseconds\n * @returns {string} Command stdout\n */\nmethods.bugreport = async function bugreport (timeout = 120000) {\n return await this.adbExec(['bugreport'], {timeout});\n};\n\n/**\n * @typedef {Object} ScreenrecordOptions\n * @property {?string} videoSize - The format is widthxheight.\n * The default value is the device's native display resolution (if supported),\n * 1280x720 if not. For best results,\n * use a size supported by your device's Advanced Video Coding (AVC) encoder.\n * For example, \"1280x720\"\n * @property {?boolean} bugReport - Set it to `true` in order to display additional information on the video overlay,\n * such as a timestamp, that is helpful in videos captured to illustrate bugs.\n * This option is only supported since API level 27 (Android P).\n * @property {?string|number} timeLimit - The maximum recording time, in seconds.\n * The default (and maximum) value is 180 (3 minutes).\n * @property {?string|number} bitRate - The video bit rate for the video, in megabits per second.\n * The default value is 4. You can increase the bit rate to improve video quality,\n * but doing so results in larger movie files.\n */\n\n/**\n * Initiate screenrecord utility on the device\n *\n * @param {string} destination - Full path to the writable media file destination\n * on the device file system.\n * @param {?ScreenrecordOptions} options [{}]\n * @returns {SubProcess} screenrecord process, which can be then controlled by the client code\n */\nmethods.screenrecord = function screenrecord (destination, options = {}) {\n const cmd = ['screenrecord'];\n const {\n videoSize,\n bitRate,\n timeLimit,\n bugReport,\n } = options;\n if (util.hasValue(videoSize)) {\n cmd.push('--size', videoSize);\n }\n if (util.hasValue(timeLimit)) {\n cmd.push('--time-limit', timeLimit);\n }\n if (util.hasValue(bitRate)) {\n cmd.push('--bit-rate', bitRate);\n }\n if (bugReport) {\n cmd.push('--bugreport');\n }\n cmd.push(destination);\n\n const fullCmd = [\n ...this.executable.defaultArgs,\n 'shell',\n ...cmd\n ];\n log.debug(`Building screenrecord process with the command line: adb ${util.quote(fullCmd)}`);\n return new SubProcess(this.executable.path, fullCmd);\n};\n\n/**\n * Executes the given function with the given input method context\n * and then restores the IME to the original value\n *\n * @param {string} ime - Valid IME identifier\n * @param {Function} fn - Function to execute\n * @returns {*} The result of the given function\n */\nmethods.runInImeContext = async function runInImeContext (ime, fn) {\n const originalIme = await this.defaultIME();\n if (originalIme === ime) {\n log.debug(`The original IME is the same as '${ime}'. There is no need to reset it`);\n } else {\n await this.enableIME(ime);\n await this.setIME(ime);\n // https://github.com/appium/appium/issues/15943\n await B.delay(500);\n }\n try {\n return await fn();\n } finally {\n if (originalIme !== ime) {\n await this.setIME(originalIme);\n }\n }\n};\n\n/**\n * Get tz database time zone formatted timezone\n *\n * @returns {string} TZ database Time Zones format\n *\n * @throws {error} If any exception is reported by adb shell.\n */\nmethods.getTimeZone = async function getTimeZone () {\n log.debug('Getting current timezone');\n try {\n return await this.getDeviceProperty('persist.sys.timezone');\n } catch (e) {\n throw new Error(`Error getting timezone. Original error: ${e.message}`);\n }\n};\n\n/**\n * Retrieves the list of features supported by the device under test\n *\n * @returns {Array<string>} the list of supported feature names or an empty list.\n * An example adb command output:\n * ```\n * cmd\n * ls_v2\n * fixed_push_mkdir\n * shell_v2\n * abb\n * stat_v2\n * apex\n * abb_exec\n * remount_shell\n * fixed_push_symlink_timestamp\n * ```\n * @throws {Error} if there was an error while retrieving the list\n */\nmethods.listFeatures = async function listFeatures () {\n this._memoizedFeatures = this._memoizedFeatures\n || _.memoize(async () => await this.adbExec(['features']), () => this.curDeviceId);\n try {\n return (await this._memoizedFeatures())\n .split(/\\s+/)\n .map((x) => x.trim())\n .filter(Boolean);\n } catch (e) {\n if (_.includes(e.stderr, 'unknown command')) {\n return [];\n }\n throw e;\n }\n};\n\n/**\n * Checks the state of streamed install feature.\n * This feature allows to speed up apk installation\n * since it does not require the original apk to be pushed to\n * the device under test first, which also saves space.\n * Although, it is required that both the device under test\n * and the adb server have the mentioned functionality.\n * See https://github.com/aosp-mirror/platform_system_core/blob/master/adb/client/adb_install.cpp\n * for more details\n *\n * @returns {boolean} `true` if the feature is supported by both adb and the\n * device under test\n */\nmethods.isStreamedInstallSupported = async function isStreamedInstallSupported () {\n const proto = Object.getPrototypeOf(this);\n proto._helpOutput = proto._helpOutput || await this.adbExec(['help']);\n return proto._helpOutput.includes('--streaming')\n && (await this.listFeatures()).includes('cmd');\n};\n\n/**\n * Checks whether incremental install feature is supported by ADB.\n * Read https://developer.android.com/preview/features#incremental\n * for more details on it.\n *\n * @returns {boolean} `true` if the feature is supported by both adb and the\n * device under test\n */\nmethods.isIncrementalInstallSupported = async function isIncrementalInstallSupported () {\n const {binary} = await this.getVersion();\n if (!binary) {\n return false;\n }\n return util.compareVersions(binary.version, '>=', '30.0.1')\n && (await this.listFeatures()).includes('abb_exec');\n};\n\n/**\n * Retrieves the list of packages from Doze whitelist on Android 8+\n *\n * @returns {Array<string>} The list of whitelisted packages. An example output:\n * system,com.android.shell,2000\n * system,com.google.android.cellbroadcastreceiver,10143\n * user,io.appium.settings,10157\n */\nmethods.getDeviceIdleWhitelist = async function getDeviceIdleWhitelist () {\n if (await this.getApiLevel() < 23) {\n // Doze mode has only been added since Android 6\n return [];\n }\n\n log.info('Listing packages in Doze whitelist');\n const output = await this.shell(['dumpsys', 'deviceidle', 'whitelist']);\n return _.trim(output).split(/\\n/)\n .map((line) => _.trim(line))\n .filter(Boolean);\n};\n\n/**\n * Adds an existing package(s) into the Doze whitelist on Android 8+\n *\n * @param {...string} packages One or more packages to add. If the package\n * already exists in the whitelist then it is only going to be added once.\n * If the package with the given name is not installed/not known then an error\n * will be thrown.\n * @returns {Boolean} `true` if the command to add package(s) has been executed\n */\nmethods.addToDeviceIdleWhitelist = async function addToDeviceIdleWhitelist (...packages) {\n if (_.isEmpty(packages) || await this.getApiLevel() < 23) {\n // Doze mode has only been added since Android 6\n return false;\n }\n\n log.info(`Adding ${util.pluralize('package', packages.length)} ${JSON.stringify(packages)} to Doze whitelist`);\n await this.shellChunks((pkg) => ['dumpsys', 'deviceidle', 'whitelist', `+${pkg}`], packages);\n return true;\n};\n\nexport default methods;\n"],"mappings":";;;;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,uBAAuB,GAAG,IAAI;AACpC,MAAMC,yBAAyB,GAAG,mCAAmC;AACrE,MAAMC,mBAAmB,GAAG,CAC1BD,yBAAyB,EACzB,qBAAqB,CACtB;AACD,MAAME,qBAAqB,GAAG,EAAE;AAChC,MAAMC,sBAAsB,GAAG,CAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,mBAAmB,CACpB;AACD,MAAMC,gBAAgB,GAAG,KAAK;AAC9B,MAAMC,yBAAyB,GAAG,MAAM;AACxC,MAAMC,gBAAgB,GAAG,IAAIC,MAAM,CAAE,UAASH,gBAAiB,WAAUC,yBAA0B,SAAQ,EAAE,GAAG,CAAC;AACjH,MAAMG,gCAAgC,GAAG,EAAE;AAE3C,MAAMC,OAAO,GAAG,CAAC,CAAC;;AAgBlBA,OAAO,CAACC,WAAW,GAAG,eAAeA,WAAW,CAAEC,cAAc,EAAEC,IAAI,EAAE;EACtE,MAAMC,QAAQ,GAAG,EAAE;EACnB,IAAIC,QAAQ,GAAG,EAAE;EACjB,KAAK,MAAMC,GAAG,IAAIH,IAAI,EAAE;IACtB,MAAMI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