From: jihye kim Date: Mon, 10 Dec 2012 11:31:59 +0000 (+0900) Subject: [Title] emulator-manager : add checking launching emulator status. X-Git-Tag: 2.2.1_release^2~45^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0ea23d7625457e1474d0072b1d26b2ea91b542c;p=sdk%2Femulator%2Femulator-manager.git [Title] emulator-manager : add checking launching emulator status. [Desc.] add checking launching emulator status. [Issue] N_SE-16404 --- diff --git a/package/changelog b/package/changelog index 96ef2cb..0805d13 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,7 @@ +* 1.3.67 +- add double checking launching emulator. +== jihye kim 2012-12-10 + * 1.3.66 - modify default skin phone shape skin -> general skina == jihye kim 2012-12-10 diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index c3cd0f8..ac239b5 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,5 +1,5 @@ Source: emulator-manager -Version: 1.3.66 +Version: 1.3.67 Maintainer: Yeong-Kyoon Lee Package: emulator-manager diff --git a/src/org/tizen/emulator/manager/vms/CheckingRunningEmulator.java b/src/org/tizen/emulator/manager/vms/CheckingRunningEmulator.java new file mode 100644 index 0000000..d22442b --- /dev/null +++ b/src/org/tizen/emulator/manager/vms/CheckingRunningEmulator.java @@ -0,0 +1,51 @@ +/* + * Emulator Manager + * + * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * MunKyu Im + * SeokYeon Hwang + * JiHye Kim + * YeongKyoon Lee + * + * 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.vms; + +import java.util.ArrayList; + +public class CheckingRunningEmulator { + private static ArrayList emList = new ArrayList (); + + public static synchronized void addEmulator(String name) { + if (!emList.contains(name)) { + emList.add(name); + } + } + + public static synchronized void removeEmulator(String name) { + emList.remove(name); + } + + public static synchronized boolean isContains(String name) { + return emList.contains(name); + } +} diff --git a/src/org/tizen/emulator/manager/vms/Launcher.java b/src/org/tizen/emulator/manager/vms/Launcher.java index 9eba07b..1e22f1e 100644 --- a/src/org/tizen/emulator/manager/vms/Launcher.java +++ b/src/org/tizen/emulator/manager/vms/Launcher.java @@ -372,7 +372,16 @@ public class Launcher { return false; } - return launch(cmd); + CheckingRunningEmulator.addEmulator(property.getName()); + MonitoringEmulator monitor = new MonitoringEmulator(property); + if (launch(cmd)) { + monitor.start(); + return true; + } else { + CheckingRunningEmulator.removeEmulator(property.getName()); + monitor.interrupt(); + return false; + } } public boolean launch(List cmd) { @@ -425,3 +434,29 @@ public class Launcher { return true; } } + +class MonitoringEmulator extends Thread { + private VMsProperty property; + public MonitoringEmulator(VMsProperty property) { + this.property = property; + this.setDaemon(true); + } + + public void run() { + while (true) { + if (VMsWorker.checking(property)) { + CheckingRunningEmulator.removeEmulator(property.getName()); + break; + } + + synchronized(this) { + try { + this.wait(500); + } catch (InterruptedException e) { + EMLogger.getLogger().warning(e.getMessage()); + break; + } + } + } + } +} \ No newline at end of file diff --git a/src/org/tizen/emulator/manager/vms/VMsWorker.java b/src/org/tizen/emulator/manager/vms/VMsWorker.java index 23937cc..6a3cd3f 100644 --- a/src/org/tizen/emulator/manager/vms/VMsWorker.java +++ b/src/org/tizen/emulator/manager/vms/VMsWorker.java @@ -254,6 +254,15 @@ public class VMsWorker { return true; } } + + if (CheckingRunningEmulator.isContains(property.getName())) { + return true; + } + + return checking(property); + } + + public static boolean checking(VMsProperty prop) { Logger logger = EMLogger.getLogger(); boolean result = false; @@ -291,7 +300,7 @@ public class VMsWorker { stdOut = new BufferedReader(inputReader); if(isLinux > -1) { while ((line = stdOut.readLine()) != null) { - String imagePath = property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue(); + String imagePath = prop.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue(); if(line.contains(imagePath)) { //logger.log(Level.INFO, line + " contains " + imagePath); logger.log(Level.INFO, "emulator instance with the same name is running now (" + imagePath + ")"); @@ -303,7 +312,7 @@ public class VMsWorker { while ((line = stdOut.readLine()) != null) { String[] titleName = line.split(","); // "split[split.length - 1]" is window title. - if(titleName[titleName.length - 1].startsWith("\"" + property.getName()+ ":261")) { + if(titleName[titleName.length - 1].startsWith("\"" + prop.getName()+ ":261")) { //logger.log(Level.INFO, "contains " + titleName[titleName.length - 1]); logger.log(Level.INFO, "emulator instance with the same name is running now (" + titleName[titleName.length - 1] + ")"); result = true; @@ -312,7 +321,7 @@ public class VMsWorker { } else if(isMac > -1) { while ((line = stdOut.readLine()) != null) { - String imagePath = property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue(); + String imagePath = prop.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue(); if(line.contains(imagePath)) { //logger.log(Level.INFO, line + " contains " + imagePath); logger.log(Level.INFO, "emulator instance with the same name is running now (" + imagePath + ")");