From bf0d23a2153502e2123240dd64b9ca8036a1d366 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 31 Jul 2017 09:56:07 +0530 Subject: [PATCH 1/3] Adding default parameter --- .../org.carbon.android.emulator/TryIt.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 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 b1a02a406..54e6fb48c 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 @@ -494,17 +494,29 @@ public class TryIt { /** * This method gets the Android SDK location if available and sets the SDK path else downloads the SDK. */ + private int count = 0; + private void setAndroidSDK() { sdkConfigFile = new File("sdkConfigLocation"); if (!(sdkConfigFile.exists() && !sdkConfigFile.isDirectory())) { //TODO Scanner read = new Scanner(System.in, StandardCharsets.UTF_8.toString()); System.out.print("Do you have an Android SDK installed on your computer (y/N) ? : "); - String response = read.next().toLowerCase(); + String response = read.nextLine().toLowerCase(); if (response.matches("y")) { setSDKPath(); - } else { + } else if (response.matches("n") || response.matches("")) { getAndroidSDK(); + } else { + if (count < 5) { + System.out.println("Please enter a valid parameter ."); + count++; + setAndroidSDK(); + return; + } else { + System.out.println("Terminating process"); + System.exit(1); + } } } else { Scanner scanner = null; @@ -526,6 +538,10 @@ public class TryIt { setExecutePermission(adbLocation); } + private void askForSDKLocation() { + System.out.println("Please enter a valid parameter ."); + } + /** * this method prints the exception and terminate the program. * From 71546f5c0cd682551ad6f13ce217f30284154915 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 31 Jul 2017 09:58:50 +0530 Subject: [PATCH 2/3] code clean up --- .../src/main/java/org.carbon.android.emulator/TryIt.java | 4 ---- 1 file changed, 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 54e6fb48c..d2c75a248 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 @@ -538,10 +538,6 @@ public class TryIt { setExecutePermission(adbLocation); } - private void askForSDKLocation() { - System.out.println("Please enter a valid parameter ."); - } - /** * this method prints the exception and terminate the program. * From 0ab450ddac0cbca5c4e22812d530933dd69b667f Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Mon, 31 Jul 2017 11:13:01 +0530 Subject: [PATCH 3/3] removing N as default parameter --- .../src/main/java/org.carbon.android.emulator/TryIt.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 d2c75a248..c866d5d1d 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 @@ -501,11 +501,11 @@ public class TryIt { if (!(sdkConfigFile.exists() && !sdkConfigFile.isDirectory())) { //TODO Scanner read = new Scanner(System.in, StandardCharsets.UTF_8.toString()); - System.out.print("Do you have an Android SDK installed on your computer (y/N) ? : "); + System.out.print("Do you have an Android SDK installed on your computer (y/n) ? : "); String response = read.nextLine().toLowerCase(); if (response.matches("y")) { setSDKPath(); - } else if (response.matches("n") || response.matches("")) { + } else if (response.matches("n") ) { getAndroidSDK(); } else { if (count < 5) {