private static Logger logger;
- private static int useSharedMemory = 0;
-
- static {
- if (SwtUtil.isMacPlatform() == true) {
- useSharedMemory = 1;
- }
- }
-
/**
* @param args
*/
public static void main(String[] args) {
-
- if(SwtUtil.isMacPlatform()) {
+ if (SwtUtil.isMacPlatform()) {
//TODO: event handling of about dialog
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Emulator");
SocketCommunicator communicator = null;
try {
-
/* get vm path from startup argument */
String vmPath = getVmPath(args);
if (StringUtil.isEmpty(vmPath)) {
/* get skin path from startup argument */
String argSkinPath = (String) argsMap.get(ArgsConstants.SKIN_PATH);
- String skinPath = ".." +
- File.separator + SKINS_FOLDER + File.separator + DEFAULT_SKIN_FOLDER;
+ String skinPath = ".." + File.separator +
+ SKINS_FOLDER + File.separator + DEFAULT_SKIN_FOLDER;
File f = new File(argSkinPath);
if (f.isDirectory() == false) {
}
/* set skin information */
- String skinInfoFilePath = skinPath + File.separator + SKIN_INFO_FILE_NAME;
+ String skinInfoFilePath =
+ skinPath + File.separator + SKIN_INFO_FILE_NAME;
Properties skinInfoProperties = loadProperties(skinInfoFilePath, false);
if (null == skinInfoProperties) {
logger.severe("Fail to load skin information file.");
temp.dispose();
System.exit(-1);
- } else {
- logger.info("skin info:" + skinInfoProperties); //TODO:
}
- /* determine the layout */
String skinInfoResolutionW =
skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_WIDTH);
String skinInfoResolutionH =
skinInfoProperties.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT);
- boolean isGeneralSkin = false;
- if (skinInfoResolutionW.equalsIgnoreCase("all") ||
- skinInfoResolutionH.equalsIgnoreCase("all")) {
- isGeneralSkin = true;
- }
- SkinInformation skinInfo = new SkinInformation(
- skinInfoProperties.getProperty(SkinInfoConstants.SKIN_NAME),
- skinPath, isGeneralSkin);
+ logger.info("skin ini : " + SkinInfoConstants.SKIN_NAME + "=" +
+ skinInfoProperties.getProperty(SkinInfoConstants.SKIN_NAME));
+ logger.info("skin ini : " + SkinInfoConstants.RESOLUTION_WIDTH +
+ "=" + skinInfoResolutionW);
+ logger.info("skin ini : " + SkinInfoConstants.RESOLUTION_HEIGHT +
+ "=" + skinInfoResolutionH);
+ logger.info("skin ini : " + SkinInfoConstants.MANAGER_PRIORITY + "=" +
+ skinInfoProperties.getProperty(SkinInfoConstants.MANAGER_PRIORITY));
/* set emulator window skin property */
- String skinPropFilePath = vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME;
+ String skinPropFilePath =
+ vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME;
Properties skinProperties = loadProperties(skinPropFilePath, true);
if (null == skinProperties) {
logger.severe("Fail to load skin properties file.");
}
/* set emulator window config property */
- String configPropFilePath = vmPath + File.separator + CONFIG_PROPERTIES_FILE_NAME;
+ String configPropFilePath =
+ vmPath + File.separator + CONFIG_PROPERTIES_FILE_NAME;
Properties configProperties = loadProperties(configPropFilePath, false);
/* able to use log file after loading properties */
EmulatorConfig.validateSkinProperties(skinProperties);
EmulatorConfig.validateSkinConfigProperties(configProperties);
+ /* determine the layout */
+ boolean isGeneralSkin = false;
+ if (skinInfoResolutionW.equalsIgnoreCase("all") ||
+ skinInfoResolutionH.equalsIgnoreCase("all")) {
+ isGeneralSkin = true;
+ }
+ SkinInformation skinInfo = new SkinInformation(
+ skinInfoProperties.getProperty(SkinInfoConstants.SKIN_NAME),
+ skinPath, isGeneralSkin);
+
/* load dbi file */
EmulatorUI dbiContents = loadXMLForSkin(skinPath);
if (null == dbiContents) {
/* create a skin */
EmulatorSkin skin = null;
- if (useSharedMemory == 1) {
+ if (config.getArgBoolean(ArgsConstants.DISPLAY_SHM) == true) {
+ logger.info("maru_shm"); /* shared framebuffer */
+
skin = new EmulatorShmSkin(config, skinInfo, isOnTop);
} else { /* linux & windows */
+ logger.info("maru_sdl"); /* WINDOWID_hack */
+
skin = new EmulatorSdlSkin(config, skinInfo, isOnTop);
}
Socket commSocket = communicator.getSocket();
if (null != commSocket) {
-
Runtime.getRuntime().addShutdownHook(
new EmulatorShutdownhook(communicator));
}
} catch (Throwable e) {
-
if (null != logger) {
logger.log(Level.SEVERE, e.getMessage(), e);
logger.warning("Shutdown skin process !!!");
if (null != communicator) {
communicator.terminate();
}
-
} finally {
ImageRegistry.getInstance().dispose();
Display.getDefault().close();
SkinLogger.end();
}
-
}
- private static void initLog(Map<String, String> argsMap, Properties properties) {
-
+ private static void initLog(
+ Map<String, String> argsMap, Properties properties) {
String argLogLevel = argsMap.get(ArgsConstants.LOG_LEVEL);
String configPropertyLogLevel = null;
}
SkinLogger.setLevel(skinLogLevel.level());
-
}
private static String getSimpleMsg(String[] args) {
-
- for ( int i = 0; i < args.length; i++ ) {
- final String simple = "simple.msg";
+ for (int i = 0; i < args.length; i++) {
String arg = args[i];
- String[] split = arg.split( "=" );
- if ( 1 < split.length ) {
- if ( simple.equals( split[0].trim() ) ) {
+ String[] split = arg.split("=");
+
+ if (1 < split.length) {
+ if (ArgsConstants.SIMPLE_MESSAGE.equals(
+ split[0].trim())) {
return split[1].trim();
}
}
}
return null;
-
}
- private static String getVmPath( String[] args ) {
-
- for ( int i = 0; i < args.length; i++ ) {
+ private static String getVmPath(String[] args) {
+ for (int i = 0; i < args.length; i++) {
String arg = args[i];
- String[] split = arg.split( "=" );
- if ( 1 < split.length ) {
- if ( ArgsConstants.VM_PATH.equals( split[0].trim() ) ) {
+ String[] split = arg.split("=");
+
+ if (1 < split.length) {
+ if (ArgsConstants.VM_PATH.equals(
+ split[0].trim())) {
return split[1].trim();
}
}
}
return null;
-
}
private static Map<String, String> parseArgs(String[] args) {
return emulatorUI;
}
- private static Properties loadProperties( String filePath, boolean create ) {
-
+ private static Properties loadProperties(
+ String filePath, boolean create) {
FileInputStream fis = null;
Properties properties = null;
try {
-
- File file = new File( filePath );
+ File file = new File(filePath);
- if (create) {
- if ( !file.exists() ) {
- if ( !file.createNewFile() ) {
- logger.severe( "Fail to create new " + filePath + " property file." );
+ if (create == true) {
+ if (file.exists() == false) {
+ if (file.createNewFile() == false) {
+ logger.severe(
+ "Fail to create new " + filePath + " property file.");
return null;
}
}
-
- fis = new FileInputStream( filePath );
+
+ fis = new FileInputStream(filePath);
properties = new Properties();
- properties.load( fis );
-
+ properties.load(fis);
} else {
-
- if ( file.exists() ) {
-
- fis = new FileInputStream( filePath );
+ if (file.exists() == true) {
+ fis = new FileInputStream(filePath);
properties = new Properties();
- properties.load( fis );
+ properties.load(fis);
}
-
}
- logger.info( "load properties file : " + filePath );
-
- } catch ( IOException e ) {
- logger.log( Level.SEVERE, "Fail to load skin properties file.", e );
+ logger.info("load properties file : " + filePath);
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, "failed to load skin properties file", e);
} finally {
- IOUtil.close( fis );
+ IOUtil.close(fis);
}
return properties;
-
}
-
}
/*
* communicate with java skin process
*
- * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* GiWoong Kim <giwoong.kim@samsung.com>
MULTI_DEBUG_CHANNEL(qemu, skin_client);
-#define SKIN_SERVER_READY_TIME 3 // second
-#define SKIN_SERVER_SLEEP_TIME 10 // milli second
+
+#define SKIN_SERVER_READY_TIME 3 /* second */
+#define SKIN_SERVER_SLEEP_TIME 10 /* milli second */
#define OPT_SVR_PORT "svr.port"
#define OPT_UID "uid"
#define OPT_VM_PATH "vm.path"
#define OPT_NET_BASE_PORT "net.baseport"
+#define OPT_DISPLAY_SHM "display.shm"
#define OPT_MAX_TOUCHPOINT "max.touchpoint"
extern char tizen_target_path[];
sprintf(buf_uid, "%d", uid);
sprintf(buf_tizen_base_port, "%d", get_emul_vm_base_port());
+ char buf_display_shm[8] = { 0, };
+#ifdef CONFIG_USE_SHM
+ strcpy(buf_display_shm, "true");
+#else
+ strcpy(buf_display_shm, "false");
+#endif
+
#ifdef CONFIG_WIN32
- // find java path in 64bit windows
+ /* find java path in 64bit windows */
JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH);
memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH);
if (is_wow64()) {
int len = strlen(JAVA_EXEFILE_PATH) + strlen(JAVA_EXEOPTION) +
#ifdef CONFIG_WIN32
- strlen((char*)bin_dir_win) + strlen(bin_dir) + strlen(JAR_SKINFILE) +
+ strlen((char*)bin_dir_win) + strlen(bin_dir) + strlen(JAR_SKINFILE) +
#else
- strlen(bin_dir) + strlen(bin_dir) + strlen(JAR_SKINFILE) +
+ strlen(bin_dir) + strlen(bin_dir) + strlen(JAR_SKINFILE) +
#endif
- strlen(OPT_SVR_PORT) + strlen(buf_skin_server_port) + strlen(OPT_UID) + strlen(buf_uid) +
- strlen(OPT_VM_PATH) + strlen(vm_path) + strlen(OPT_NET_BASE_PORT) + strlen(buf_tizen_base_port) +
- strlen(OPT_MAX_TOUCHPOINT) + len_maxtouchpoint + strlen(argv) + 46;
+ strlen(OPT_SVR_PORT) + strlen(buf_skin_server_port) +
+ strlen(OPT_UID) + strlen(buf_uid) +
+ strlen(OPT_VM_PATH) + strlen(vm_path) +
+ strlen(OPT_NET_BASE_PORT) + strlen(buf_tizen_base_port) +
+ strlen(OPT_MAX_TOUCHPOINT) + len_maxtouchpoint +
+ strlen(OPT_DISPLAY_SHM) + strlen(buf_display_shm) +
+ strlen(argv) + 48;
+
if (len > JAVA_MAX_COMMAND_LENGTH) {
INFO("swt command length is too long! (%d)\n", len);
len = JAVA_MAX_COMMAND_LENGTH;
}
- snprintf(cmd, len, "%s %s %s=\"%s\" \"%s%s\" %s=\"%d\" %s=\"%d\" %s=\"%s\" %s=\"%d\" %s=%d %s",
+ snprintf(cmd, len, "%s %s %s=\"%s\" \"%s%s\" %s=\"%d\" %s=\"%d\" %s=\"%s\" %s=\"%d\" %s=%s %s=%d %s",
JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH,
#ifdef CONFIG_WIN32
bin_dir_win, bin_dir, JAR_SKINFILE,
OPT_UID, uid,
OPT_VM_PATH, vm_path,
OPT_NET_BASE_PORT, get_emul_vm_base_port(),
+ OPT_DISPLAY_SHM, buf_display_shm,
OPT_MAX_TOUCHPOINT, maxtouchpoint,
argv);
INFO("command for swt : %s\n", cmd);
#ifdef CONFIG_WIN32
- // for 64bit windows
+ /* for 64bit windows */
free(JAVA_EXEFILE_PATH);
JAVA_EXEFILE_PATH = NULL;
break;
}
- //retrieves the termination status of the specified process
+ /* retrieves the termination status of the specified process */
if (GetExitCodeProcess(pi.hProcess, &dwRet) != 0) {
ERR("failed to GetExitCodeProcess, error %u\n", GetLastError());
}
}
}
-#else //ifndef CONFIG_WIN32
+#else /* ifndef CONFIG_WIN32 */
int ret = system(cmd);
if (ret == 127) {
INFO("fork error!\n");
} else {
ret = WEXITSTATUS(ret);
- //The high-order 8 bits are the exit code from exit().
- //The low-order 8 bits are zero if the process exited normally.
+ /* The high-order 8 bits are the exit code from exit() */
+ /* The low-order 8 bits are zero if the process exited normally */
INFO("child return value : %d\n", ret);
if (ret != 0) {
int skin_server_ready = 0;
while(1) {
-
if (100 * SKIN_SERVER_READY_TIME < count) {
break;
}
pthread_t thread_id;
if (0 != pthread_create(&thread_id, NULL, run_skin_client, NULL)) {
- ERR( "fail to create skin_client pthread.\n" );
+ ERR("fail to create skin_client pthread\n");
return -1;
}
INFO("run simple client\n");
#ifdef CONFIG_WIN32
- // find java path in 64bit windows
+ /* find java path in 64bit windows */
JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH);
memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH);
if (is_wow64()) {
} else {
strcpy(JAVA_EXEFILE_PATH, "java");
}
+
char* bin_dir = get_bin_path();
int bin_dir_len = strlen(bin_dir);
char bin_dir_win[bin_dir_len];
int len = strlen(JAVA_EXEFILE_PATH) + strlen(JAVA_EXEOPTION) + strlen(JAVA_LIBRARY_PATH) +
#ifdef CONFIG_WIN32
- strlen((char*)bin_dir_win) + strlen(bin_dir) + strlen(JAR_SKINFILE) +
+ strlen((char*)bin_dir_win) + strlen(bin_dir) + strlen(JAR_SKINFILE) +
#else
- strlen(bin_dir) + strlen(bin_dir) + strlen(JAR_SKINFILE) +
+ strlen(bin_dir) + strlen(bin_dir) + strlen(JAR_SKINFILE) +
#endif
- strlen(bin_dir) + strlen(JAVA_SIMPLEMODE_OPTION) + strlen(msg) + 11;
+ strlen(bin_dir) + strlen(JAVA_SIMPLEMODE_OPTION) + strlen(msg) + 11;
+
if (len > JAVA_MAX_COMMAND_LENGTH) {
len = JAVA_MAX_COMMAND_LENGTH;
}
+
snprintf(cmd, len, "%s %s %s=\"%s\" %s%s %s=\"%s\"",
#ifdef CONFIG_WIN32
- JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, bin_dir_win,
+ JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, bin_dir_win,
#else
- JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, bin_dir,
+ JAVA_EXEFILE_PATH, JAVA_EXEOPTION, JAVA_LIBRARY_PATH, bin_dir,
#endif
- bin_dir, JAR_SKINFILE, JAVA_SIMPLEMODE_OPTION, msg);
+ bin_dir, JAR_SKINFILE, JAVA_SIMPLEMODE_OPTION, msg);
+
INFO("command for swt : %s\n", cmd);
#ifdef CONFIG_WIN32
- // for 64bit windows
+ /* for 64bit windows */
free(JAVA_EXEFILE_PATH);
JAVA_EXEFILE_PATH=0;