Skip to content

Commit

Permalink
Make killEmulator method work for current emu
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Jun 26, 2018
1 parent 90354b5 commit 7271ff7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/tools/system-calls.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path';
import log from '../logger.js';
import B from 'bluebird';
import { system, fs } from 'appium-support';
import { system, fs, util } from 'appium-support';
import { getSdkToolsVersion, getBuildToolsDirs } from '../helpers';
import { exec, SubProcess } from 'teen_process';
import { sleep, retry, retryInterval } from 'asyncbox';
Expand Down Expand Up @@ -546,13 +546,20 @@ systemCallMethods.killAllEmulators = async function () {
* @param {string} avdName - The name of the emulator to be killed.
*/
systemCallMethods.killEmulator = async function (avdName) {
log.debug(`killing avd '${avdName}'`);
let device = await this.getRunningAVD(avdName);
if (device) {
await this.adbExec(['emu', 'kill']);
log.info(`successfully killed emulator '${avdName}'`);
if (util.hasValue(avdName)) {
log.debug(`killing avd '${avdName}'`);
let device = await this.getRunningAVD(avdName);
if (device) {
await this.adbExec(['emu', 'kill']);
log.info(`successfully killed emulator '${avdName}'`);
} else {
log.info(`no avd with name '${avdName}' running. skipping kill step.`);
}
} else {
log.info(`no avd with name '${avdName}' running. skipping kill step.`);
// killing the current avd
log.debug(`killing avd with id '${this.curDeviceId}'`);
await this.adbExec(['emu', 'kill']);
log.info(`successfully killed emulator`);
}
};

Expand Down

0 comments on commit 7271ff7

Please sign in to comment.