From: minkee.lee Date: Wed, 6 Aug 2014 12:11:38 +0000 (+0900) Subject: Bug fix: Missing default-property when create custom-image. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=276079f526308adfb80d6341fd668c55866bef3e;p=sdk%2Femulator%2Femulator-manager.git Bug fix: Missing default-property when create custom-image. Change-Id: Icc00c73b06ef450c80ce128fad5649871ee5705f Signed-off-by: minkee.lee --- diff --git a/common-project/src/org/tizen/emulator/manager/platform/BaseImage.java b/common-project/src/org/tizen/emulator/manager/platform/BaseImage.java index 99fc1de..a5fb2c9 100644 --- a/common-project/src/org/tizen/emulator/manager/platform/BaseImage.java +++ b/common-project/src/org/tizen/emulator/manager/platform/BaseImage.java @@ -67,7 +67,7 @@ public class BaseImage { private String information; protected String lastCreatedPropertyPath; - private VMProperty defaultProperty; + protected VMProperty defaultProperty; private ItemList itemList; public static JAXBContext templateContext = null; diff --git a/common-project/src/org/tizen/emulator/manager/platform/CustomBaseImage.java b/common-project/src/org/tizen/emulator/manager/platform/CustomBaseImage.java index 484d617..8b3ccb8 100644 --- a/common-project/src/org/tizen/emulator/manager/platform/CustomBaseImage.java +++ b/common-project/src/org/tizen/emulator/manager/platform/CustomBaseImage.java @@ -34,6 +34,7 @@ import java.io.IOException; import org.tizen.emulator.manager.resources.FilePathResources; import org.tizen.emulator.manager.resources.StringResources; +import org.tizen.emulator.manager.vms.EmulatorVMList; public class CustomBaseImage extends BaseImage { @@ -47,6 +48,7 @@ public class CustomBaseImage extends BaseImage { this.version = "0"; this.binaryVersion = ""; initLastCreatedPropertyPath(); + loadProperty(); } protected void initLastCreatedPropertyPath() { @@ -57,4 +59,47 @@ public class CustomBaseImage extends BaseImage { .append(imageName).append(".xml"); lastCreatedPropertyPath = sb.toString(); } + + private void loadProperty() { + // load default + File propertyFile = new File(platform.platformPath + File.separator + + FilePathResources.getPlatformTemplatePath() + + File.separator + + imageName + "." + PlatformStringResources.CONFIG_EXTENSION); + if (propertyFile.exists()) { + EmulatorVMList vmList = EmulatorVMList.getInstance(); + defaultProperty = vmList.parseXML(propertyFile); + + } else { + // If custom default property not exist, load standard property + if (PlatformList.getPlatformList() != null) { + Platform latest = null; + for (Platform p : PlatformList.getPlatformList()) { + if (p.getProfile().equals(profile)) { + if (latest == null) { + latest = p; + } else { + if (p.getVersion().compareTo(latest.getVersion()) > 0) { + latest = p; + } + } + } + } + + if (latest != null) { + for (BaseImage image : latest.getImageList()) { + if (image.getType() != null && image.getType().equals("default")) { + defaultProperty = image.getDefaultProperty(); + } + } + if (defaultProperty == null) { + if (latest.getImageList().size() > 0) { + defaultProperty = latest.getImageList().get(0).getDefaultProperty(); + } + } + } + // TODO if defaultProperty == null ??? + } + } + } }