Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function killServer (adbPort) {
if (!process.env.TESTOBJECT_E2E_TESTS) {
let adb = await ADB.createADB({adbPort});
await adb.killServer();
if (process.env.CI) {
// on Travis this takes a while to get into a good state
await B.delay(10000);
}
}
}
async function initSession (caps, adbPort) {
if (TRAVIS && !CLOUD) {
let adb = await ADB.createADB({adbPort});
try {
// on Travis, sometimes we get the keyboard dying and the screen stuck
await adb.forceStop('com.android.inputmethod.latin');
await adb.shell(['pm', 'clear', 'com.android.inputmethod.latin']);
} catch (ign) {}
}
if (CLOUD) {
// on cloud tests, we want to set the `name` capability
if (!caps.name) {
caps.name = process.env.SAUCE_JOB_NAME || process.env.TRAVIS_JOB_NUMBER || 'unnamed';
}
}
// Create a WD driver
const host = getHost();
// this list should be updated as ADB takes more arguments
const {
adbPort,
suppressKillServer,
remoteAdbHost,
clearDeviceLogsOnStart,
adbExecTimeout,
useKeystore,
keystorePath,
keystorePassword,
keyAlias,
keyPassword,
remoteAppsCacheLimit,
buildToolsVersion,
} = opts;
return await ADB.createADB({
adbPort,
suppressKillServer,
remoteAdbHost,
clearDeviceLogsOnStart,
adbExecTimeout,
useKeystore,
keystorePath,
keystorePassword,
keyAlias,
keyPassword,
remoteAppsCacheLimit,
buildToolsVersion,
});
};
before(async function () {
adb = await ADB.createADB();
const packageName = 'io.appium.android.apis',
activityName = '.ApiDemos';
await adb.install(apiDemos);
await adb.startApp({pkg: packageName,
activity: activityName});
androidBootstrap = new AndroidBootstrap(adb, systemPort);
await androidBootstrap.start('io.appium.android.apis', false);
});
after(async function () {
before(async function () {
adb = await ADB.createADB();
});
describe('installApk', function () {
before(async function () {
adb = await ADB.createADB();
const packageName = 'io.appium.android.apis',
activityName = '.ApiDemos';
await adb.uninstallApk('io.appium.android.apis');
await adb.install(apiDemos);
await adb.startApp({pkg: packageName,
activity: activityName});
androidBootstrap = new AndroidBootstrap(adb, systemPort);
await androidBootstrap.start('io.appium.android.apis', false);
});
after(async function () {
private async getOrCreateAdb(udid: string): Promise {
let adb = this.adbList[udid];
if (!adb) {
adb = await ADB.createADB();
adb.setDeviceId(udid);
this.adbList[udid] = adb;
}
return adb;
}
private async getDevices_(): Promise {
constructor(private readonly log: logger) {
super();
this.adbPromise = ADB.createADB();
this.updatePromise = this.getDevices_();
}
private async getAdb(): ADB {