From b1e86877518ed6bfa0c4bd19f733c48abc6dc304 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 19 Jun 2017 22:30:39 +0530 Subject: [PATCH] Code clean up --- .../main/java/org.carbon.android.emulator/TryIt.java | 12 ++++-------- .../org.carbon.android.emulator/TryItEmulator.java | 7 +++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryIt.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryIt.java index 3dbe0cbbc..f911a2812 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryIt.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryIt.java @@ -308,8 +308,8 @@ public class TryIt { ArrayList devices = new ArrayList<>(); BufferedReader reader = null; try { - reader = new BufferedReader(new InputStreamReader(listAVDsProcess.getInputStream() - , StandardCharsets.UTF_8)); + reader = new BufferedReader(new InputStreamReader(listAVDsProcess.getInputStream(), + StandardCharsets.UTF_8)); String readLine; while ((readLine = reader.readLine()) != null) { devices.add(readLine); @@ -403,7 +403,6 @@ public class TryIt { * @throws IOException process start throws if an I/O error occurs. */ private void runEmulator(String deviceId) throws IOException { - // mac os and windows needs hardware_Accelerated_execution_Manager if (osSuffix.equals(Constants.MAC_OS) || osSuffix.equals(Constants.WINDOWS_OS)) { installHAXM(); @@ -552,8 +551,6 @@ public class TryIt { try { reader = new BufferedReader(new InputStreamReader(badgingApkFileProcess.getInputStream(), StandardCharsets.UTF_8)); - - while ((readLine = reader.readLine()) != null) { if (readLine.contains("package")) { pkg = readLine.substring(readLine.indexOf(Constants.NAME) + 6).substring(0, @@ -613,7 +610,6 @@ public class TryIt { ProcessBuilder installAgentProcessBuilder = new ProcessBuilder(adbLocation, "install", androidAgentLocation); Process installAgentProcess = installAgentProcessBuilder.start(); - try { installAgentProcess.waitFor(); } catch (InterruptedException e) { @@ -715,14 +711,14 @@ public class TryIt { try { process = processBuilder.start(); } catch (IOException e) { - handleException("HAXM installation failed", e); + System.out.println("HAXM installation failed, install HAXM and try again"); } try { if (process != null) { process.waitFor(); } } catch (InterruptedException e) { - handleException("HAXM installation failed", e); + System.out.println("HAXM installation failed, install HAXM and try again"); } System.out.println("Please restart your machine and run again."); System.exit(0); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryItEmulator.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryItEmulator.java index 28fc0032f..a86f533cc 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryItEmulator.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/src/main/java/org.carbon.android.emulator/TryItEmulator.java @@ -46,13 +46,16 @@ public class TryItEmulator implements Runnable { ProcessBuilder processBuilder = new ProcessBuilder(emulatorLocation, "-avd", deviceId); try { Process process = processBuilder.start(); - reader = new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); - writer = new OutputStreamWriter(new FileOutputStream(new File("emulator.log")), StandardCharsets.UTF_8); + reader = new BufferedReader(new InputStreamReader(process.getInputStream(), + StandardCharsets.UTF_8)); + writer = new OutputStreamWriter(new FileOutputStream(new File("emulator.log")), + StandardCharsets.UTF_8); while ((readLine = reader.readLine()) != null) { writer.append(readLine); writer.append(readLine); } } catch (IOException e) { + System.out.println("Error in starting " + deviceId); e.printStackTrace(); } finally { if (reader != null) {