From 8f04b660cf97a5529d71a5cadcd8330f1e1e6e4f Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 31 Jul 2017 16:52:20 +0530 Subject: [PATCH 1/5] changing file format for windows --- .../org.carbon.android.emulator/TryIt.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 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 de4836799e..96c4755e22 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 @@ -156,7 +156,7 @@ public class TryIt { if (!new File(localPath).delete()) { System.out.println("Delete " + localPath + " and try again"); } - handleException("Downloading " + localPath + " failed.", e); + handleException("Download failed for file : " + localPath , e); } finally { if (in != null) try { @@ -193,7 +193,7 @@ public class TryIt { String response = new Scanner(System.in, StandardCharsets.UTF_8.toString()).next(); String emulatorLocationPath = response + File.separator + "tools" + File.separator + "emulator"; if (osSuffix.equals(Constants.WINDOWS_OS)) { - emulatorLocationPath += Constants.WINDOWS_EXTENSION_BAT; + emulatorLocationPath += Constants.WINDOWS_EXTENSION_EXE; } if (new File(emulatorLocationPath).exists()) { androidSdkHome = response; @@ -734,19 +734,19 @@ public class TryIt { if (!new File(haxmLocation).mkdirs()) { makeDirectoryError(haxmLocation, androidSdkHome); } - String folderName = "_haxm.zip"; - getTools(System.getProperty(Constants.HAXM_URL), haxmLocation + File.separator - + folderName); - String haxmInstaller = haxmLocation + File.separator + "silent_install"; - if (osSuffix.equals(Constants.WINDOWS_OS)) { - haxmInstaller += Constants.WINDOWS_EXTENSION_BAT; - } else { - haxmInstaller += Constants.MAC_HAXM_EXTENSION; - } + String folderName = "extras" + File.separator + "intel" + File.separator + + "Hardware_Accelerated_Execution_Manager" + File.separator + "_haxm.zip"; + getTools(System.getProperty(Constants.HAXM_URL), folderName); + String haxmInstaller = haxmLocation + File.separator + "HAXM installation"; +// if (osSuffix.equals(Constants.WINDOWS_OS)) { +// haxmInstaller += Constants.WINDOWS_EXTENSION_BAT; +// } else { +// haxmInstaller += Constants.MAC_HAXM_EXTENSION; +// } setExecutePermission(haxmInstaller); ProcessBuilder processBuilder = new ProcessBuilder(haxmInstaller, "-m", "2048", "-log", - workingDirectory + File.separator + "haxmSilentRun.log"); + androidSdkHome + File.separator + "haxmSilentRun.log"); processBuilder.directory(new File(haxmLocation)); processBuilder.redirectInput(ProcessBuilder.Redirect.INHERIT); processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT); From e32feaaea59fd5a20134c187207214ab38dec76d Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 31 Jul 2017 17:15:46 +0530 Subject: [PATCH 2/5] code clean up --- .../src/main/java/org.carbon.android.emulator/TryIt.java | 8 ++------ 1 file changed, 2 insertions(+), 6 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 96c4755e22..41914d179f 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 @@ -646,7 +646,7 @@ public class TryIt { */ private void installAgent() { String androidAgentLocation = workingDirectory + Constants.APK_LOCATION; - System.out.println("Installing agent ..."); + System.out.println("Installing agent, please wait..."); ProcessBuilder installAgentProcessBuilder = new ProcessBuilder(adbLocation, "install", androidAgentLocation); try { @@ -738,11 +738,6 @@ public class TryIt { + "Hardware_Accelerated_Execution_Manager" + File.separator + "_haxm.zip"; getTools(System.getProperty(Constants.HAXM_URL), folderName); String haxmInstaller = haxmLocation + File.separator + "HAXM installation"; -// if (osSuffix.equals(Constants.WINDOWS_OS)) { -// haxmInstaller += Constants.WINDOWS_EXTENSION_BAT; -// } else { -// haxmInstaller += Constants.MAC_HAXM_EXTENSION; -// } setExecutePermission(haxmInstaller); ProcessBuilder processBuilder = new ProcessBuilder(haxmInstaller, "-m", "2048", "-log", @@ -830,6 +825,7 @@ public class TryIt { private void checkCacheImg(String deviceId) { File cacheImg = new File(userHome + File.separator + ".android" + File.separator + "avd" + File.separator + deviceId + ".avd" + File.separator + "cache.img"); + System.out.print("Creating cache image, please wait "); while (!cacheImg.exists()) { System.out.print("."); delay(1000); From 1fbcbd0fbd97f68645505ab84eea072324abd24b Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 31 Jul 2017 17:21:47 +0530 Subject: [PATCH 3/5] adding messages --- .../src/main/java/org.carbon.android.emulator/TryIt.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 41914d179f..58b2b27c4e 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 @@ -255,7 +255,7 @@ public class TryIt { private void getTools(String url, String folderName) { System.out.println("Downloading " + folderName); downloadArtifacts(url, androidSdkHome + File.separator + folderName); - System.out.println("Configuring " + folderName); + System.out.println("Configuring " + folderName + ", please wait"); extractFolder(androidSdkHome + File.separator + folderName); } From 1b729295987000749362f4a031915feb80572f7f Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 31 Jul 2017 18:14:33 +0530 Subject: [PATCH 4/5] code clean up --- .../org.carbon.android.emulator/TryIt.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 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 58b2b27c4e..8ed89e626a 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 @@ -734,14 +734,26 @@ public class TryIt { if (!new File(haxmLocation).mkdirs()) { makeDirectoryError(haxmLocation, androidSdkHome); } + String haxmInstaller ; String folderName = "extras" + File.separator + "intel" + File.separator + "Hardware_Accelerated_Execution_Manager" + File.separator + "_haxm.zip"; getTools(System.getProperty(Constants.HAXM_URL), folderName); - String haxmInstaller = haxmLocation + File.separator + "HAXM installation"; - setExecutePermission(haxmInstaller); + ProcessBuilder processBuilder; + if(osSuffix.equals(Constants.MAC_OS) ) { + haxmInstaller = haxmLocation + File.separator + "HAXM installation"; + setExecutePermission(haxmInstaller); + processBuilder = new ProcessBuilder("sudo", haxmInstaller, "-m", "2048", "-log", + androidSdkHome + File.separator + "haxmSilentRun.log"); + } else { + haxmInstaller = haxmLocation + File.separator + "silent_install"; + haxmInstaller += Constants.WINDOWS_EXTENSION_BAT; + setExecutePermission(haxmInstaller); + processBuilder = new ProcessBuilder(haxmInstaller, "-m", "2048", "-log", + androidSdkHome + File.separator + "haxmSilentRun.log"); + } + + System.out.println("Installing intel HAXM..."); - ProcessBuilder processBuilder = new ProcessBuilder(haxmInstaller, "-m", "2048", "-log", - androidSdkHome + File.separator + "haxmSilentRun.log"); processBuilder.directory(new File(haxmLocation)); processBuilder.redirectInput(ProcessBuilder.Redirect.INHERIT); processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT); From 33dc732bd32d7b1791726ea19aa01efec3d59c58 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 31 Jul 2017 18:23:48 +0530 Subject: [PATCH 5/5] code clean up --- .../org.carbon.android.emulator/TryIt.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 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 8ed89e626a..81dbf4c219 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 @@ -156,7 +156,7 @@ public class TryIt { if (!new File(localPath).delete()) { System.out.println("Delete " + localPath + " and try again"); } - handleException("Download failed for file : " + localPath , e); + handleException("Download failed for file : " + localPath, e); } finally { if (in != null) try { @@ -505,7 +505,7 @@ public class TryIt { String response = read.nextLine().toLowerCase(); if (response.matches("y")) { setSDKPath(); - } else if (response.matches("n") ) { + } else if (response.matches("n")) { getAndroidSDK(); } else { if (count < 5) { @@ -734,26 +734,20 @@ public class TryIt { if (!new File(haxmLocation).mkdirs()) { makeDirectoryError(haxmLocation, androidSdkHome); } - String haxmInstaller ; + String haxmInstaller; String folderName = "extras" + File.separator + "intel" + File.separator + "Hardware_Accelerated_Execution_Manager" + File.separator + "_haxm.zip"; getTools(System.getProperty(Constants.HAXM_URL), folderName); ProcessBuilder processBuilder; - if(osSuffix.equals(Constants.MAC_OS) ) { - haxmInstaller = haxmLocation + File.separator + "HAXM installation"; - setExecutePermission(haxmInstaller); - processBuilder = new ProcessBuilder("sudo", haxmInstaller, "-m", "2048", "-log", - androidSdkHome + File.separator + "haxmSilentRun.log"); + if (osSuffix.equals(Constants.MAC_OS)) { + haxmInstaller = haxmLocation + File.separator + "silent_install.sh"; } else { - haxmInstaller = haxmLocation + File.separator + "silent_install"; - haxmInstaller += Constants.WINDOWS_EXTENSION_BAT; - setExecutePermission(haxmInstaller); - processBuilder = new ProcessBuilder(haxmInstaller, "-m", "2048", "-log", - androidSdkHome + File.separator + "haxmSilentRun.log"); + haxmInstaller = haxmLocation + File.separator + "silent_install.bat"; } - - System.out.println("Installing intel HAXM..."); - + setExecutePermission(haxmInstaller); + processBuilder = new ProcessBuilder("sudo", haxmInstaller, "-m", "2048", "-log", + androidSdkHome + File.separator + "haxmSilentRun.log"); + System.out.println("Installing intel HAXM, Please wait . . . "); processBuilder.directory(new File(haxmLocation)); processBuilder.redirectInput(ProcessBuilder.Redirect.INHERIT); processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);