skin: remove dubious method used 42/12942/1
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 26 Nov 2013 05:31:23 +0000 (14:31 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 26 Nov 2013 06:31:17 +0000 (15:31 +0900)
1. To specify an explicit charset, I give encoding
argument for String construct.
2. define terminateImmediately function

Change-Id: Ibfd5b8e4184fb492fe9b22e3ceb123f35ed9b185
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorShmSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java
tizen/src/skin/client/src/org/tizen/emulator/skin/dialog/DetailInfoDialog.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/GeneralPurposeSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/layout/ProfileSpecificSkinComposer.java
tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java
tizen/src/skin/client/src/org/tizen/emulator/skin/menu/SpecialKeyWindow.java

index 9feeb05..be5e1e9 100644 (file)
@@ -88,7 +88,7 @@ public class EmulatorShmSkin extends EmulatorSkin {
                        messageBox.open();
                        temp.dispose();
 
-                       System.exit(-1);
+                       EmulatorSkinMain.terminateImmediately(-1);;
                }
        }
 
@@ -290,7 +290,7 @@ public class EmulatorShmSkin extends EmulatorSkin {
                                        "Failed to get identifier of the shared memory segment.",
                                        SWT.ICON_ERROR, config);
 
-                       System.exit(-1);
+                       EmulatorSkinMain.terminateImmediately(-1);
                } else if (result == 2) {
                        logger.severe("Failed to attach the shared memory segment.");
                        SkinUtil.openMessage(shell, null,
@@ -298,7 +298,7 @@ public class EmulatorShmSkin extends EmulatorSkin {
                                        "Failed to attach the shared memory segment.",
                                        SWT.ICON_ERROR, config);
 
-                       System.exit(-1);
+                       EmulatorSkinMain.terminateImmediately(-1);
                }
 
                /* display updater thread */
index b2f137a..6079201 100755 (executable)
@@ -1648,7 +1648,7 @@ public class EmulatorSkin {
                                        shell.getDisplay().asyncExec(new Runnable() {
                                                @Override
                                                public void run() {
-                                                       System.exit(-1);
+                                                       EmulatorSkinMain.terminateImmediately(-1);
                                                }
                                        });
                                }
index 3a52abc..2edc547 100644 (file)
@@ -100,7 +100,7 @@ public class EmulatorSkinMain {
                        messageBox.open();
                        temp.dispose();
 
-                       System.exit(-1);
+                       return;
                }
 
                SocketCommunicator communicator = null;
@@ -163,7 +163,7 @@ public class EmulatorSkinMain {
                                messageBox.open();
                                temp.dispose();
 
-                               System.exit(-1);
+                               terminateImmediately(-1);
                        }
 
                        String skinInfoResolutionW =
@@ -225,7 +225,7 @@ public class EmulatorSkinMain {
                                messageBox.open();
                                temp.dispose();
 
-                               System.exit(-1);
+                               terminateImmediately(-1);
                        }
                        logger.info("dbi version : " + dbiContents.getDbiVersion());
 
@@ -301,7 +301,7 @@ public class EmulatorSkinMain {
                        if (null != communicator) {
                                communicator.terminate();
                        } else {
-                               System.exit(-1);
+                               terminateImmediately(-1);
                        }
                } finally {
                        ImageRegistry.getInstance().dispose();
@@ -478,4 +478,12 @@ public class EmulatorSkinMain {
 
                return properties;
        }
+
+       public static void terminateImmediately(int exit) {
+               if (logger != null) {
+                       logger.info("shutdown immediately! exit value : " + exit);
+               }
+
+               System.exit(exit);
+       }
 }
index c6a3e38..c11a892 100755 (executable)
@@ -317,8 +317,8 @@ public class SocketCommunicator implements ICommunicator {
 
                                        byte[] receivedData = getReceivedData(miscDataTransfer);
                                        if (null != receivedData) {
-                                               String strLayer = new String(receivedData, 0, 1);
-                                               String strValue = new String(receivedData, 1, length - 2);
+                                               String strLayer = new String(receivedData, 0, 1, "UTF-8");
+                                               String strValue = new String(receivedData, 1, length - 2, "UTF-8");
 
                                                int layer = 0;
                                                int value = 0;
@@ -343,7 +343,7 @@ public class SocketCommunicator implements ICommunicator {
 
                                        byte[] receivedData = getReceivedData(miscDataTransfer);
                                        if (null != receivedData) {
-                                               String strValue = new String(receivedData, 0, length - 1);
+                                               String strValue = new String(receivedData, 0, length - 1, "UTF-8");
 
                                                int value = 1;
                                                try {
@@ -375,7 +375,7 @@ public class SocketCommunicator implements ICommunicator {
 
                                        byte[] receivedData = getReceivedData(miscDataTransfer);
                                        if (null != receivedData) {
-                                               String strValue = new String(receivedData, 0, length - 1);
+                                               String strValue = new String(receivedData, 0, length - 1, "UTF-8");
 
                                                int value = 1;
                                                try {
index 3f9c7e1..7286749 100644 (file)
@@ -143,8 +143,7 @@ public class EmulatorConfig {
                } else {
                        BufferedReader reader = null;
                        try {
-                               reader = new BufferedReader(
-                                               new FileReader(versionFilePath));
+                               reader = new BufferedReader(new FileReader(file));
                        } catch (FileNotFoundException e) {
                                logger.warning(e.getMessage());
                        }
index e7ffc1f..1289890 100644 (file)
@@ -244,7 +244,7 @@ public class DetailInfoDialog extends SkinDialog {
                                infoData = new String(receivedData, "UTF-8");
                        } catch (UnsupportedEncodingException e) {
                                logger.warning("unsupported encoding exception");
-                               infoData = new String(receivedData);
+                               infoData = null;
                        }
                } else {
                        logger.severe("Fail to get detail info");
index 8c7da19..3f130e9 100644 (file)
@@ -47,6 +47,7 @@ import org.eclipse.swt.widgets.Canvas;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.EmulatorSkin;
+import org.tizen.emulator.skin.EmulatorSkinMain;
 import org.tizen.emulator.skin.comm.ICommunicator.RotationInfo;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
@@ -237,7 +238,8 @@ public class GeneralPurposeSkinComposer implements ISkinComposer {
                                        "Failed to read display information for skin.\n" +
                                        "Check the contents of skin dbi file.",
                                        SWT.ICON_ERROR, config);
-                       System.exit(-1);
+
+                       EmulatorSkinMain.terminateImmediately(-1);
                }
                logger.info("display bounds : " + displayBounds);
 
index 6ccaf70..16b86c1 100644 (file)
@@ -49,6 +49,7 @@ import org.eclipse.swt.graphics.Region;
 import org.eclipse.swt.widgets.Canvas;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.emulator.skin.EmulatorSkin;
+import org.tizen.emulator.skin.EmulatorSkinMain;
 import org.tizen.emulator.skin.comm.ICommunicator.KeyEventType;
 import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
 import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
@@ -158,7 +159,8 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                        logger.severe("Failed to load initial skin image file. Kill this skin process.");
                        SkinUtil.openMessage(shell, null,
                                        "Failed to load Skin image file.", SWT.ICON_ERROR, config);
-                       System.exit(-1);
+
+                       EmulatorSkinMain.terminateImmediately(-1);
                }
 
                /* open the key window if key window menu item was enabled */
@@ -198,7 +200,8 @@ public class ProfileSpecificSkinComposer implements ISkinComposer {
                                        "Failed to read display information for skin.\n" +
                                        "Check the contents of skin dbi file.",
                                        SWT.ICON_ERROR, config);
-                       System.exit(-1);
+
+                       EmulatorSkinMain.terminateImmediately(-1);
                }
                logger.info("display bounds : " + displayBounds);
 
index 238d83c..6f7a786 100644 (file)
@@ -44,6 +44,7 @@ import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
+import org.tizen.emulator.skin.EmulatorSkinMain;
 import org.tizen.emulator.skin.util.StringUtil;
 
 /**
@@ -135,13 +136,13 @@ public class SkinLogger {
                                                System.err.println("[SkinLog:error] "
                                                                + "Cannot create skin log file. path : " + file.getAbsolutePath());
 
-                                               System.exit(-1);
+                                               EmulatorSkinMain.terminateImmediately(-1);
                                                return;
                                        }
                                } catch (IOException e) {
                                        e.printStackTrace();
 
-                                       System.exit(-1);
+                                       EmulatorSkinMain.terminateImmediately(-1);
                                        return;
                                }
                        }
index 0406969..4a26946 100644 (file)
@@ -78,7 +78,6 @@ public class SpecialKeyWindow extends SkinWindow {
        public static final String KEYWINDOW_LAYOUT_ROOT = "keywindow-layout";
        public static final String DBI_FILE_NAME = "default.dbi";
 
-       private EmulatorSkin skin;
        private SpecialKeyWindowImageRegistry imageRegistry;
        private SocketCommunicator communicator;
 
@@ -99,7 +98,6 @@ public class SpecialKeyWindow extends SkinWindow {
        public SpecialKeyWindow(EmulatorSkin skin, String layoutName) {
                super(skin.getShell(), SWT.RIGHT | SWT.CENTER);
 
-               this.skin = skin;
                this.parent = skin.getShell();
                this.shell = new Shell(parent.getDisplay() /* for Mac & Always on Top */,
                                SWT.NO_TRIM | SWT.RESIZE | SWT.TOOL | SWT.NO_FOCUS);