encoding: use UTF-8 encoding.
authorminkee.lee <minkee.lee@samsung.com>
Wed, 2 Sep 2015 01:34:19 +0000 (10:34 +0900)
committerminkee Lee <minkee.lee@samsung.com>
Wed, 2 Sep 2015 02:32:25 +0000 (11:32 +0900)
- write: emulator-manager.log, vm_launch.conf
- read: sdk.info

Change-Id: I3097cdebdbb3c67ed4ddcadf1a0aa6ac321d2aeb
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
src/org/tizen/emulator/manager/logging/EMLogger.java
src/org/tizen/emulator/manager/resources/FilePathResources.java
src/org/tizen/emulator/manager/vms/option/LaunchConfig.java

index 926da38..c4ceedd 100644 (file)
@@ -114,6 +114,7 @@ public class EMLogger {
                                logFileHandler.setLevel(Level.INFO);
                        }
                        logFileHandler.setFormatter(new LoggerFormatter());
+                       logFileHandler.setEncoding("UTF-8");
                        logger.addHandler(logFileHandler);
                } catch (SecurityException e) {
                        logger.setLevel(Level.OFF);
index b989c6a..fec9720 100644 (file)
@@ -32,9 +32,12 @@ package org.tizen.emulator.manager.resources;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
 import java.net.URISyntaxException;
 
 import org.tizen.emulator.manager.EmulatorManager;
@@ -46,12 +49,14 @@ import org.tizen.emulator.manager.vms.EmulatorVMList;
 
 public class FilePathResources {
        private final static String sdk_suffix = ".." + File.separator + ".." + File.separator + ".."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-       private final static String bin_suffix  = File.separator + "bin"; //$NON-NLS-1$
+       private final static String bin_suffix = File.separator + "bin"; //$NON-NLS-1$
        private final static String tool_suffix = File.separator + "tools"; //$NON-NLS-1$
        private final static String emulator_suffix = File.separator + "emulator"; //$NON-NLS-1$
-       private final static String platform_suffix  = File.separator + "platforms"; //$NON-NLS-1$
-       private final static String em_images_suffix    = File.separator + "emulator-images"; //$NON-NLS-1$
-       private final static String resource_suffix  = File.separator + "emulator-resources"; //$NON-NLS-1$
+       private final static String platform_suffix = File.separator + "platforms"; //$NON-NLS-1$
+       private final static String em_images_suffix = File.separator
+                       + "emulator-images"; //$NON-NLS-1$
+       private final static String resource_suffix = File.separator
+                       + "emulator-resources"; //$NON-NLS-1$
        private final static String common_suffix = File.separator + "common"; //$NON-NLS-1$
        private final static String platform_prefix = File.separator + "tizen-"; //$NON-NLS-1$
 
@@ -59,16 +64,18 @@ public class FilePathResources {
        private final static String etc_suffix = File.separator + "etc"; //$NON-NLS-1$
        private final static String remote_suffix = File.separator + "remote"; //$NON-NLS-1$
        private final static String bios_suffix = File.separator + "bios"; //$NON-NLS-1$
-       private final static String kernel_suffix = File.separator +"kernel"; //$NON-NLS-1$
+       private final static String kernel_suffix = File.separator + "kernel"; //$NON-NLS-1$
        private final static String swap_suffix = File.separator + "swap"; //$NON-NLS-1$
-       private final static String data_suffix = File.separator +"data"; //$NON-NLS-1$
+       private final static String data_suffix = File.separator + "data"; //$NON-NLS-1$
        private final static String images_suffix = File.separator + "images"; //$NON-NLS-1$
 
        private final static String win_sdb_exec = File.separator + "sdb.exe"; //$NON-NLS-1$
        private final static String sdb_exec = File.separator + "sdb"; //$NON-NLS-1$
 
-       private final static String sdkpath_suffix = File.separator + "tizensdkpath"; //$NON-NLS-1$
-       private final static String sdkdata_suffix = File.separator + "tizen-sdk-data"; //$NON-NLS-1$
+       private final static String sdkpath_suffix = File.separator
+                       + "tizensdkpath"; //$NON-NLS-1$
+       private final static String sdkdata_suffix = File.separator
+                       + "tizen-sdk-data"; //$NON-NLS-1$
        private final static String storages_suffix = File.separator + "storages"; //$NON-NLS-1$
        private final static String sdcard_suffix = File.separator + "sdcard"; //$NON-NLS-1$
        private final static String skins_suffix = File.separator + "skins"; //$NON-NLS-1$
@@ -76,12 +83,13 @@ public class FilePathResources {
        private final static String template2_suffix = File.separator + "template2"; //$NON-NLS-1$
        private final static String plugins_suffix = File.separator + "plugins"; //$NON-NLS-1$
 
-       private final static String sdkdata_new_emulator_suffix = File.separator + "emulator"; //$NON-NLS-1$
+       private final static String sdkdata_new_emulator_suffix = File.separator
+                       + "emulator"; //$NON-NLS-1$
        private final static String vms_suffix = File.separator + "vms"; //$NON-NLS-1$
 
        private final static String qemuImg_suffix = File.separator + "qemu-img"; //$NON-NLS-1$
        private final static String checkCam_suffix = File.separator + "check-cam" //$NON-NLS-1$
-                       + (EmulatorManager.isWin() ? ".exe" : "") ; //$NON-NLS-1$ //$NON-NLS-2$
+                       + (EmulatorManager.isWin() ? ".exe" : ""); //$NON-NLS-1$ //$NON-NLS-2$
 
        // Tizen SDK
        private static String currentPath;
@@ -107,7 +115,7 @@ public class FilePathResources {
        private static String sdkDataSdcardPath;
        private static String sdkDataSwapPath;
 
-       private final static String log_suffix = File.separator +"logs"; //$NON-NLS-1$
+       private final static String log_suffix = File.separator + "logs"; //$NON-NLS-1$
        private static String tizensdkdataPath;
        private static String tizensdkdataEmulatorPath;;
        private static String sdkDataVmsPath;
@@ -117,7 +125,8 @@ public class FilePathResources {
                {
                        File jar = null;
                        try {
-                               jar = new File(EmulatorManager.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
+                               jar = new File(EmulatorManager.class.getProtectionDomain()
+                                               .getCodeSource().getLocation().toURI().getPath());
                        } catch (URISyntaxException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
@@ -135,7 +144,7 @@ public class FilePathResources {
                }
 
                if (sdkPath == null) {
-                               sdkPath = currentPath;
+                       sdkPath = currentPath;
                }
 
                String toolsPath = ""; //$NON-NLS-1$
@@ -146,7 +155,8 @@ public class FilePathResources {
                }
 
                try {
-                       toolEmulatorPath = new File(toolsPath + emulator_suffix).getCanonicalPath();
+                       toolEmulatorPath = new File(toolsPath + emulator_suffix)
+                                       .getCanonicalPath();
                } catch (IOException e) {
                        toolEmulatorPath = toolsPath + emulator_suffix;
                }
@@ -175,15 +185,16 @@ public class FilePathResources {
 
                toolEmulatorBinPath = toolEmulatorPath + bin_suffix;
 
-               toolEmulatorEtcPath = toolEmulatorPath +  etc_suffix;
+               toolEmulatorEtcPath = toolEmulatorPath + etc_suffix;
                toolEmulatorRemotePath = toolEmulatorPath + remote_suffix;
 
                sdkDataSdcardPath = toolEmulatorPath + storages_suffix + sdcard_suffix;
                sdkDataSwapPath = toolEmulatorPath + storages_suffix + swap_suffix;
 
-               tizensdkdataEmulatorPath = tizensdkdataPath + sdkdata_new_emulator_suffix;
+               tizensdkdataEmulatorPath = tizensdkdataPath
+                               + sdkdata_new_emulator_suffix;
                sdcardPath = tizensdkdataEmulatorPath + sdcard_suffix;
-//             swapPath = tizensdkdataEmulatorPath + swap_suffix;
+               // swapPath = tizensdkdataEmulatorPath + swap_suffix;
                swapPath = sdkDataSwapPath;
                sdkDataVmsPath = tizensdkdataEmulatorPath + vms_suffix;
 
@@ -194,42 +205,47 @@ public class FilePathResources {
        private static String findSDKDataPath() {
                String dataPath = null;
                // read sdk.info file
-               File sdkInfoFile = new File(currentPath + File.separator + sdk_suffix + sdkinfo_suffix);
+               File sdkInfoFile = new File(currentPath + File.separator + sdk_suffix
+                               + sdkinfo_suffix);
                if (sdkInfoFile.exists()) {
-                               EMLogger.addStaticLog("sdk.info file path: " + sdkInfoFile); //$NON-NLS-1$
-                               BufferedReader in = null;
-                               try {
-                                       in = new BufferedReader(new FileReader(sdkInfoFile));
-                               } catch (FileNotFoundException e) {
-                                       EMLogger.getLogger().warning(e.getMessage());
-                               }
-                               String s = null;;
-                               try {
-                                       while((s = in.readLine()) != null) {
-                                               int i = s.indexOf("="); //$NON-NLS-1$
-                                               if (i != -1) {
-                                                       String s1 = s.substring(0, i);
-                                                       String s2 = s.substring(i+1, s.length());
-                                                       if (s1.equals("TIZEN_SDK_INSTALLED_PATH")) { //$NON-NLS-1$
-                                                               sdkPath = s2;
-                                                               EMLogger.addStaticLog("TIZEN_SDK_INSTALLED_PATH: " //$NON-NLS-1$
-                                                                               + sdkPath);
-                                                       } else if (s1.equals("TIZEN_SDK_DATA_PATH")) { //$NON-NLS-1$
-                                                               dataPath = s2;
-                                                               EMLogger.addStaticLog("TIZEN_SDK_DATA_PATH: " //$NON-NLS-1$
-                                                                               + dataPath);
-                                                       }
+                       EMLogger.addStaticLog("sdk.info file path: " + sdkInfoFile); //$NON-NLS-1$
+                       BufferedReader in = null;
+                       try {
+                               in = new BufferedReader(new InputStreamReader(
+                                               new FileInputStream(sdkInfoFile), "UTF-8"));
+                       } catch (FileNotFoundException | UnsupportedEncodingException e) {
+                               EMLogger.getLogger().warning(
+                                               "Failed to open sdk.info file : " + e.getMessage());
+                               return null;
+                       }
+
+                       String s = null;
+                       try {
+                               while ((s = in.readLine()) != null) {
+                                       int i = s.indexOf("="); //$NON-NLS-1$
+                                       if (i != -1) {
+                                               String s1 = s.substring(0, i);
+                                               String s2 = s.substring(i + 1, s.length());
+                                               if (s1.equals("TIZEN_SDK_INSTALLED_PATH")) { //$NON-NLS-1$
+                                                       sdkPath = s2;
+                                                       EMLogger.addStaticLog("TIZEN_SDK_INSTALLED_PATH: " //$NON-NLS-1$
+                                                                       + sdkPath);
+                                               } else if (s1.equals("TIZEN_SDK_DATA_PATH")) { //$NON-NLS-1$
+                                                       dataPath = s2;
+                                                       EMLogger.addStaticLog("TIZEN_SDK_DATA_PATH: " //$NON-NLS-1$
+                                                                       + dataPath);
                                                }
                                        }
-                               } catch (IOException e) {
-                                       EMLogger.addStaticLog(e.getMessage());
                                }
+                       } catch (IOException e) {
+                               EMLogger.addStaticLog(e.getMessage());
+                       }
 
-                               try {
-                                       in.close();
-                               } catch (IOException e) {
-                                       EMLogger.addStaticLog(e.getMessage());
-                               }
+                       try {
+                               in.close();
+                       } catch (IOException e) {
+                               EMLogger.addStaticLog(e.getMessage());
+                       }
                }
 
                if (dataPath == null || dataPath.isEmpty()) {
@@ -273,10 +289,10 @@ public class FilePathResources {
                                try {
                                        in = new BufferedReader(new FileReader(f));
                                        String s;
-                                       while((s = in.readLine()) != null) {
+                                       while ((s = in.readLine()) != null) {
                                                int i = s.indexOf("="); //$NON-NLS-1$
                                                if (i != -1) {
-                                                       String s2 = s.substring(i+1, s.length());
+                                                       String s2 = s.substring(i + 1, s.length());
                                                        sdkPath = s2;
                                                }
                                        }
@@ -307,7 +323,7 @@ public class FilePathResources {
        static FilePathResources instance = null;
 
        static {
-               synchronized(FilePathResources.class) {
+               synchronized (FilePathResources.class) {
                        instance = new FilePathResources();
                }
        }
@@ -315,11 +331,11 @@ public class FilePathResources {
        private FilePathResources() {
        }
 
-       public static String getSdkRoot(){
+       public static String getSdkRoot() {
                return sdkPath;
        }
 
-       public static String getSdbPath(){
+       public static String getSdbPath() {
                return sdbPath;
        }
 
@@ -328,7 +344,7 @@ public class FilePathResources {
                return toolEmulatorPath;
        }
 
-       public static String getToolEmulatorBinPath(){
+       public static String getToolEmulatorBinPath() {
                return toolEmulatorBinPath;
        }
 
@@ -342,7 +358,7 @@ public class FilePathResources {
 
        // emulator common check tool
        public static String getEmulatorCheckToolPath() {
-                return getToolEmulatorBinPath();
+               return getToolEmulatorBinPath();
        }
 
        public static String getEmulatorQemuImgPath() {
@@ -382,10 +398,11 @@ public class FilePathResources {
                }
                try {
                        emulatorPath = new File(platformsPath + platform_prefix
-                                       + platformVersion + common_suffix + emulator_suffix).getCanonicalPath();
+                                       + platformVersion + common_suffix + emulator_suffix)
+                                       .getCanonicalPath();
                } catch (IOException e) {
-                       emulatorPath = platformsPath + platform_prefix
-                                       + platformVersion + common_suffix + emulator_suffix;
+                       emulatorPath = platformsPath + platform_prefix + platformVersion
+                                       + common_suffix + emulator_suffix;
                }
                return emulatorPath;
        }
@@ -438,6 +455,7 @@ public class FilePathResources {
        public static String getSwapPath() {
                return swapPath;
        }
+
        public static String getbaseSwapPath() {
                return sdkDataSwapPath;
        }
@@ -459,7 +477,7 @@ public class FilePathResources {
        }
 
        public static String getPlatformTemplate2Path() {
-               return platformTemplate2Path ;
+               return platformTemplate2Path;
        }
 
        public static String getPlatformPluginsPath() {
@@ -478,7 +496,7 @@ public class FilePathResources {
                if (path != null) {
                        String arr[] = path.split("\\.");
                        if (arr.length > 1) {
-                               return arr[arr.length-1];
+                               return arr[arr.length - 1];
                        }
                }
                return "";
index faee9bf..c09ffeb 100644 (file)
@@ -32,9 +32,10 @@ import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.FileReader;
-import java.io.FileWriter;
 import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -132,7 +133,7 @@ public class LaunchConfig {
        private void writeFile(File file) throws VMWorkerException {
                BufferedWriter bw = null;
                try {
-                       bw = new BufferedWriter(new FileWriter(file));
+                       bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
 
                        // Write variables
                        bw.write(DEFAULT_VALUE);