appium-android-driver 5.11.1 → 5.11.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","names":["_androidHelpers","_interopRequireDefault","require","_support","_path","_bluebird","_jimp","_teen_process","_utils","swipeStepsPerSec","dragStepsPerSec","commands","helpers","extensions","exports","keyevent","keycode","metastate","log","warn","pressKeyCode","bootstrap","sendAction","longPressKeyCode","getOrientation","params","naturalOrientation","opts","androidNaturalOrientation","orientation","toUpperCase","setOrientation","fakeFlick","xSpeed","ySpeed","fakeFlickElement","elementId","xoffset","yoffset","speed","swipe","startX","startY","endX","endY","duration","touchCount","elId","swipeOpts","steps","Math","round","util","hasValue","doSwipe","pinchClose","percent","pinchOpts","direction","pinchOpen","flick","element","xOffset","yOffset","drag","destElId","dragOpts","doDrag","lock","seconds","adb","isNaN","floatSeconds","parseFloat","B","delay","unlock","isLocked","isScreenLocked","androidHelpers","caps","openNotifications","setLocation","latitude","longitude","sendTelnetCommand","fingerprint","fingerprintId","isEmulator","errorAndThrow","mobileFingerprint","requireArgs","sendSMS","phoneNumber","message","mobileSendSms","gsmCall","action","mobileGsmCall","gsmSignal","signalStrengh","mobileGsmSignal","strength","gsmVoice","state","mobileGsmVoice","powerAC","mobilePowerAc","powerCapacity","batteryPercent","mobilePowerCapacity","networkSpeed","mobileNetworkSpeed","sensorSet","sensor","sensorType","value","getScreenshotDataWithAdbShell","localFile","tempDir","path","prefix","suffix","fs","exists","unlink","pngDir","androidScreenshotPath","png","posix","resolve","cmd","shell","fileSize","Error","pull","jimp","read","getScreenshotDataWithAdbExecOut","stdout","stderr","code","exec","executable","defaultArgs","concat","encoding","isBuffer","length","toString","getScreenshot","apiLevel","getApiLevel","image","e","info","err","screenOrientation","getScreenOrientation","rotate","getBuffer","promisify","context","imgBuffer","MIME_PNG","Object","assign","_default","default"],"sources":["../../../lib/commands/actions.js"],"sourcesContent":["import androidHelpers from '../android-helpers';\nimport { fs, util, tempDir} from '@appium/support';\nimport path from 'path';\nimport B from 'bluebird';\nimport jimp from 'jimp';\nimport { exec } from 'teen_process';\nimport { requireArgs } from '../utils';\n\nconst swipeStepsPerSec = 28;\nconst dragStepsPerSec = 40;\n\nlet commands = {}, helpers = {}, extensions = {};\n\ncommands.keyevent = async function keyevent (keycode, metastate = null) {\n // TODO deprecate keyevent; currently wd only implements keyevent\n this.log.warn('keyevent will be deprecated use pressKeyCode');\n return await this.pressKeyCode(keycode, metastate);\n};\n\ncommands.pressKeyCode = async function pressKeyCode (keycode, metastate = null) {\n return await this.bootstrap.sendAction('pressKeyCode', {keycode, metastate});\n};\n\ncommands.longPressKeyCode = async function longPressKeyCode (keycode, metastate = null) {\n return await this.bootstrap.sendAction('longPressKeyCode', {keycode, metastate});\n};\n\ncommands.getOrientation = async function getOrientation () {\n let params = {\n naturalOrientation: !!this.opts.androidNaturalOrientation,\n };\n let orientation = await this.bootstrap.sendAction('orientation', params);\n return orientation.toUpperCase();\n};\n\ncommands.setOrientation = async function setOrientation (orientation) {\n orientation = orientation.toUpperCase();\n let params = {\n orientation,\n naturalOrientation: !!this.opts.androidNaturalOrientation,\n };\n return await this.bootstrap.sendAction('orientation', params);\n};\n\ncommands.fakeFlick = async function fakeFlick (xSpeed, ySpeed) {\n return await this.bootstrap.sendAction('flick', {xSpeed, ySpeed});\n};\n\ncommands.fakeFlickElement = async function fakeFlickElement (elementId, xoffset, yoffset, speed) {\n let params = {xoffset, yoffset, speed, elementId};\n return await this.bootstrap.sendAction('element:flick', params);\n};\n\ncommands.swipe = async function swipe (startX, startY, endX, endY, duration, touchCount, elId) {\n if (startX === 'null') {\n startX = 0.5;\n }\n if (startY === 'null') {\n startY = 0.5;\n }\n let swipeOpts = {startX, startY, endX, endY,\n steps: Math.round(duration * swipeStepsPerSec)};\n // going the long way and checking for undefined and null since\n // we can't be assured `elId` is a string and not an int\n if (util.hasValue(elId)) {\n swipeOpts.elementId = elId;\n }\n return await this.doSwipe(swipeOpts);\n};\n\ncommands.doSwipe = async function doSwipe (swipeOpts) {\n if (util.hasValue(swipeOpts.elementId)) {\n return await this.bootstrap.sendAction('element:swipe', swipeOpts);\n } else {\n return await this.bootstrap.sendAction('swipe', swipeOpts);\n }\n};\n\ncommands.pinchClose = async function pinchClose (startX, startY, endX, endY, duration, percent, steps, elId) {\n let pinchOpts = {\n direction: 'in',\n elementId: elId,\n percent,\n steps\n };\n return await this.bootstrap.sendAction('element:pinch', pinchOpts);\n};\n\ncommands.pinchOpen = async function pinchOpen (startX, startY, endX, endY, duration, percent, steps, elId) {\n let pinchOpts = {direction: 'out', elementId: elId, percent, steps};\n return await this.bootstrap.sendAction('element:pinch', pinchOpts);\n};\n\ncommands.flick = async function flick (element, xSpeed, ySpeed, xOffset, yOffset, speed) {\n if (element) {\n await this.fakeFlickElement(element, xOffset, yOffset, speed);\n } else {\n await this.fakeFlick(xSpeed, ySpeed);\n }\n};\n\ncommands.drag = async function drag (startX, startY, endX, endY, duration, touchCount, elementId, destElId) {\n let dragOpts = {\n elementId, destElId, startX, startY, endX, endY,\n steps: Math.round(duration * dragStepsPerSec)\n };\n return await this.doDrag(dragOpts);\n\n};\n\ncommands.doDrag = async function doDrag (dragOpts) {\n if (util.hasValue(dragOpts.elementId)) {\n return await this.bootstrap.sendAction('element:drag', dragOpts);\n } else {\n return await this.bootstrap.sendAction('drag', dragOpts);\n }\n};\n\ncommands.lock = async function lock (seconds) {\n await this.adb.lock();\n if (isNaN(seconds)) {\n return;\n }\n\n const floatSeconds = parseFloat(seconds);\n if (floatSeconds <= 0) {\n return;\n }\n await B.delay(1000 * floatSeconds);\n await this.unlock();\n};\n\ncommands.isLocked = async function isLocked () {\n return await this.adb.isScreenLocked();\n};\n\ncommands.unlock = async function unlock () {\n return await androidHelpers.unlock(this, this.adb, this.caps);\n};\n\ncommands.openNotifications = async function openNotifications () {\n return await this.bootstrap.sendAction('openNotification');\n};\n\ncommands.setLocation = async function setLocation (latitude, longitude) {\n return await this.adb.sendTelnetCommand(`geo fix ${longitude} ${latitude}`);\n};\n\ncommands.fingerprint = async function fingerprint (fingerprintId) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('fingerprint method is only available for emulators');\n }\n await this.adb.fingerprint(fingerprintId);\n};\n\n/**\n * @typedef {Object} FingerprintOpts\n * @param {string|number} fingerprintId The value is the finger_id for the finger that\n * was \"scanned\". It is a unique integer that you assign for each virtual fingerprint.\n * When the app is running you can run this same command each time the\n * emulator prompts you for a fingerprint, you can run the adb command and pass it\n * the finger_id to simulate the fingerprint scan.\n */\n\n/**\n * Emulate fingerprint on Android Emulator.\n * Only works on API 23+\n *\n * @param {FingerprintOpts} opts\n */\ncommands.mobileFingerprint = async function mobileFingerprint(opts = {}) {\n const {fingerprintId} = requireArgs('fingerprintId', opts);\n await this.fingerprint(fingerprintId);\n};\n\ncommands.sendSMS = async function sendSMS (phoneNumber, message) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('sendSMS method is only available for emulators');\n }\n await this.adb.sendSMS(phoneNumber, message);\n};\n\n/**\n * @typedef {Object} SendSmsOptions\n * @property {string} phoneNumber The phone number to send SMS to\n * @property {string} message The message payload\n */\n\n/**\n * Emulate sending an SMS to the given phone number.\n * Only works on emulators.\n *\n * @param {SendSmsOptions} opts\n */\ncommands.mobileSendSms = async function mobileSendSms(opts = {}) {\n const {phoneNumber, message} = requireArgs(['phoneNumber', 'message'], opts);\n await this.sendSMS(phoneNumber, message);\n};\n\ncommands.gsmCall = async function gsmCall (phoneNumber, action) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('gsmCall method is only available for emulators');\n }\n await this.adb.gsmCall(phoneNumber, action);\n};\n\n/**\n * @typedef {Object} GsmCallOptions\n * @property {string} phoneNumber The phone number to call to\n * @property {call|accept|cancel|hold} action One of possible actions to take\n */\n\n/**\n * Emulate a GSM call to the given phone number.\n * Only works on emulators.\n *\n * @param {GsmCallOptions} opts\n */\ncommands.mobileGsmCall = async function mobileGsmCall(opts = {}) {\n const {phoneNumber, action} = requireArgs(['phoneNumber', 'action'], opts);\n await this.gsmCall(phoneNumber, action);\n};\n\ncommands.gsmSignal = async function gsmSignal (signalStrengh) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('gsmSignal method is only available for emulators');\n }\n await this.adb.gsmSignal(signalStrengh);\n};\n\n/**\n * @typedef {Object} GsmSignalOptions\n * @property {0|1|2|3|4} strength One of possible signal strength values, where 4 is the best signal.\n */\n\n/**\n * Emulate GSM signal strength change event.\n * Only works on emulators.\n *\n * @param {GsmSignalOptions} opts\n */\ncommands.mobileGsmSignal = async function mobileGsmSignal(opts = {}) {\n const {strength} = requireArgs('strength', opts);\n await this.gsmSignal(strength);\n};\n\ncommands.gsmVoice = async function gsmVoice (state) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('gsmVoice method is only available for emulators');\n }\n await this.adb.gsmVoice(state);\n};\n\n/**\n * @typedef {Object} GsmVoiceOptions\n * @property {on|off} state\n */\n\n/**\n * Emulate GSM voice state change event.\n * Only works on emulators.\n *\n * @param {GsmVoiceOptions} opts\n */\ncommands.mobileGsmVoice = async function mobileGsmVoice(opts = {}) {\n const {state} = requireArgs('state', opts);\n await this.gsmVoice(state);\n};\n\ncommands.powerAC = async function powerAC (state) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('powerAC method is only available for emulators');\n }\n await this.adb.powerAC(state);\n};\n\n/**\n * @typedef {Object} PowerAcOptions\n * @property {on|off} state\n */\n\n/**\n * Emulate AC power state change.\n * Only works on emulators.\n *\n * @param {GsmVoiceOptions} opts\n */\ncommands.mobilePowerAc = async function mobilePowerAc(opts = {}) {\n const {state} = requireArgs('state', opts);\n await this.powerAC(state);\n};\n\ncommands.powerCapacity = async function powerCapacity (batteryPercent) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('powerCapacity method is only available for emulators');\n }\n await this.adb.powerCapacity(batteryPercent);\n};\n\n/**\n * @typedef {Object} PowerCapacityOptions\n * @property {number} percent - Percentage value in range [0, 100]\n */\n\n/**\n * Emulate power capacity change.\n * Only works on emulators.\n *\n * @param {PowerCapacityOptions} opts\n */\ncommands.mobilePowerCapacity = async function mobilePowerCapacity(opts = {}) {\n const {percent} = requireArgs('percent', opts);\n await this.powerCapacity(percent);\n};\n\ncommands.networkSpeed = async function networkSpeed (networkSpeed) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('networkSpeed method is only available for emulators');\n }\n await this.adb.networkSpeed(networkSpeed);\n};\n\n/**\n * @typedef {Object} NetworkSpeedOptions\n * @property {gsm|scsd|gprs|edge|umts|hsdpa|lte|evdo|full} speed\n */\n\n/**\n * Emulate different network connection speed modes.\n * Only works on emulators.\n *\n * @param {NetworkSpeedOptions} opts\n */\ncommands.mobileNetworkSpeed = async function mobileNetworkSpeed(opts = {}) {\n const {speed} = requireArgs('speed', opts);\n await this.networkSpeed(speed);\n};\n\n/**\n * Emulate sensors values on the connected emulator.\n *\n * @typedef {Object} Sensor\n * @property {string} sensorType - sensor type declared in adb.SENSORS\n * @property {string} value - value to set to the sensor\n *\n * @param {Object} Sensor\n * @throws {Error} - If sensorType is not defined\n * @throws {Error} - If value for the se sor is not defined\n * @throws {Error} - If deviceType is not an emulator\n */\ncommands.sensorSet = async function sensorSet (sensor = {}) {\n const {sensorType, value} = sensor;\n if (!util.hasValue(sensorType)) {\n this.log.errorAndThrow(`'sensorType' argument is required`);\n }\n if (!util.hasValue(value)) {\n this.log.errorAndThrow(`'value' argument is required`);\n }\n if (!this.isEmulator()) {\n this.log.errorAndThrow('sensorSet method is only available for emulators');\n }\n await this.adb.sensorSet(sensorType, value);\n};\n\nhelpers.getScreenshotDataWithAdbShell = async function getScreenshotDataWithAdbShell (adb, opts) {\n const localFile = await tempDir.path({prefix: 'appium', suffix: '.png'});\n if (await fs.exists(localFile)) {\n await fs.unlink(localFile);\n }\n try {\n const pngDir = opts.androidScreenshotPath || '/data/local/tmp/';\n const png = path.posix.resolve(pngDir, 'screenshot.png');\n const cmd = ['/system/bin/rm', `${png};`, '/system/bin/screencap', '-p', png];\n await adb.shell(cmd);\n if (!await adb.fileSize(png)) {\n throw new Error('The size of the taken screenshot equals to zero.');\n }\n await adb.pull(png, localFile);\n return await jimp.read(localFile);\n } finally {\n if (await fs.exists(localFile)) {\n await fs.unlink(localFile);\n }\n }\n};\n\nhelpers.getScreenshotDataWithAdbExecOut = async function getScreenshotDataWithAdbExecOut (adb) {\n let {stdout, stderr, code} = await exec(adb.executable.path,\n adb.executable.defaultArgs\n .concat(['exec-out', '/system/bin/screencap', '-p']),\n {encoding: 'binary', isBuffer: true});\n // if there is an error, throw\n if (code || stderr.length) {\n throw new Error(`Screenshot returned error, code: '${code}', stderr: '${stderr.toString()}'`);\n }\n // if we don't get anything at all, throw\n if (!stdout.length) {\n throw new Error('Screenshot returned no data');\n }\n\n return await jimp.read(stdout);\n};\n\ncommands.getScreenshot = async function getScreenshot () {\n const apiLevel = await this.adb.getApiLevel();\n let image = null;\n if (apiLevel > 20) {\n try {\n // This screenshoting approach is way faster, since it requires less external commands\n // to be executed. Unfortunately, exec-out option is only supported by newer Android/SDK versions (5.0 and later)\n image = await this.getScreenshotDataWithAdbExecOut(this.adb);\n } catch (e) {\n this.log.info(`Cannot get screenshot data with 'adb exec-out' because of '${e.message}'. ` +\n `Defaulting to 'adb shell' call`);\n }\n }\n if (!image) {\n try {\n image = await this.getScreenshotDataWithAdbShell(this.adb, this.opts);\n } catch (e) {\n const err = `Cannot get screenshot data because of '${e.message}'. ` +\n `Make sure the 'LayoutParams.FLAG_SECURE' is not set for ` +\n `the current view`;\n this.log.errorAndThrow(err);\n }\n }\n if (apiLevel < 23) {\n // Android bug 8433742 - rotate screenshot if screen is rotated\n let screenOrientation = await this.adb.getScreenOrientation();\n try {\n image = await image.rotate(-90 * screenOrientation);\n } catch (err) {\n this.log.warn(`Could not rotate screenshot due to error: ${err}`);\n }\n }\n const getBuffer = B.promisify(image.getBuffer, {context: image});\n const imgBuffer = await getBuffer(jimp.MIME_PNG);\n return imgBuffer.toString('base64');\n};\n\nObject.assign(extensions, commands, helpers);\nexport { commands, helpers };\nexport default extensions;\n"],"mappings":";;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA,MAAMO,gBAAgB,GAAG,EAAE;AAC3B,MAAMC,eAAe,GAAG,EAAE;AAE1B,IAAIC,QAAQ,GAAG,CAAC,CAAC;EAAEC,OAAO,GAAG,CAAC,CAAC;EAAEC,UAAU,GAAG,CAAC,CAAC;AAACC,OAAA,CAAAF,OAAA,GAAAA,OAAA;AAAAE,OAAA,CAAAH,QAAA,GAAAA,QAAA;AAEjDA,QAAQ,CAACI,QAAQ,GAAG,eAAeA,QAAQA,CAAEC,OAAO,EAAEC,SAAS,GAAG,IAAI,EAAE;EAEtE,IAAI,CAACC,GAAG,CAACC,IAAI,CAAC,8CAA8C,CAAC;EAC7D,OAAO,MAAM,IAAI,CAACC,YAAY,CAACJ,OAAO,EAAEC,SAAS,CAAC;AACpD,CAAC;AAEDN,QAAQ,CAACS,YAAY,GAAG,eAAeA,YAAYA,CAAEJ,OAAO,EAAEC,SAAS,GAAG,IAAI,EAAE;EAC9E,OAAO,MAAM,IAAI,CAACI,SAAS,CAACC,UAAU,CAAC,cAAc,EAAE;IAACN,OAAO;IAAEC;EAAS,CAAC,CAAC;AAC9E,CAAC;AAEDN,QAAQ,CAACY,gBAAgB,GAAG,eAAeA,gBAAgBA,CAAEP,OAAO,EAAEC,SAAS,GAAG,IAAI,EAAE;EACtF,OAAO,MAAM,IAAI,CAACI,SAAS,CAACC,UAAU,CAAC,kBAAkB,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E,GAAG,CAAC;IAC7B;EACF;EACA,IAAIL,QAAQ,GAAG,EAAE,EAAE;IAEjB,IAAIM,iBAAiB,GAAG,MAAM,IAAI,CAACvF,GAAG,CAACwF,oBAAoB,CAAC,CAAC;IAC7D,IAAI;MACFL,KAAK,GAAG,MAAMA,KAAK,CAACM,MAAM,CAAC,CAAC,EAAE,GAAGF,iBAAiB,CAAC;IACrD,CAAC,CAAC,OAAOD,GAAG,EAAE;MACZ,IAAI,CAAC1I,GAAG,CAACC,IAAI,CAAE,6CAA4CyI,GAAI,EAAC,CAAC;IACnE;EACF;EACA,MAAMI,SAAS,GAAGtF,iBAAC,CAACuF,SAAS,CAACR,KAAK,CAACO,SAAS,EAAE;IAACE,OAAO,EAAET;EAAK,CAAC,CAAC;EAChE,MAAMU,SAAS,GAAG,MAAMH,SAAS,CAACxB,aAAI,CAAC4B,QAAQ,CAAC;EAChD,OAAOD,SAAS,CAACd,QAAQ,CAAC,QAAQ,CAAC;AACrC,CAAC;AAEDgB,MAAM,CAACC,MAAM,CAACzJ,UAAU,EAAEF,QAAQ,EAAEC,OAAO,CAAC;AAAC,IAAA2J,QAAA,GAE9B1J,UAAU;AAAAC,OAAA,CAAA0J,OAAA,GAAAD,QAAA"}
1
+ {"version":3,"file":"actions.js","names":["_androidHelpers","_interopRequireDefault","require","_support","_path","_bluebird","_sharp","_teen_process","_utils","swipeStepsPerSec","dragStepsPerSec","commands","exports","helpers","extensions","keyevent","keycode","metastate","log","warn","pressKeyCode","bootstrap","sendAction","longPressKeyCode","getOrientation","params","naturalOrientation","opts","androidNaturalOrientation","orientation","toUpperCase","setOrientation","fakeFlick","xSpeed","ySpeed","fakeFlickElement","elementId","xoffset","yoffset","speed","swipe","startX","startY","endX","endY","duration","touchCount","elId","swipeOpts","steps","Math","round","util","hasValue","doSwipe","pinchClose","percent","pinchOpts","direction","pinchOpen","flick","element","xOffset","yOffset","drag","destElId","dragOpts","doDrag","lock","seconds","adb","isNaN","floatSeconds","parseFloat","B","delay","unlock","isLocked","isScreenLocked","androidHelpers","caps","openNotifications","setLocation","latitude","longitude","sendTelnetCommand","fingerprint","fingerprintId","isEmulator","errorAndThrow","mobileFingerprint","requireArgs","sendSMS","phoneNumber","message","mobileSendSms","gsmCall","action","mobileGsmCall","gsmSignal","signalStrengh","mobileGsmSignal","strength","gsmVoice","state","mobileGsmVoice","powerAC","mobilePowerAc","powerCapacity","batteryPercent","mobilePowerCapacity","networkSpeed","mobileNetworkSpeed","sensorSet","sensor","sensorType","value","getScreenshotDataWithAdbShell","localFile","tempDir","path","prefix","suffix","fs","exists","unlink","pngDir","androidScreenshotPath","png","posix","resolve","shell","fileSize","Error","pull","sharp","getScreenshotDataWithAdbExecOut","stdout","stderr","code","exec","executable","defaultArgs","encoding","isBuffer","length","toString","getScreenshot","apiLevel","getApiLevel","image","e","info","err","screenOrientation","getScreenOrientation","rotate","toBuffer","Object","assign","_default","default"],"sources":["../../../lib/commands/actions.js"],"sourcesContent":["import androidHelpers from '../android-helpers';\nimport { fs, util, tempDir} from '@appium/support';\nimport path from 'path';\nimport B from 'bluebird';\nimport sharp from 'sharp';\nimport { exec } from 'teen_process';\nimport { requireArgs } from '../utils';\n\nconst swipeStepsPerSec = 28;\nconst dragStepsPerSec = 40;\n\nconst commands = {};\nconst helpers = {};\nconst extensions = {};\n\ncommands.keyevent = async function keyevent (keycode, metastate = null) {\n // TODO deprecate keyevent; currently wd only implements keyevent\n this.log.warn('keyevent will be deprecated use pressKeyCode');\n return await this.pressKeyCode(keycode, metastate);\n};\n\ncommands.pressKeyCode = async function pressKeyCode (keycode, metastate = null) {\n return await this.bootstrap.sendAction('pressKeyCode', {keycode, metastate});\n};\n\ncommands.longPressKeyCode = async function longPressKeyCode (keycode, metastate = null) {\n return await this.bootstrap.sendAction('longPressKeyCode', {keycode, metastate});\n};\n\ncommands.getOrientation = async function getOrientation () {\n let params = {\n naturalOrientation: !!this.opts.androidNaturalOrientation,\n };\n let orientation = await this.bootstrap.sendAction('orientation', params);\n return orientation.toUpperCase();\n};\n\ncommands.setOrientation = async function setOrientation (orientation) {\n orientation = orientation.toUpperCase();\n let params = {\n orientation,\n naturalOrientation: !!this.opts.androidNaturalOrientation,\n };\n return await this.bootstrap.sendAction('orientation', params);\n};\n\ncommands.fakeFlick = async function fakeFlick (xSpeed, ySpeed) {\n return await this.bootstrap.sendAction('flick', {xSpeed, ySpeed});\n};\n\ncommands.fakeFlickElement = async function fakeFlickElement (elementId, xoffset, yoffset, speed) {\n let params = {xoffset, yoffset, speed, elementId};\n return await this.bootstrap.sendAction('element:flick', params);\n};\n\ncommands.swipe = async function swipe (startX, startY, endX, endY, duration, touchCount, elId) {\n if (startX === 'null') {\n startX = 0.5;\n }\n if (startY === 'null') {\n startY = 0.5;\n }\n let swipeOpts = {startX, startY, endX, endY,\n steps: Math.round(duration * swipeStepsPerSec)};\n // going the long way and checking for undefined and null since\n // we can't be assured `elId` is a string and not an int\n if (util.hasValue(elId)) {\n swipeOpts.elementId = elId;\n }\n return await this.doSwipe(swipeOpts);\n};\n\ncommands.doSwipe = async function doSwipe (swipeOpts) {\n if (util.hasValue(swipeOpts.elementId)) {\n return await this.bootstrap.sendAction('element:swipe', swipeOpts);\n } else {\n return await this.bootstrap.sendAction('swipe', swipeOpts);\n }\n};\n\ncommands.pinchClose = async function pinchClose (startX, startY, endX, endY, duration, percent, steps, elId) {\n let pinchOpts = {\n direction: 'in',\n elementId: elId,\n percent,\n steps\n };\n return await this.bootstrap.sendAction('element:pinch', pinchOpts);\n};\n\ncommands.pinchOpen = async function pinchOpen (startX, startY, endX, endY, duration, percent, steps, elId) {\n let pinchOpts = {direction: 'out', elementId: elId, percent, steps};\n return await this.bootstrap.sendAction('element:pinch', pinchOpts);\n};\n\ncommands.flick = async function flick (element, xSpeed, ySpeed, xOffset, yOffset, speed) {\n if (element) {\n await this.fakeFlickElement(element, xOffset, yOffset, speed);\n } else {\n await this.fakeFlick(xSpeed, ySpeed);\n }\n};\n\ncommands.drag = async function drag (startX, startY, endX, endY, duration, touchCount, elementId, destElId) {\n let dragOpts = {\n elementId, destElId, startX, startY, endX, endY,\n steps: Math.round(duration * dragStepsPerSec)\n };\n return await this.doDrag(dragOpts);\n\n};\n\ncommands.doDrag = async function doDrag (dragOpts) {\n if (util.hasValue(dragOpts.elementId)) {\n return await this.bootstrap.sendAction('element:drag', dragOpts);\n } else {\n return await this.bootstrap.sendAction('drag', dragOpts);\n }\n};\n\ncommands.lock = async function lock (seconds) {\n await this.adb.lock();\n if (isNaN(seconds)) {\n return;\n }\n\n const floatSeconds = parseFloat(seconds);\n if (floatSeconds <= 0) {\n return;\n }\n await B.delay(1000 * floatSeconds);\n await this.unlock();\n};\n\ncommands.isLocked = async function isLocked () {\n return await this.adb.isScreenLocked();\n};\n\ncommands.unlock = async function unlock () {\n return await androidHelpers.unlock(this, this.adb, this.caps);\n};\n\ncommands.openNotifications = async function openNotifications () {\n return await this.bootstrap.sendAction('openNotification');\n};\n\ncommands.setLocation = async function setLocation (latitude, longitude) {\n return await this.adb.sendTelnetCommand(`geo fix ${longitude} ${latitude}`);\n};\n\ncommands.fingerprint = async function fingerprint (fingerprintId) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('fingerprint method is only available for emulators');\n }\n await this.adb.fingerprint(fingerprintId);\n};\n\n/**\n * @typedef {Object} FingerprintOpts\n * @param {string|number} fingerprintId The value is the finger_id for the finger that\n * was \"scanned\". It is a unique integer that you assign for each virtual fingerprint.\n * When the app is running you can run this same command each time the\n * emulator prompts you for a fingerprint, you can run the adb command and pass it\n * the finger_id to simulate the fingerprint scan.\n */\n\n/**\n * Emulate fingerprint on Android Emulator.\n * Only works on API 23+\n *\n * @param {FingerprintOpts} opts\n */\ncommands.mobileFingerprint = async function mobileFingerprint(opts = {}) {\n const {fingerprintId} = requireArgs('fingerprintId', opts);\n await this.fingerprint(fingerprintId);\n};\n\ncommands.sendSMS = async function sendSMS (phoneNumber, message) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('sendSMS method is only available for emulators');\n }\n await this.adb.sendSMS(phoneNumber, message);\n};\n\n/**\n * @typedef {Object} SendSmsOptions\n * @property {string} phoneNumber The phone number to send SMS to\n * @property {string} message The message payload\n */\n\n/**\n * Emulate sending an SMS to the given phone number.\n * Only works on emulators.\n *\n * @param {SendSmsOptions} opts\n */\ncommands.mobileSendSms = async function mobileSendSms(opts = {}) {\n const {phoneNumber, message} = requireArgs(['phoneNumber', 'message'], opts);\n await this.sendSMS(phoneNumber, message);\n};\n\ncommands.gsmCall = async function gsmCall (phoneNumber, action) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('gsmCall method is only available for emulators');\n }\n await this.adb.gsmCall(phoneNumber, action);\n};\n\n/**\n * @typedef {Object} GsmCallOptions\n * @property {string} phoneNumber The phone number to call to\n * @property {call|accept|cancel|hold} action One of possible actions to take\n */\n\n/**\n * Emulate a GSM call to the given phone number.\n * Only works on emulators.\n *\n * @param {GsmCallOptions} opts\n */\ncommands.mobileGsmCall = async function mobileGsmCall(opts = {}) {\n const {phoneNumber, action} = requireArgs(['phoneNumber', 'action'], opts);\n await this.gsmCall(phoneNumber, action);\n};\n\ncommands.gsmSignal = async function gsmSignal (signalStrengh) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('gsmSignal method is only available for emulators');\n }\n await this.adb.gsmSignal(signalStrengh);\n};\n\n/**\n * @typedef {Object} GsmSignalOptions\n * @property {0|1|2|3|4} strength One of possible signal strength values, where 4 is the best signal.\n */\n\n/**\n * Emulate GSM signal strength change event.\n * Only works on emulators.\n *\n * @param {GsmSignalOptions} opts\n */\ncommands.mobileGsmSignal = async function mobileGsmSignal(opts = {}) {\n const {strength} = requireArgs('strength', opts);\n await this.gsmSignal(strength);\n};\n\ncommands.gsmVoice = async function gsmVoice (state) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('gsmVoice method is only available for emulators');\n }\n await this.adb.gsmVoice(state);\n};\n\n/**\n * @typedef {Object} GsmVoiceOptions\n * @property {on|off} state\n */\n\n/**\n * Emulate GSM voice state change event.\n * Only works on emulators.\n *\n * @param {GsmVoiceOptions} opts\n */\ncommands.mobileGsmVoice = async function mobileGsmVoice(opts = {}) {\n const {state} = requireArgs('state', opts);\n await this.gsmVoice(state);\n};\n\ncommands.powerAC = async function powerAC (state) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('powerAC method is only available for emulators');\n }\n await this.adb.powerAC(state);\n};\n\n/**\n * @typedef {Object} PowerAcOptions\n * @property {on|off} state\n */\n\n/**\n * Emulate AC power state change.\n * Only works on emulators.\n *\n * @param {GsmVoiceOptions} opts\n */\ncommands.mobilePowerAc = async function mobilePowerAc(opts = {}) {\n const {state} = requireArgs('state', opts);\n await this.powerAC(state);\n};\n\ncommands.powerCapacity = async function powerCapacity (batteryPercent) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('powerCapacity method is only available for emulators');\n }\n await this.adb.powerCapacity(batteryPercent);\n};\n\n/**\n * @typedef {Object} PowerCapacityOptions\n * @property {number} percent - Percentage value in range [0, 100]\n */\n\n/**\n * Emulate power capacity change.\n * Only works on emulators.\n *\n * @param {PowerCapacityOptions} opts\n */\ncommands.mobilePowerCapacity = async function mobilePowerCapacity(opts = {}) {\n const {percent} = requireArgs('percent', opts);\n await this.powerCapacity(percent);\n};\n\ncommands.networkSpeed = async function networkSpeed (networkSpeed) {\n if (!this.isEmulator()) {\n this.log.errorAndThrow('networkSpeed method is only available for emulators');\n }\n await this.adb.networkSpeed(networkSpeed);\n};\n\n/**\n * @typedef {Object} NetworkSpeedOptions\n * @property {gsm|scsd|gprs|edge|umts|hsdpa|lte|evdo|full} speed\n */\n\n/**\n * Emulate different network connection speed modes.\n * Only works on emulators.\n *\n * @param {NetworkSpeedOptions} opts\n */\ncommands.mobileNetworkSpeed = async function mobileNetworkSpeed(opts = {}) {\n const {speed} = requireArgs('speed', opts);\n await this.networkSpeed(speed);\n};\n\n/**\n * Emulate sensors values on the connected emulator.\n *\n * @typedef {Object} Sensor\n * @property {string} sensorType - sensor type declared in adb.SENSORS\n * @property {string} value - value to set to the sensor\n *\n * @param {Object} Sensor\n * @throws {Error} - If sensorType is not defined\n * @throws {Error} - If value for the se sor is not defined\n * @throws {Error} - If deviceType is not an emulator\n */\ncommands.sensorSet = async function sensorSet (sensor = {}) {\n const {sensorType, value} = sensor;\n if (!util.hasValue(sensorType)) {\n this.log.errorAndThrow(`'sensorType' argument is required`);\n }\n if (!util.hasValue(value)) {\n this.log.errorAndThrow(`'value' argument is required`);\n }\n if (!this.isEmulator()) {\n this.log.errorAndThrow('sensorSet method is only available for emulators');\n }\n await this.adb.sensorSet(sensorType, value);\n};\n\n/**\n * @param {ADB} adb\n * @param {Object} opts\n * @returns {Promise<sharp>}\n */\nhelpers.getScreenshotDataWithAdbShell = async function getScreenshotDataWithAdbShell (adb, opts) {\n const localFile = await tempDir.path({prefix: 'appium', suffix: '.png'});\n if (await fs.exists(localFile)) {\n await fs.unlink(localFile);\n }\n try {\n const pngDir = opts.androidScreenshotPath || '/data/local/tmp/';\n const png = path.posix.resolve(pngDir, 'screenshot.png');\n await adb.shell(['/system/bin/rm', `${png};`, '/system/bin/screencap', '-p', png]);\n if (!await adb.fileSize(png)) {\n throw new Error('The size of the taken screenshot equals to zero.');\n }\n await adb.pull(png, localFile);\n return sharp(localFile);\n } finally {\n if (await fs.exists(localFile)) {\n await fs.unlink(localFile);\n }\n }\n};\n\n/**\n * @param {ADB} adb\n * @returns {Promise<sharp>}\n */\nhelpers.getScreenshotDataWithAdbExecOut = async function getScreenshotDataWithAdbExecOut (adb) {\n const {stdout, stderr, code} = await exec(\n adb.executable.path,\n [...adb.executable.defaultArgs, 'exec-out', '/system/bin/screencap', '-p'],\n {encoding: 'binary', isBuffer: true}\n );\n // if there is an error, throw\n if (code || stderr.length) {\n throw new Error(`Screenshot returned error, code: '${code}', stderr: '${stderr.toString()}'`);\n }\n // if we don't get anything at all, throw\n if (!stdout.length) {\n throw new Error('Screenshot returned no data');\n }\n\n return sharp(stdout);\n};\n\ncommands.getScreenshot = async function getScreenshot () {\n const apiLevel = await this.adb.getApiLevel();\n let image = null;\n if (apiLevel > 20) {\n try {\n // This screenshoting approach is way faster, since it requires less external commands\n // to be executed. Unfortunately, exec-out option is only supported by newer Android/SDK versions (5.0 and later)\n image = await this.getScreenshotDataWithAdbExecOut(this.adb);\n } catch (e) {\n this.log.info(`Cannot get screenshot data with 'adb exec-out' because of '${e.message}'. ` +\n `Defaulting to 'adb shell' call`);\n }\n }\n if (!image) {\n try {\n image = await this.getScreenshotDataWithAdbShell(this.adb, this.opts);\n } catch (e) {\n const err = `Cannot get screenshot data because of '${e.message}'. ` +\n `Make sure the 'LayoutParams.FLAG_SECURE' is not set for ` +\n `the current view`;\n this.log.errorAndThrow(err);\n }\n }\n if (apiLevel < 23) {\n // Android bug 8433742 - rotate screenshot if screen is rotated\n let screenOrientation = await this.adb.getScreenOrientation();\n try {\n image = image.rotate(-90 * screenOrientation);\n } catch (err) {\n this.log.warn(`Could not rotate screenshot due to error: ${err}`);\n }\n }\n return (await image.toBuffer()).toString('base64');\n};\n\nObject.assign(extensions, commands, helpers);\nexport { commands, helpers };\nexport default extensions;\n"],"mappings":";;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA,MAAMO,gBAAgB,GAAG,EAAE;AAC3B,MAAMC,eAAe,GAAG,EAAE;AAE1B,MAAMC,QAAQ,GAAG,CAAC,CAAC;AAACC,OAAA,CAAAD,QAAA,GAAAA,QAAA;AACpB,MAAME,OAAO,GAAG,CAAC,CAAC;AAACD,OAAA,CAAAC,OAAA,GAAAA,OAAA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ACTIVITY = {
50
50
  },
51
51
  };
