job: GPU checking routine is moved to job "CheckGPU"
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Fri, 12 Jun 2015 05:00:59 +0000 (14:00 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Fri, 12 Jun 2015 08:30:33 +0000 (17:30 +0900)
Removed CheckVirtualization class since it is not used anymore.

Change-Id: Id83a1faf3a21267672b302a92e498565d942074f
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
src/org/tizen/emulator/manager/console/ActionList.java
src/org/tizen/emulator/manager/console/ConsoleCreateVM.java
src/org/tizen/emulator/manager/job/CheckGPU.java
src/org/tizen/emulator/manager/job/CheckVT.java
src/org/tizen/emulator/manager/tool/CheckVirtualization.java [deleted file]
src/org/tizen/emulator/manager/ui/detail/item/property/GPUSupportSubViewItem.java
src/org/tizen/emulator/manager/vms/VMPropertyValue.java
src/org/tizen/emulator/manager/vms/option/HWSupportOption.java

index c25f3a1..f477812 100644 (file)
@@ -32,10 +32,10 @@ package org.tizen.emulator.manager.console;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.tizen.emulator.manager.job.CheckGPU;
 import org.tizen.emulator.manager.job.CheckVT;
 import org.tizen.emulator.manager.resources.FilePathResources;
 import org.tizen.emulator.manager.resources.StringResources;
-import org.tizen.emulator.manager.tool.CheckVirtualization;
 import org.tizen.emulator.manager.vms.RAM_SIZE;
 import org.tizen.emulator.manager.vms.RESOLUTION;
 
@@ -432,7 +432,7 @@ class Create extends Action {
                                CheckVT.isVTSupported() ? "yes" : "no", false, true));
                commandList.add(new Command("g", Actions.OP_GLACCELERATION,
                                Actions.DESC_GLACCELERATION,
-                               CheckVirtualization.getInstance().isSupportGPU() ? "yes" : "no", false, true));
+                               CheckGPU.isGPUSupported() ? "yes" : "no", false, true));
                /*
                commandList.add(new Command("t", Actions.OP_MAXTOUCH,
                                "Set count of multi touch point.(1 ~ 3)", Integer.toString(property.maxTouchCount), false, true));
@@ -568,7 +568,7 @@ class Modify extends Action {
                                CheckVT.isVTSupported() ? "yes" : "no", false, true));
                commandList.add(new Command("g", Actions.OP_GLACCELERATION,
                                Actions.DESC_GLACCELERATION,
-                               CheckVirtualization.getInstance().isSupportGPU() ? "yes" : "no", false, true));
+                               CheckGPU.isGPUSupported() ? "yes" : "no", false, true));
                /*
                commandList.add(new Command("t", Actions.OP_MAXTOUCH,
                                "Set count of multi touch point.(1 or 2)", Integer.toString(property.maxTouchCount), false, true));
index a5f2d02..0c632d8 100644 (file)
@@ -34,6 +34,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.tizen.emulator.manager.job.CheckGPU;
 import org.tizen.emulator.manager.job.CheckVT;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.platform.BaseImage;
@@ -43,7 +44,6 @@ import org.tizen.emulator.manager.platform.Profile;
 import org.tizen.emulator.manager.platform.ProfileList;
 import org.tizen.emulator.manager.platform.Skin;
 import org.tizen.emulator.manager.resources.StringResources;
-import org.tizen.emulator.manager.tool.CheckVirtualization;
 import org.tizen.emulator.manager.vms.Creator;
 import org.tizen.emulator.manager.vms.RAM_SIZE;
 import org.tizen.emulator.manager.vms.RESOLUTION;
@@ -458,7 +458,7 @@ public class ConsoleCreateVM {
                                System.out.println("So this value set false.");
                                return false;
                        }
-                       if (!CheckVirtualization.getInstance().isSupportGPU()) {
+                       if (!CheckGPU.isGPUSupported()) {
                                throw new ConsoleException("This computer does not support GPU.");
                        } else {
                                return true;
index 9814d2b..186b4a2 100644 (file)
@@ -1,10 +1,54 @@
 package org.tizen.emulator.manager.job;
 
-import org.tizen.emulator.manager.tool.CheckVirtualization;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.FilePathResources;
+import org.tizen.emulator.manager.vms.helper.HelperClass;
+import org.tizen.emulator.manager.vms.helper.ProcessResult;
 
 public class CheckGPU implements Job {
+       private static final String GPU_CHECKER;
+
+       private static boolean isGPUSupported = false;
+       private static boolean isGallium = false;
+
+       static {
+               GPU_CHECKER = EmulatorManager.isWin() ? "check-gl.exe" : "check-gl";
+       }
+
+       public static boolean isGPUSupported() {
+               return isGPUSupported;
+       }
+
+       public static boolean isGallium() {
+               return isGallium;
+       }
+
        @Override
        public void work() {
-               CheckVirtualization.getInstance().check();
+               List<String> cmd = new ArrayList<String>();
+               cmd.add(FilePathResources.getEmulatorToolPath() + File.separator + GPU_CHECKER);
+               ProcessResult result = HelperClass.runProcess(cmd,
+                               new File(FilePathResources.getEmulatorToolPath()));
+
+               switch (result.getExitValue()) {
+               case 0:
+                       isGPUSupported = true;
+                       break;
+               case 2:
+                       isGPUSupported = true;
+                       isGallium = true;
+                       break;
+               default:
+                       break;
+               }
+
+               EMLogger.getLogger().log(Level.INFO, "Support GPU: "    + Boolean.toString(isGPUSupported));
+               EMLogger.getLogger().log(Level.INFO, "Gallium: "        + Boolean.toString(isGallium));
        }
 }
index b413eb3..5c32249 100644 (file)
@@ -15,6 +15,8 @@ public class CheckVT implements Job {
        private static final String HAX_CHECKER;
        private static final String ENABLE_HAX = "-enable-hax";
        private static final String ENABLE_KVM = "-enable-kvm";
+       // for linux
+       private static final String KVM_DEV_NODE = "/dev/kvm";
 
        private static boolean isVTSupported = false;
        private static boolean isNonUG = false; // for HAXM, non-UG CPU
@@ -60,12 +62,14 @@ public class CheckVT implements Job {
                                break;
                        }
                } else if (EmulatorManager.isLinux()) {
-                       if(new File("/dev/kvm").canRead()) {
+                       if(new File(KVM_DEV_NODE).canRead()) {
                                isVTSupported = true;
                        }
                }
 
                EMLogger.getLogger().log(Level.INFO, "Support HW virtualization: "
                                + Boolean.toString(isVTSupported));
+               EMLogger.getLogger().log(Level.INFO, "non-UG: "
+                               + Boolean.toString(isNonUG));
        }
 }
diff --git a/src/org/tizen/emulator/manager/tool/CheckVirtualization.java b/src/org/tizen/emulator/manager/tool/CheckVirtualization.java
deleted file mode 100644 (file)
index 9e59b4d..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Emulator Manager
- *
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * JiHye Kim <jihye1128.kim@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.emulator.manager.tool;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-
-import org.tizen.emulator.manager.logging.EMLogger;
-import org.tizen.emulator.manager.resources.FilePathResources;
-
-public class CheckVirtualization {
-       private static CheckVirtualization instance     = new CheckVirtualization();
-       private static boolean isGPUSupport = true;
-       private static String GPU_enable_command        = null;
-       private static String GPU_disable_command       = null;
-
-       private static boolean isCheck = false;
-       private static boolean isGallium = false; // for ubuntu OS
-
-       private CheckVirtualization() {
-               // singleton class
-       }
-
-       public static CheckVirtualization getInstance() {
-               return instance;
-       }
-
-       public boolean isSupportGPU() {
-               return isGPUSupport;
-       }
-
-       public boolean isGallium() {
-               return isGallium;
-       }
-
-       public void check() {
-               if (!isCheck) {
-                       checkGPU();
-                       isCheck = true;
-               }
-       }
-
-       private void checkGPU() {
-               GPUCheckWork work = new GPUCheckWork();
-               work.setDaemon(true);
-               work.start();
-
-               try {
-                       work.join();
-               } catch (InterruptedException e) {
-                       EMLogger.getLogger().log(Level.WARNING, "Exception" + e.getMessage());
-               }
-       }
-
-       public String getGPU_enable_command() {
-               return GPU_enable_command;
-       }
-
-       public String getGPU_disable_command() {
-               return GPU_disable_command;
-       }
-
-       private static class GPUCheckWork extends Thread {
-               @Override
-               public void run() {
-                       GPU_enable_command = "-enable-gl";
-
-                       int exitValue = 1;
-
-                       List<String> cmd = new ArrayList<String>();
-                       cmd.add(FilePathResources.getEmulatorToolPath() + File.separator +
-                                       (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1 ? "check-gl.exe" : "check-gl"));
-                       ProcessBuilder pb = new ProcessBuilder(cmd);
-                       pb.directory(new File(FilePathResources.getEmulatorToolPath()));
-
-                       try {
-                               Process process = pb.start();
-                               ProcessOutputReader.startRead(process, "check-gl");
-                               process.waitFor();
-                               exitValue = process.exitValue();
-                               EMLogger.getLogger().log(Level.CONFIG, "'check-gl's exit value : " + exitValue);
-                       } catch (IOException e) {
-                               EMLogger.getLogger().log(Level.WARNING, "IOException" + e.getMessage());
-                       }  catch (InterruptedException e) {
-                               EMLogger.getLogger().log(Level.WARNING, "InterruptedException" + e.getMessage());
-                       }  catch (Exception e) {
-                               EMLogger.getLogger().log(Level.WARNING, "Exception" + e.getMessage());
-                       }
-
-                       if( exitValue == 0) {
-                               isGPUSupport = true;
-
-                       } else if (exitValue == 2) {
-                               isGPUSupport = true;
-                               isGallium = true;
-
-                       } else {
-                               GPU_enable_command = "";
-                               isGPUSupport = false;
-                       }
-                       EMLogger.getLogger().log(Level.INFO, "Support GPU: "
-                                       + (isGPUSupport ? "true" : "false"));
-               }
-       }
-}
-
-class ProcessOutputReader extends Thread {
-
-       private final BufferedReader reader;
-       private final String processName;
-       private final List<String> msgList = new ArrayList<String>();
-
-       public ProcessOutputReader(BufferedReader reader, String processName) {
-               this.reader = reader;
-               this.processName = processName;
-               this.setDaemon(true);
-       }
-
-       // Read output/error stream of process to prevent blocking due to full of buffer.
-       public static void startRead(Process process, String processName) {
-               BufferedReader out = new BufferedReader(new InputStreamReader(process.getInputStream()));
-               new ProcessOutputReader(out, processName).start();
-
-               BufferedReader err = new BufferedReader(new InputStreamReader(process.getErrorStream()));
-               new ProcessOutputReader(err, processName).start();
-       }
-
-       @Override
-       public void run(){
-               String msg;
-               try {
-                       while ((msg = reader.readLine()) != null) {
-                               msgList.add(msg);
-                       }
-               } catch (IOException e) {
-                       EMLogger.getLogger().warning(e.getMessage());
-               } finally {
-                       try {
-                               reader.close();
-                       } catch (IOException e) {
-                               EMLogger.getLogger().warning(e.getMessage());
-                       }
-               }
-
-               if (!msgList.isEmpty()) {
-                       EMLogger.getLogger().info(processName + "'s stdout/stderr");
-                       for (String s : msgList) {
-                               EMLogger.getLogger().info(s);
-                       }
-                       msgList.clear();
-               }
-       }
-
-}
index 094a3ef..cf08d49 100644 (file)
@@ -34,12 +34,11 @@ package org.tizen.emulator.manager.ui.detail.item.property;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
-import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.job.CheckGPU;
 import org.tizen.emulator.manager.resources.ColorResources;
 import org.tizen.emulator.manager.resources.FontResources;
 import org.tizen.emulator.manager.resources.ImageResources;
 import org.tizen.emulator.manager.resources.StringResources;
-import org.tizen.emulator.manager.tool.CheckVirtualization;
 import org.tizen.emulator.manager.ui.detail.item.ItemState;
 import org.tizen.emulator.manager.ui.detail.item.template.LabelViewItem;
 import org.tizen.emulator.manager.ui.detail.item.template.OnOffSubViewItem;
@@ -49,7 +48,7 @@ import org.tizen.emulator.manager.vms.xml.template.Item;
 
 public class GPUSupportSubViewItem extends OnOffSubViewItem {
 
-       private boolean isArm = false;
+       private final boolean isArm = false;
        private static String GPUToolTipText = "If you enable the GPU option,"
                        + StringResources.NEW_LINE
                        + "the rendering performance of video player or camera may degrade.";
@@ -95,7 +94,7 @@ public class GPUSupportSubViewItem extends OnOffSubViewItem {
 
        @Override
        public boolean settingDetailItem(VMPropertyValue value) {
-               if (!CheckVirtualization.getInstance().isSupportGPU()) {
+               if (!CheckGPU.isGPUSupported()) {
                        valueLabel.setText(StringResources.DISABLED);
                        valueLabel.setToolTipText(GPUDisableToolTipText);
                } else {
@@ -111,7 +110,7 @@ public class GPUSupportSubViewItem extends OnOffSubViewItem {
        public boolean settingModifyItem(VMPropertyValue value) {
                oldValue = newValue = value.isGLAcceleration;
 
-               if (!CheckVirtualization.getInstance().isSupportGPU() || isArm) {
+               if (!CheckGPU.isGPUSupported() || isArm) {
                        onOffButton.setEnabled(false);
                        buttonLabel.setText(StringResources.DISABLED);
                        buttonLabel.setToolTipText(GPUDisableToolTipText);
@@ -134,8 +133,7 @@ public class GPUSupportSubViewItem extends OnOffSubViewItem {
        public ItemState checkValue() {
                itemState.setNormal();
 
-               if (CheckVirtualization.getInstance().isGallium()
-                               && EmulatorManager.isLinux() && getValue() == true) {
+               if (CheckGPU.isGallium() && getValue() == true) {
                        itemState.setWarning(GALLIUM_WARNING_MSG);
                }
 
index 4665a32..b098295 100644 (file)
@@ -39,7 +39,6 @@ import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.platform.BaseImage;
 import org.tizen.emulator.manager.platform.Skin;
 import org.tizen.emulator.manager.resources.StringResources;
-import org.tizen.emulator.manager.tool.CheckVirtualization;
 import org.tizen.emulator.manager.vms.xml.DisplayType.Resolution;
 import org.tizen.emulator.manager.vms.xml.ExtendedOptionType;
 import org.tizen.emulator.manager.vms.xml.OptionType;
@@ -375,8 +374,7 @@ public class VMPropertyValue implements Cloneable {
                }
 
                isHWVirtualization = property.getConfiguration().getUsability().isHwVirtualization();
-               isGLAcceleration = property.getConfiguration().getUsability().isHwGLAcceleration()
-                                                               && CheckVirtualization.getInstance().isSupportGPU();
+               isGLAcceleration = property.getConfiguration().getUsability().isHwGLAcceleration();
 
                TouchType touchType = property.getConfiguration().getDevice().getTouch();
                if (touchType != null) {
index 95fef30..c32b86e 100644 (file)
@@ -29,9 +29,8 @@
 package org.tizen.emulator.manager.vms.option;
 
 import org.eclipse.swt.SWT;
-import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.job.CheckGPU;
 import org.tizen.emulator.manager.job.CheckVT;
-import org.tizen.emulator.manager.tool.CheckVirtualization;
 import org.tizen.emulator.manager.ui.dialog.MessageDialog;
 import org.tizen.emulator.manager.vms.VMProperty;
 import org.tizen.emulator.manager.vms.helper.VMLauncherException;
@@ -53,11 +52,7 @@ public class HWSupportOption extends Option {
                }
 
                // Set GPU option
-               if (property.getConfiguration().getUsability().isHwGLAcceleration()
-                               && CheckVirtualization.getInstance().isSupportGPU()) {
-                       // config.addQemuOption("-vigs-backend", "gl");
-                       // config.addQemuOption("-enable-yagl");
-                       // config.addQemuOption("-yagl-backend", "vigs");
+               if (property.getConfiguration().getUsability().isHwGLAcceleration()) {
                        config.addQemuOption("-device", "vigs,backend=gl");
                        config.addQemuOption("-device", "yagl");
 
@@ -69,8 +64,7 @@ public class HWSupportOption extends Option {
        @Override
        public void checkArgument(VMProperty property) throws VMLauncherException {
                // Check graphic driver (only in linux)
-               if (EmulatorManager.isLinux()
-                               && CheckVirtualization.getInstance().isGallium()
+               if (CheckGPU.isGallium()
                                && property.getPropertyValue().isGLAcceleration) {
                        // show [ok/cancel] message.
                        MessageDialog dialog = new MessageDialog();