[Desc.] add checking launching emulator status.
[Issue] N_SE-16404
+* 1.3.67
+- add double checking launching emulator.
+== jihye kim <jihye1128.kim@samsung.com> 2012-12-10
+
* 1.3.66
- modify default skin phone shape skin -> general skina
== jihye kim <jihye1128.kim@samsung.com> 2012-12-10
Source: emulator-manager
-Version: 1.3.66
+Version: 1.3.67
Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
Package: emulator-manager
--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * MunKyu Im <munkyu.im@samsung.com>
+ * 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.vms;
+
+import java.util.ArrayList;
+
+public class CheckingRunningEmulator {
+ private static ArrayList<String> emList = new ArrayList<String> ();
+
+ 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);
+ }
+}
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<String> cmd) {
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
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;
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 + ")");
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;
}
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 + ")");