52
52
  const SETTINGS_HELPER_PKG_ID = 'io.appium.settings';
53
+ const SETTING_NOTIFICATIONS_LISTENER_SERVICE = `${SETTINGS_HELPER_PKG_ID}/.NLService`;
53
54
  const EMULATOR_PATTERN = /\bemulator\b/i;
54
55
  // These constants are in sync with
55
56
  // https://developer.apple.com/documentation/xctest/xcuiapplicationstate/xcuiapplicationstaterunningbackground?language=objc
@@ -653,7 +654,12 @@ helpers.pushSettingsApp = async function pushSettingsApp (adb, throwError = fals
653
654
  try {
654
655
  await adb.shell(['appops', 'set', SETTINGS_HELPER_PKG_ID, 'PROJECT_MEDIA', 'allow']);
655
656
  } catch (err) {
656
- logger.debug(err);
657
+ logger.debug(err.message);
658
+ }
659
+ try {
660
+ await adb.shell(['cmd', 'notification', 'allow_listener', SETTING_NOTIFICATIONS_LISTENER_SERVICE]);
661
+ } catch (err) {
662
+ logger.debug(err.message);
657
663
  }
658
664
  }
659
665
  if (apiLevel <= 23) { // Android 6- devices should have granted permissions
@@ -2,14 +2,16 @@ import androidHelpers from '../android-helpers';
2
2
  import { fs, util, tempDir} from '@appium/support';
3
3
  import path from 'path';
4
4
  import B from 'bluebird';
5
- import jimp from 'jimp';
5
+ import sharp from 'sharp';
6
6
  import { exec } from 'teen_process';
7
7
  import { requireArgs } from '../utils';
8
8
 
9
9
  const swipeStepsPerSec = 28;
10
10
  const dragStepsPerSec = 40;
11
11
 
12
- let commands = {}, helpers = {}, extensions = {};
12
+ const commands = {};
13
+ const helpers = {};
14
+ const extensions = {};
13
15
 
14
16
  commands.keyevent = async function keyevent (keycode, metastate = null) {
15
17
  // TODO deprecate keyevent; currently wd only implements keyevent
@@ -362,6 +364,11 @@ commands.sensorSet = async function sensorSet (sensor = {}) {
362
364
  await this.adb.sensorSet(sensorType, value);
363
365
  };
364
366
 
367
+ /**
368
+ * @param {ADB} adb
369
+ * @param {Object} opts
370
+ * @returns {Promise<sharp>}
371
+ */
365
372
  helpers.getScreenshotDataWithAdbShell = async function getScreenshotDataWithAdbShell (adb, opts) {
366
373
  const localFile = await tempDir.path({prefix: 'appium', suffix: '.png'});
367
374
  if (await fs.exists(localFile)) {
@@ -370,13 +377,12 @@ helpers.getScreenshotDataWithAdbShell = async function getScreenshotDataWithAdbS
370
377
  try {
371
378
  const pngDir = opts.androidScreenshotPath || '/data/local/tmp/';
372
379
  const png = path.posix.resolve(pngDir, 'screenshot.png');
373
- const cmd = ['/system/bin/rm', `${png};`, '/system/bin/screencap', '-p', png];
374
- await adb.shell(cmd);
380
+ await adb.shell(['/system/bin/rm', `${png};`, '/system/bin/screencap', '-p', png]);
375
381
  if (!await adb.fileSize(png)) {
376
382
  throw new Error('The size of the taken screenshot equals to zero.');
377
383
  }
378
384
  await adb.pull(png, localFile);
379
- return await jimp.read(localFile);
385
+ return sharp(localFile);
380
386
  } finally {
381
387
  if (await fs.exists(localFile)) {
382
388
  await fs.unlink(localFile);
@@ -384,11 +390,16 @@ helpers.getScreenshotDataWithAdbShell = async function getScreenshotDataWithAdbS
384
390
  }
385
391
  };
386
392
 
393
+ /**
394
+ * @param {ADB} adb
395
+ * @returns {Promise<sharp>}
396
+ */
387
397
  helpers.getScreenshotDataWithAdbExecOut = async function getScreenshotDataWithAdbExecOut (adb) {
388
- let {stdout, stderr, code} = await exec(adb.executable.path,
389
- adb.executable.defaultArgs
390
- .concat(['exec-out', '/system/bin/screencap', '-p']),
391
- {encoding: 'binary', isBuffer: true});
398
+ const {stdout, stderr, code} = await exec(
399
+ adb.executable.path,
400
+ [...adb.executable.defaultArgs, 'exec-out', '/system/bin/screencap', '-p'],
401
+ {encoding: 'binary', isBuffer: true}
402
+ );
392
403
  // if there is an error, throw
393
404
  if (code || stderr.length) {
394
405
  throw new Error(`Screenshot returned error, code: '${code}', stderr: '${stderr.toString()}'`);
@@ -398,7 +409,7 @@ helpers.getScreenshotDataWithAdbExecOut = async function getScreenshotDataWithAd
398
409
  throw new Error('Screenshot returned no data');
399
410
  }
400
411
 
401
- return await jimp.read(stdout);
412
+ return sharp(stdout);
402
413
  };
403
414
 
404
415
  commands.getScreenshot = async function getScreenshot () {
@@ -428,14 +439,12 @@ commands.getScreenshot = async function getScreenshot () {
428
439
  // Android bug 8433742 - rotate screenshot if screen is rotated
429
440
  let screenOrientation = await this.adb.getScreenOrientation();
430
441
  try {
431
- image = await image.rotate(-90 * screenOrientation);
442
+ image = image.rotate(-90 * screenOrientation);
432
443
  } catch (err) {
433
444
  this.log.warn(`Could not rotate screenshot due to error: ${err}`);
434
445
  }
435
446
  }
436
- const getBuffer = B.promisify(image.getBuffer, {context: image});
437
- const imgBuffer = await getBuffer(jimp.MIME_PNG);
438
- return imgBuffer.toString('base64');
447
+ return (await image.toBuffer()).toString('base64');
439
448
  };
440
449
 
441
450
  Object.assign(extensions, commands, helpers);
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "mobile",
10
10
  "mobile testing"
11
11
  ],
12
- "version": "5.11.1",
12
+ "version": "5.11.2",
13
13
  "author": "Appium Contributors",
14
14
  "license": "Apache-2.0",
15
15
  "repository": {
@@ -54,7 +54,6 @@
54
54
  "axios": "^1.x",
55
55
  "bluebird": "^3.4.7",
56
56
  "io.appium.settings": "^5.0.0",
57
- "jimp": "^0.x",
58
57
  "lodash": "^4.17.4",
59
58
  "lru-cache": "^7.3.0",
60
59
  "moment": "^2.24.0",
@@ -62,6 +61,7 @@
62
61
  "portfinder": "^1.0.6",
63
62
  "portscanner": "2.2.0",
64
63
  "shared-preferences-builder": "^0.x",
64
+ "sharp": "^0.x",
65
65
  "semver": "^7.0.0",
66
66
  "source-map-support": "^0.x",
67
67
  "teen_process": "^2.0.0",