From a9ce6f71f6dc613f86028d552c4f8334d40a01aa Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Fri, 22 Apr 2016 16:39:57 +0300 Subject: [PATCH] Firstly try to stop emulator via adb then via kill process --- .../android/tests/emulator/Emulator.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/compiler/android-tests/src/org/jetbrains/kotlin/android/tests/emulator/Emulator.java b/compiler/android-tests/src/org/jetbrains/kotlin/android/tests/emulator/Emulator.java index 6a0ef6e11ff..c631c250303 100644 --- a/compiler/android-tests/src/org/jetbrains/kotlin/android/tests/emulator/Emulator.java +++ b/compiler/android-tests/src/org/jetbrains/kotlin/android/tests/emulator/Emulator.java @@ -112,10 +112,15 @@ public class Emulator { OutputUtils.checkResult(RunUtils.execute(new RunUtils.RunSettings(getCreateCommand(), "no", true, null, false))); } - public void startServer() { + private GeneralCommandLine createAdbCommand() { GeneralCommandLine commandLine = new GeneralCommandLine(); String adbCmdName = SystemInfo.isWindows ? "adb.exe" : "adb"; commandLine.setExePath(pathManager.getPlatformToolsFolderInAndroidSdk() + "/" + adbCmdName); + return commandLine; + } + + public void startServer() { + GeneralCommandLine commandLine = createAdbCommand(); commandLine.addParameter("start-server"); System.out.println("Start adb server..."); OutputUtils.checkResult(RunUtils.execute(commandLine)); @@ -129,9 +134,7 @@ public class Emulator { } public void printLog() { - GeneralCommandLine commandLine = new GeneralCommandLine(); - String adbCmdName = SystemInfo.isWindows ? "adb.exe" : "adb"; - commandLine.setExePath(pathManager.getPlatformToolsFolderInAndroidSdk() + "/" + adbCmdName); + GeneralCommandLine commandLine = createAdbCommand(); commandLine.addParameter("logcat"); commandLine.addParameter("-v"); commandLine.addParameter("time"); @@ -146,9 +149,19 @@ public class Emulator { public void stopEmulator() { System.out.println("Stopping emulator..."); + + GeneralCommandLine command = createAdbCommand(); + command.addParameter("-s"); + command.addParameter("emulator-5554"); + command.addParameter("emu"); + command.addParameter("kill"); + RunUtils.execute(command); + if (SystemInfo.isWindows) { + //TODO check that command above works on windows and remove this OutputUtils.checkResult(RunUtils.execute(getStopCommand())); } + finishProcess("emulator64-" + platform); finishProcess("emulator-" + platform); } @@ -198,9 +211,7 @@ public class Emulator { } private void stopRedundantEmulators(PathManager pathManager) { - GeneralCommandLine commandLineForListOfDevices = new GeneralCommandLine(); - String adbCmdName = SystemInfo.isWindows ? "adb.exe" : "adb"; - commandLineForListOfDevices.setExePath(pathManager.getPlatformToolsFolderInAndroidSdk() + "/" + adbCmdName); + GeneralCommandLine commandLineForListOfDevices = createAdbCommand(); commandLineForListOfDevices.addParameter("devices"); RunResult runResult = RunUtils.execute(commandLineForListOfDevices); OutputUtils.checkResult(runResult);