Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp.task('sign-apk', async function signApks () {
// Signs the APK with the default Appium Certificate
const adb = await androidHelpers.createADB({});
const pathToApk = path.resolve('apks', `appium-uiautomator2-server-v${version}.apk`);
return adb.sign(pathToApk);
});
async startUiAutomator2Session () {
// get device udid for this session
let {udid, emPort} = await helpers.getDeviceInfoFromCaps(this.opts);
this.opts.udid = udid;
this.opts.emPort = emPort;
// now that we know our java version and device info, we can create our
// ADB instance
this.adb = await androidHelpers.createADB(this.opts);
const apiLevel = await this.adb.getApiLevel();
if (apiLevel < 21) {
logger.errorAndThrow('UIAutomator2 is only supported since Android 5.0 (Lollipop). ' +
'You could still use other supported backends in order to automate older Android versions.');
}
if (apiLevel >= 28) { // Android P
logger.warn('Relaxing hidden api policy');
await this.adb.setHiddenApiPolicy('1');
}
// check if we have to enable/disable gps before running the application
if (util.hasValue(this.opts.gpsEnabled)) {
if (this.isEmulator()) {
async function main () {
// Signs the APK with the default Appium Certificate
const adb = await androidHelpers.createADB({});
const pathToApk = path.resolve('apks', `appium-uiautomator2-server-v${packageJson.version}.apk`);
await adb.sign(pathToApk);
}