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>
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;
/* 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.");
/* 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.");
}
/* 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 */
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);
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;
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 {
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 {
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;
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;
}
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) {
*
*/
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 {
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 "./";
}