From 3087ffd5e92ca16c3fd96d7a9f2000e94075ad5a Mon Sep 17 00:00:00 2001 From: "minkee.lee" Date: Mon, 27 Apr 2015 17:21:02 +0900 Subject: [PATCH] arch: Modified emulator directory structure. Change-Id: I70fb534bbb255d162ce17afa2612f4a989668f73 Signed-off-by: minkee.lee --- .../tizen/emulator/manager/platform/Platform.java | 17 ++++++++-- .../emulator/manager/platform/PlatformList.java | 28 ++++++++++++++--- .../manager/resources/FilePathResources.java | 36 ++++++++++++++++++++++ .../org/tizen/emulator/manager/vms/Creator.java | 11 +++++-- .../tizen/emulator/manager/vms/VMWorkerCommon.java | 2 +- 5 files changed, 83 insertions(+), 11 deletions(-) diff --git a/common-project/src/org/tizen/emulator/manager/platform/Platform.java b/common-project/src/org/tizen/emulator/manager/platform/Platform.java index dfc2666..f8fdf18 100644 --- a/common-project/src/org/tizen/emulator/manager/platform/Platform.java +++ b/common-project/src/org/tizen/emulator/manager/platform/Platform.java @@ -67,8 +67,10 @@ public class Platform { public Platform(String name) { this.platformName = name; - this.platformPath = FilePathResources.getPlatformsPath() - + File.separator + platformName; +// this.platformPath = FilePathResources.getPlatformsPath() +// + File.separator + platformName; + this.platformPath = FilePathResources.getPlatformsPath() + File.separator + + getPlatformPath(platformName); loadProperties(); if (!imageList.isEmpty()) { @@ -78,6 +80,17 @@ public class Platform { } } + public static String getPlatformPath(String platformName) { + String split[] = platformName.split("-"); + if (split != null && split.length == 2) { + String profile = split[0]; + String ver = split[1]; + return "tizen" + "-" + ver + File.separator + profile; + } + EMLogger.getLogger().warning("Failed to get platformpath from platform name : " + platformName); + return ""; + } + private void loadProperties() { if (platformPath == null) { return; diff --git a/common-project/src/org/tizen/emulator/manager/platform/PlatformList.java b/common-project/src/org/tizen/emulator/manager/platform/PlatformList.java index 72ed344..5b15143 100644 --- a/common-project/src/org/tizen/emulator/manager/platform/PlatformList.java +++ b/common-project/src/org/tizen/emulator/manager/platform/PlatformList.java @@ -101,13 +101,31 @@ public class PlatformList { File platforms = new File(FilePathResources.getPlatformsPath()); if (platforms.isDirectory() && platforms.exists()) { +// for (File platform : platforms.listFiles()) { +// if (platform.isDirectory()) { +// Platform p = new Platform(platform.getName()); +// if (!p.getImageList().isEmpty()) { +// //platformList.add(p); +// addPlatform(p); +// //addProfile(p.getProfile()); +// } +// } +// } for (File platform : platforms.listFiles()) { if (platform.isDirectory()) { - Platform p = new Platform(platform.getName()); - if (!p.getImageList().isEmpty()) { - //platformList.add(p); - addPlatform(p); - //addProfile(p.getProfile()); + for (File profile : platform.listFiles()) { + if (profile.isDirectory()) { + String versionSplit[] = platform.getName().split("-"); + if (versionSplit != null && versionSplit.length == 2) { + Platform p = new Platform(profile.getName() + "-" + versionSplit[1]); + if (!p.getImageList().isEmpty()) { + //platformList.add(p); + addPlatform(p); + //addProfile(p.getProfile()); + } + } + + } } } } diff --git a/common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java b/common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java index e932904..4a0bf10 100644 --- a/common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java +++ b/common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java @@ -50,6 +50,8 @@ public class FilePathResources { private final static String em_images_suffix = File.separator + "emulator-images"; private final static String resource_suffix = File.separator + "emulator-resources"; private final static String old_default_suffix = File.separator + "default"; + private final static String common_suffix = File.separator + "common"; + private final static String platform_prefix = File.separator + "tizen-"; // private final static String addons_suffix = File.separator + "add-ons"; // private final static String x86_extension = ".x86"; // private final static String arm_extension = ".arm"; @@ -78,6 +80,8 @@ public class FilePathResources { private final static String sdkdata_new_emulator_suffix = File.separator + "emulator"; private final static String vms_suffix = File.separator + "vms"; + private final static String qemuImg_suffic = File.separator + "qemu-img"; + private static String currentPath; private static String sdkPath = null; private static String platformsPath; @@ -347,6 +351,38 @@ public class FilePathResources { public static String getBinPath(){ return binPath; } + + public static String getEmulatorBinPath(String platformVersion) { + return getEmulatorPath(platformVersion) + bin_suffix; + } + + public static String getEmulatorKernelPath(String platformVersion) { + return getEmulatorDataPath(platformVersion) + kernel_suffix; + } + + public static String getEmulatorBiosPath(String platformVersion) { + return getEmulatorDataPath(platformVersion) + bios_suffix; + } + + public static String getEmulatorQemuImgPath(String platformVersion) { + return getEmulatorBinPath(platformVersion) + qemuImg_suffic; + } + + public static String getEmulatorDataPath(String platformVersion) { + return getEmulatorPath(platformVersion) + data_suffix; + } + + public static String getEmulatorPath(String platformVersion) { + String emulatorPath; + try { + emulatorPath = new File(platformsPath + platform_prefix + + platformVersion + common_suffix + emulator_suffix).getCanonicalPath(); + } catch (IOException e) { + emulatorPath = platformsPath + platform_prefix + + platformVersion + common_suffix + emulator_suffix; + } + return emulatorPath; + } /* public String getArchPath(){ return arcPath; diff --git a/common-project/src/org/tizen/emulator/manager/vms/Creator.java b/common-project/src/org/tizen/emulator/manager/vms/Creator.java index 88b2669..1ba0f17 100644 --- a/common-project/src/org/tizen/emulator/manager/vms/Creator.java +++ b/common-project/src/org/tizen/emulator/manager/vms/Creator.java @@ -173,7 +173,7 @@ public class Creator { } private void createSwapImageInternal(String basePath, String targetPath) throws VMCreatorException { - String exe_path = FilePathResources.getBinPath() + File.separator + "qemu-img"; + String exe_path = getQemuImgPath(); List cmd = new ArrayList(); cmd.add(exe_path); @@ -193,7 +193,7 @@ public class Creator { } private void checkCustomBaseImage(final String path) throws VMCreatorException { - String exe_path = FilePathResources.getBinPath() + File.separator + "qemu-img"; + String exe_path = getQemuImgPath(); List cmd = new ArrayList(); cmd.add(exe_path); @@ -207,7 +207,7 @@ public class Creator { } public void createInitialVMImageInternal(String baseImagePath, String targetImagePath) throws VMCreatorException { - String exe_path = FilePathResources.getBinPath() + File.separator + "qemu-img"; + String exe_path = getQemuImgPath(); List cmd = new ArrayList(); cmd.add(exe_path); @@ -397,4 +397,9 @@ public class Creator { new Creator().createSwapImageInternal(basePath, targetPath); } + private String getQemuImgPath() { +// return FilePathResources.getBinPath() + File.separator + "qemu-img"; + return FilePathResources.getEmulatorQemuImgPath(newVM.version); + } + } diff --git a/common-project/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java b/common-project/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java index 131a5cd..57c0c40 100644 --- a/common-project/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java +++ b/common-project/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java @@ -255,7 +255,7 @@ public class VMWorkerCommon { throw new VMWorkerException("File does not exist :" + baseImage.getAbsolutePath()); } - String exe_path = FilePathResources.getBinPath() + File.separator + "qemu-img"; + String exe_path = FilePathResources.getEmulatorQemuImgPath(property.getPropertyValue().version); List cmd = new ArrayList(); cmd.add(exe_path); -- 2.7.4