skin: modified SDK version loading 36/17136/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 4 Mar 2014 07:52:05 +0000 (16:52 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 4 Mar 2014 08:08:14 +0000 (17:08 +0900)
As the Version Manager changes, version file path was changed.
([SDK_ROOT]/tools/emulator/etc/version -> [SDK_ROOT]/sdk.version)
And file format was changed also.
(text -> property)

Change-Id: I88578a653e6f4ca02f93cfb13cc258593d3cdb65
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java
tizen/src/skin/client/src/org/tizen/emulator/skin/util/SkinUtil.java
tizen/src/skin/client/src/org/tizen/emulator/skin/util/StringUtil.java

index 4f352b3..1fe8429 100644 (file)
@@ -63,6 +63,7 @@ import org.tizen.emulator.skin.util.CocoaUtil;
 import org.tizen.emulator.skin.util.IOUtil;
 import org.tizen.emulator.skin.util.JaxbUtil;
 import org.tizen.emulator.skin.util.SkinRotation;
+import org.tizen.emulator.skin.util.SkinUtil;
 import org.tizen.emulator.skin.util.StringUtil;
 import org.tizen.emulator.skin.util.SwtUtil;
 
@@ -159,7 +160,8 @@ public class EmulatorSkinMain {
                        /* set skin information */
                        String skinInfoFilePath =
                                        skinPath + File.separator + SKIN_INFO_FILE_NAME;
-                       Properties skinInfoProperties = loadProperties(skinInfoFilePath, false);
+                       Properties skinInfoProperties =
+                                       SkinUtil.loadProperties(skinInfoFilePath, false);
                        if (null == skinInfoProperties) {
                                logger.severe("Fail to load skin information file.");
 
@@ -192,7 +194,8 @@ public class EmulatorSkinMain {
                        /* set emulator window skin property */
                        String skinPropFilePath =
                                        vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME;
-                       Properties skinProperties = loadProperties(skinPropFilePath, true);
+                       Properties skinProperties =
+                                       SkinUtil.loadProperties(skinPropFilePath, true);
                        if (null == skinProperties) {
                                logger.severe("Fail to load skin properties file.");
                        }
@@ -200,7 +203,8 @@ public class EmulatorSkinMain {
                        /* set emulator window config property */
                        String configPropFilePath =
                                        vmPath + File.separator + CONFIG_PROPERTIES_FILE_NAME;
-                       Properties configProperties = loadProperties(configPropFilePath, false);
+                       Properties configProperties =
+                                       SkinUtil.loadProperties(configPropFilePath, false);
                        EmulatorConfig.validateSkinConfigProperties(configProperties);
 
                        /* able to use log file after loading properties */
@@ -454,44 +458,6 @@ public class EmulatorSkinMain {
                return emulatorUI;
        }
 
-       private static Properties loadProperties(
-                       String filePath, boolean create) {
-               FileInputStream fis = null;
-               Properties properties = null;
-
-               try {
-                       File file = new File(filePath);
-                       
-                       if (create == true) {
-                               if (file.exists() == false) {
-                                       if (file.createNewFile() == false) {
-                                               logger.severe(
-                                                               "Fail to create new " + filePath + " property file.");
-                                               return null;
-                                       }
-                               }
-
-                               fis = new FileInputStream(filePath);
-                               properties = new Properties();
-                               properties.load(fis);
-                       } else {
-                               if (file.exists() == true) {
-                                       fis = new FileInputStream(filePath);
-                                       properties = new Properties();
-                                       properties.load(fis);
-                               }
-                       }
-
-                       logger.info("load properties file : " + filePath);
-               } catch (IOException e) {
-                       logger.log(Level.SEVERE, "failed to load skin properties file", e);
-               } finally {
-                       IOUtil.close(fis);
-               }
-
-               return properties;
-       }
-
        public static void terminateImmediately(int exit) {
                if (logger != null) {
                        logger.info("shutdown immediately! exit value : " + exit);
index 5fd127d..4f748e1 100644 (file)
 
 package org.tizen.emulator.skin.config;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
 import java.util.Map;
 import java.util.Properties;
 import java.util.logging.Level;
@@ -135,14 +130,33 @@ public class EmulatorConfig {
                        this.configProperties = new Properties();
                }
 
-               /* load SDK version */
+               /* read SDK version */
+               String strVersion = loadSDKVersion();
+               logger.info("SDK version : " + strVersion);
+
+               setSkinProperty(
+                               EmulatorConfig.SkinInfoConstants.SDK_VERSION_NAME, strVersion);
+       }
+
+       private String loadSDKVersion() {
                String strVersion = "Undefined";
-               String versionFilePath = SkinUtil.getSdkVersionFilePath();
 
-               File file = new File(versionFilePath);
+               String filePath = SkinUtil.getSdkVersionFilePath();
+               Properties properties = SkinUtil.loadProperties(filePath, false);
+
+               if (properties != null) {
+                       strVersion = (String) properties.get("TIZEN_SDK_VERSION");
+                       if (StringUtil.isEmpty(strVersion) == true) {
+                               strVersion = "Undefined";
+                       }
+               } else {
+                       logger.warning("cannot read version from " + filePath);
+               }
+
+               /* File file = new File(filePath);
 
                if (file.exists() == false || file.isFile() == false) {
-                       logger.warning("cannot read version from " + versionFilePath);
+                       logger.warning("cannot read version from " + filePath);
                } else {
                        BufferedReader reader = null;
                        try {
@@ -167,11 +181,9 @@ public class EmulatorConfig {
                                        logger.warning(e.getMessage());
                                }
                        }
-               }
+               } */
 
-               logger.info("SDK version : " + strVersion);
-               setSkinProperty(
-                               EmulatorConfig.SkinInfoConstants.SDK_VERSION_NAME, strVersion);
+               return strVersion;
        }
 
        public static void validateArgs(Map<String, String> args) throws ConfigException {
index 5c7a0c4..b586124 100644 (file)
 package org.tizen.emulator.skin.util;
 
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.lang.reflect.Array;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
+import java.util.Properties;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -107,6 +110,43 @@ public class SkinUtil {
                return vmName + ":" + portNumber;
        }
 
+       public static Properties loadProperties(String filePath, boolean create) {
+               FileInputStream fis = null;
+               Properties properties = null;
+
+               try {
+                       File file = new File(filePath);
+
+                       if (create == true) {
+                               if (file.exists() == false) {
+                                       if (file.createNewFile() == false) {
+                                               logger.severe(
+                                                               "Fail to create new " + filePath + " property file.");
+                                               return null;
+                                       }
+                               }
+
+                               fis = new FileInputStream(filePath);
+                               properties = new Properties();
+                               properties.load(fis);
+                       } else {
+                               if (file.exists() == true) {
+                                       fis = new FileInputStream(filePath);
+                                       properties = new Properties();
+                                       properties.load(fis);
+                               }
+                       }
+
+                       logger.info("load properties file : " + filePath);
+               } catch (IOException e) {
+                       logger.log(Level.SEVERE, "failed to load skin properties file", e);
+               } finally {
+                       IOUtil.close(fis);
+               }
+
+               return properties;
+       }
+
        public static String getSdbPath() {
                String sdbPath = null;
 
@@ -124,7 +164,8 @@ public class SkinUtil {
        }
 
        public static String getSdkVersionFilePath() {
-               return ".." + File.separator + "etc" + File.separator + "version";
+               return ".." + File.separator + ".." + File.separator +
+                               ".." + File.separator + "sdk.version";
        }
 
        public static List<KeyMapType> getHWKeyMapList(short rotationId) {
index d4e4c77..34a7899 100644 (file)
@@ -37,15 +37,16 @@ import java.io.IOException;
  *
  */
 public class StringUtil {
-       
-       private StringUtil(){}
-       
-       public static boolean isEmpty( String value ) {
-               return ( null == value ) || ( 0 == value.length() );
+       private StringUtil() {
+               /* do nothing */
        }
 
-       public static String nvl( String value ) {
-               return ( null == value ) ? "" : value;
+       public static boolean isEmpty(String value) {
+               return (null == value) || (0 == value.length());
+       }
+
+       public static String nvl(String value) {
+               return (null == value) ? "" : value;
        }
 
        public static String getCanonicalPath(String filePath) throws IOException {
@@ -60,8 +61,8 @@ public class StringUtil {
                        canonicalPath = file.getCanonicalPath();
 
                        if (file.isDirectory() == false) {
-                               canonicalPath =
-                                               canonicalPath.substring(0, canonicalPath.lastIndexOf(File.separator));
+                               canonicalPath = canonicalPath.substring(
+                                               0, canonicalPath.lastIndexOf(File.separator));
                                if (canonicalPath.compareTo("") == 0) {
                                        return "./";
                                }