From: SeokYeon Hwang Date: Thu, 22 Oct 2015 07:23:56 +0000 (+0900) Subject: osutil: get_java_path() move to osutil-win32.c X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~205 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a9d752ec588d4b4e07f8cbc35390244b91d0ad8f;p=sdk%2Femulator%2Fqemu.git osutil: get_java_path() move to osutil-win32.c qemu_oom_check() uses new QT5 dialog for reporting errors. Finally, get_java_path() is called by tizen specific logics only. Then it can move to tizen specific utility now. Change-Id: I9f2d0dd26715059734bc8242320de01c539a331c Signed-off-by: SeokYeon Hwang --- diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index a9f57dc9c9..3de576825c 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -65,6 +65,10 @@ extern bool hax_allowed; DECLARE_DEBUG_CHANNEL(emul_state); +#define MAXLEN 512 +#define HTTP_PROXY_PREFIX "http_proxy=" +#define HOST_IP_PREFIX "host_ip=" + static EmulatorConfigInfo _emul_info = {0,}; static EmulatorConfigState _emul_state; diff --git a/tizen/src/emulator_common.h b/tizen/src/emulator_common.h index bb297d32f0..1e0ea8d913 100644 --- a/tizen/src/emulator_common.h +++ b/tizen/src/emulator_common.h @@ -47,12 +47,19 @@ #include #include #include +#include #include "config-host.h" #ifdef CONFIG_DARWIN #include "sys/syslimits.h" #endif +#ifdef CONFIG_WIN32 +#if defined(__MINGW64_VERSION_MAJOR) +#define __MINGW_W64__ +#endif +#endif + #if !defined(PATH_MAX) #if defined(MAX_PATH) #define PATH_MAX MAX_PATH @@ -62,33 +69,17 @@ #endif #define JAVA_MAX_COMMAND_LENGTH 1024 -#define MAXLEN 512 -#define HTTP_PROXY_PREFIX "http_proxy=" -#define HOST_IP_PREFIX "host_ip=" - +#ifdef CONFIG_JAVA_UI #define JAR_SKINFILE "emulator-skin.jar" #define JAVA_LIBRARY_PATH "-Djava.library.path" - +#define JAVA_SIMPLEMODE_OPTION "simple.msg" +#define JAVA_EXEFILE_PATH "java" #ifndef CONFIG_DARWIN #define JAVA_EXEOPTION "-jar" #else #define JAVA_EXEOPTION "-XstartOnFirstThread -jar" // Must start the Java window on the first thread on Mac #endif -#define JAVA_SIMPLEMODE_OPTION "simple.msg" - -#ifdef CONFIG_WIN32 -#define MY_KEY_WOW64_64KEY 0x0100 -#ifdef __cplusplus -extern "C" { -#endif -int is_wow64(void); -bool get_java_path(char **java_path); -#ifdef __cplusplus -} -#endif -#else -#define JAVA_EXEFILE_PATH "java" #endif #endif /* __EMULATOR_COMMON_H__ */ diff --git a/tizen/src/hw/pci/maru_camera_win32.h b/tizen/src/hw/pci/maru_camera_win32.h index a8009f21cc..2a86f9a31c 100644 --- a/tizen/src/hw/pci/maru_camera_win32.h +++ b/tizen/src/hw/pci/maru_camera_win32.h @@ -100,7 +100,9 @@ DECLARE_INTERFACE_(IGrabCallback, IUnknown) #define IGrabCallback_Grab(T,a,b) (T)->lpVtbl->Grab(T,a,b) #endif /* COBJMACROS */ -#if defined(__MINGW64_VERSION_MAJOR) +#include "emulator_common.h" + +#ifdef __MINGW_W64__ #include #include #include diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index db2f603234..d24eac11f0 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -41,6 +41,7 @@ extern "C" { // FIXME: To avoid very complex header inclusion chains void qemu_system_graceful_shutdown_request(unsigned int sec); +#include "util/osutil.h" #include "util/device_hotplug.h" #include "util/ui_operations.h" } diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c index 1677eabbda..c56bae9cee 100644 --- a/tizen/src/util/osutil-win32.c +++ b/tizen/src/util/osutil-win32.c @@ -281,3 +281,108 @@ int remove_sdcard_lock_os(char *sdcard) return ERR_UNLCK; } } + +typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); +int is_wow64(void) +{ + int result = 0; + LPFN_ISWOW64PROCESS fnIsWow64Process; + + /* IsWow64Process is not available on all supported versions of Windows. + Use GetModuleHandle to get a handle to the DLL that contains the function + and GetProcAddress to get a pointer to the function if available. */ + + fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( + GetModuleHandle(TEXT("kernel32")), "IsWow64Process"); + + if (NULL != fnIsWow64Process) { + if (!fnIsWow64Process(GetCurrentProcess(), &result)) { + /* No need to handle error, + just check whether is this WoW64 process */ + } + } + return result; +} + +#define MY_KEY_WOW64_64KEY 0x0100 +static char wow64_java_path[PATH_MAX]; +bool get_java_path(char **java_path) +{ + int index; + LONG res; + HKEY hKey, hSubKey; + char strChoosenName[PATH_MAX] = {0}; + char strSubKeyName[PATH_MAX] = {0}; + char strJavaHome[PATH_MAX] = {0}; + DWORD dwSubKeyNameMax = PATH_MAX; + DWORD dwBufLen = PATH_MAX; + char strKeyList[4][64] = { + /* 64bit runtime */ + "SOFTWARE\\JavaSoft\\Java Runtime Environment", + "SOFTWARE\\JavaSoft\\Java Development Kit", + /* 32bit runtime */ + "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment", + "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit" + }; + + if (wow64_java_path[0] != '\0') { + strcpy(*java_path, wow64_java_path); + return true; + } + + for (index = 0; index < ARRAY_SIZE(strKeyList); index++) { + res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + strKeyList[index], + 0, + KEY_QUERY_VALUE | + KEY_ENUMERATE_SUB_KEYS | + MY_KEY_WOW64_64KEY, + &hKey); + if (res == ERROR_SUCCESS) { + break; + } + } + + if (res == ERROR_SUCCESS) { + index = 0; + do { + dwSubKeyNameMax = PATH_MAX; + res = RegEnumKeyEx(hKey, + index++, + (LPSTR)strSubKeyName, + &dwSubKeyNameMax, + NULL, NULL, NULL, NULL); + if (strcmp(strChoosenName, strSubKeyName) < 0) { + strcpy(strChoosenName, strSubKeyName); + } + } while (res == ERROR_SUCCESS); + + RegOpenKeyEx(hKey, strChoosenName, 0, + KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hSubKey); + RegQueryValueEx(hSubKey, "JavaHome", NULL, + NULL, (LPBYTE)strJavaHome, &dwBufLen); + RegCloseKey(hSubKey); + RegCloseKey(hKey); + } else { + /* TODO: + get from %winDir%\System32 + but, is this really needed? + */ + DWORD dwRet = 0; + char strJavaHomeVar[PATH_MAX] = {0,}; + dwRet = GetEnvironmentVariable("JAVA_HOME", + strJavaHomeVar, + PATH_MAX); + if (dwRet != 0 && dwRet < PATH_MAX) { + strcpy(strJavaHome, strJavaHomeVar); + } + } + if (strJavaHome[0] != '\0') { + sprintf(*java_path, "\"%s\\bin\\javaw.exe\"", strJavaHome); + strcpy(wow64_java_path, *java_path); + } else { + return false; + } + + return true; +} diff --git a/tizen/src/util/osutil.h b/tizen/src/util/osutil.h index bcfe1c6f28..cc9e95cf6d 100644 --- a/tizen/src/util/osutil.h +++ b/tizen/src/util/osutil.h @@ -32,7 +32,15 @@ #ifndef __OSUTIL_H__ #define __OSUTIL_H__ -#include "qemu-common.h" +#include +#include + +#include "emulator_common.h" +#ifdef CONFIG_WIN32 +#include "sysemu/os-win32.h" +#else +#include "sysemu/os-posix.h" +#endif #define DEFAULTBUFLEN 512 #define ERR_SUCCESS 0 @@ -60,6 +68,9 @@ typedef struct sdcard_info #ifndef CONFIG_WIN32 bool make_sdcard_lock_posix(char *sdcard); int remove_sdcard_lock_posix(char *sdcard); +#else +int is_wow64(void); +bool get_java_path(char **java_path); #endif void print_system_info_os(void); diff --git a/util/oslib-win32.c b/util/oslib-win32.c index de9fd7e288..23d934a6c0 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -41,115 +41,6 @@ /* this must come after including "trace.h" */ #include -#ifdef CONFIG_MARU -#include "tizen/src/emulator_common.h" - -typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); - -int is_wow64(void) -{ - int result = 0; - LPFN_ISWOW64PROCESS fnIsWow64Process; - - /* IsWow64Process is not available on all supported versions of Windows. - Use GetModuleHandle to get a handle to the DLL that contains the function - and GetProcAddress to get a pointer to the function if available. */ - - fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( - GetModuleHandle(TEXT("kernel32")), "IsWow64Process"); - - if (NULL != fnIsWow64Process) { - if (!fnIsWow64Process(GetCurrentProcess(), &result)) { - /* No need to handle error, - just check whether is this WoW64 process */ - } - } - return result; -} - -static char wow64_java_path[JAVA_MAX_COMMAND_LENGTH]; -bool get_java_path(char **java_path) -{ - int index; - LONG res; - HKEY hKey, hSubKey; - char strChoosenName[JAVA_MAX_COMMAND_LENGTH] = {0}; - char strSubKeyName[JAVA_MAX_COMMAND_LENGTH] = {0}; - char strJavaHome[JAVA_MAX_COMMAND_LENGTH] = {0}; - DWORD dwSubKeyNameMax = JAVA_MAX_COMMAND_LENGTH; - DWORD dwBufLen = JAVA_MAX_COMMAND_LENGTH; - char strKeyList[4][64] = { - /* 64bit runtime */ - "SOFTWARE\\JavaSoft\\Java Runtime Environment", - "SOFTWARE\\JavaSoft\\Java Development Kit", - /* 32bit runtime */ - "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment", - "SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit" - }; - - if (wow64_java_path[0] != '\0') { - strcpy(*java_path, wow64_java_path); - return true; - } - - for (index = 0; index < ARRAY_SIZE(strKeyList); index++) { - res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - strKeyList[index], - 0, - KEY_QUERY_VALUE | - KEY_ENUMERATE_SUB_KEYS | - MY_KEY_WOW64_64KEY, - &hKey); - if (res == ERROR_SUCCESS) { - break; - } - } - - if (res == ERROR_SUCCESS) { - index = 0; - do { - dwSubKeyNameMax = JAVA_MAX_COMMAND_LENGTH; - res = RegEnumKeyEx(hKey, - index++, - (LPSTR)strSubKeyName, - &dwSubKeyNameMax, - NULL, NULL, NULL, NULL); - if (strcmp(strChoosenName, strSubKeyName) < 0) { - strcpy(strChoosenName, strSubKeyName); - } - } while (res == ERROR_SUCCESS); - - RegOpenKeyEx(hKey, strChoosenName, 0, - KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hSubKey); - RegQueryValueEx(hSubKey, "JavaHome", NULL, - NULL, (LPBYTE)strJavaHome, &dwBufLen); - RegCloseKey(hSubKey); - RegCloseKey(hKey); - } else { - /* TODO: - get from %winDir%\System32 - but, is this really needed? - */ - DWORD dwRet = 0; - char strJavaHomeVar[JAVA_MAX_COMMAND_LENGTH] = {0,}; - dwRet = GetEnvironmentVariable("JAVA_HOME", - strJavaHomeVar, - JAVA_MAX_COMMAND_LENGTH); - if (dwRet != 0 && dwRet < JAVA_MAX_COMMAND_LENGTH) { - strcpy(strJavaHome, strJavaHomeVar); - } - } - if (strJavaHome[0] != '\0') { - sprintf(*java_path, "\"%s\\bin\\javaw.exe\"", strJavaHome); - strcpy(wow64_java_path, *java_path); - } else { - return false; - } - - return true; -} -#endif - void *qemu_oom_check(void *ptr) { if (ptr == NULL) {