path: Fixed emulator tool path.
authorminkee.lee <minkee.lee@samsung.com>
Thu, 11 Jun 2015 09:54:27 +0000 (18:54 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 15 Jun 2015 11:35:57 +0000 (20:35 +0900)
- Find path of latest version.

Change-Id: Ib0999afecb7d41d5d3073b7abc7e6f19b6436965
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
src/org/tizen/emulator/manager/resources/FilePathResources.java

index 85c71b0..9487ae3 100644 (file)
@@ -39,6 +39,9 @@ import java.net.URISyntaxException;
 
 import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.platform.Platform;
+import org.tizen.emulator.manager.platform.Profile;
+import org.tizen.emulator.manager.platform.ProfileList;
 import org.tizen.emulator.manager.vms.EmulatorVMList;
 
 public class FilePathResources {
@@ -375,13 +378,13 @@ public class FilePathResources {
 
        public static String getEmulatorToolPath() {
                // TODO return /tools/emulator/bin
-               return getEmulatorPath("2.4") + bin_suffix;
+               return getEmulatorPath(getLatestPlatformVersion()) + bin_suffix;
        }
 
        public static String getEmulatorPath(String platformVersion) {
-               String emulatorPath;
+               String emulatorPath = "";
                if (platformVersion == null || platformVersion.isEmpty()) {
-                       platformVersion = "2.4"; // TODO Get lastest version.
+                       platformVersion = getLatestPlatformVersion();
                }
                try {
                        emulatorPath = new File(platformsPath + platform_prefix
@@ -392,6 +395,21 @@ public class FilePathResources {
                }
                return emulatorPath;
        }
+
+       // Return latest platform version in whole profile.
+       private static String getLatestPlatformVersion() {
+               String latestVersion = "0";
+               for (Profile profile : ProfileList.getProfileList()) {
+                       Platform platform = profile.getPlatformByLatestVersion();
+                       if (platform != null) {
+                               int compare = latestVersion.compareTo(platform.getVersion());
+                               if (compare < 0) { // totalLatestVesion < platform.getVersion()
+                                       latestVersion = platform.getVersion();
+                               }
+                       }
+               }
+               return latestVersion;
+       }
 /*
        public String getArchPath(){
                return arcPath;