/* 3 */ "Failed to load a bios file the following path.\
Check if the file is corrupted or missing.\n\n",
/* 4 */ "Skin process cannot be initialized. Skin server is not ready.",
- /* 5 */ "Skin client cannot connected to Skin server. The time of internal heartbeat has expired.",
+ /* 5 */ "Skin client could not connect to Skin server. The time of internal heartbeat has expired.",
/* add here.. */
""
};
*
*/
public class EmulatorShutdownhook extends Thread {
+ private Logger logger =
+ SkinLogger.getSkinLogger(EmulatorShutdownhook.class).getLogger();
- private Logger logger = SkinLogger.getSkinLogger( EmulatorShutdownhook.class ).getLogger();
private ICommunicator communicator;
-
- public EmulatorShutdownhook( ICommunicator communicator ) {
+
+ public EmulatorShutdownhook(ICommunicator communicator) {
this.communicator = communicator;
}
@Override
public void run() {
- logger.info( " EmulatorShutdownhook run by a signal." );
+ logger.info("EmulatorShutdownhook run by a signal.");
communicator.terminate();
}
} else { // linux & windows
skin = new EmulatorSdlSkin(currentState, finger, config, skinInfo, isOnTop);
}
+
/* create a qemu communicator */
int uid = config.getArgInt(ArgsConstants.UID);
communicator = new SocketCommunicator(config, uid, skin);
skin.setCommunicator(communicator);
finger.setEmulatorSkin(skin);
+
/* initialize a skin layout */
long windowHandleId = skin.initLayout();
communicator.setInitialData(windowHandleId);
Runtime.getRuntime().addShutdownHook(
new EmulatorShutdownhook(communicator));
- Thread communicatorThread = new Thread(communicator);
+ Thread communicatorThread =
+ new Thread(communicator, "communicator");
communicatorThread.start();
-
+
// SkinReopenPolicy reopenPolicy = skin.open();
//
// while( true ) {
System.out.println("Shutdown skin process !!!");
}
- if(null != communicator) {
+ if (null != communicator) {
communicator.terminate();
}
}
- 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 argLogLevel = argsMap.get(ArgsConstants.LOG_LEVEL);
String configPropertyLogLevel = null;
- if( null != properties ) {
- configPropertyLogLevel = (String) properties.get( ConfigPropertiesConstants.LOG_LEVEL );
+ if (null != properties) {
+ configPropertyLogLevel =
+ (String) properties.get(ConfigPropertiesConstants.LOG_LEVEL);
}
- // default log level is debug.
+ /* default log level is debug. */
String logLevel = "";
-
- if( !StringUtil.isEmpty( argLogLevel ) ) {
+
+ if (!StringUtil.isEmpty(argLogLevel)) {
logLevel = argLogLevel;
- }else if( !StringUtil.isEmpty( configPropertyLogLevel ) ) {
+ } else if (!StringUtil.isEmpty(configPropertyLogLevel)) {
logLevel = configPropertyLogLevel;
- }else {
+ } else {
logLevel = EmulatorConfig.DEFAULT_LOG_LEVEL.value();
}
-
+
SkinLogLevel skinLogLevel = EmulatorConfig.DEFAULT_LOG_LEVEL;
-
+
SkinLogLevel[] values = SkinLogLevel.values();
-
- for ( SkinLogLevel level : values ) {
- if ( level.value().equalsIgnoreCase( logLevel ) ) {
+
+ for (SkinLogLevel level : values) {
+ if (level.value().equalsIgnoreCase(logLevel)) {
skinLogLevel = level;
break;
}
}
- SkinLogger.setLevel( skinLogLevel.level() );
+ SkinLogger.setLevel(skinLogLevel.level());
}
- private static String getSimpleMsg( String[] args ) {
+ private static String getSimpleMsg(String[] args) {
for ( int i = 0; i < args.length; i++ ) {
final String simple = "simple.msg";
char cmd[JAVA_MAX_COMMAND_LENGTH] = { 0, };
char argv[JAVA_MAX_COMMAND_LENGTH] = { 0, };
- INFO("run skin client\n");
+ INFO("run skin client\n");
int i;
for (i = 0; i < skin_argc; ++i) {
strncat(argv, skin_argv[i], strlen(skin_argv[i]));
strncat(argv, " ", 1);
- INFO( "[skin args %d] %s\n", i, skin_argv[i] );
+ INFO("[skin args %d] %s\n", i, skin_argv[i]);
}
int skin_server_port = get_skin_server_port();
#ifdef CONFIG_WIN32
// find java path in 64bit windows
JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH);
- memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH);
+ memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH);
if (is_wow64()) {
INFO("This process is running under WOW64.\n");
if (!get_java_path(&JAVA_EXEFILE_PATH)) {
strcpy(JAVA_EXEFILE_PATH, "java");
- }
+ }
} else {
strcpy(JAVA_EXEFILE_PATH, "java");
}
argv );
#endif
- INFO( "command for swt : %s\n", cmd );
+ INFO("command for swt : %s\n", cmd);
#ifdef CONFIG_WIN32
// for 64bit windows
INFO("the child thread state was signaled!\n");
break;
case WAIT_TIMEOUT:
- INFO("time-out interval elapsed, and the child thread's state is nonsignaled.\n");
+ INFO("time-out interval elapsed,\
+ and the child thread's state is nonsignaled.\n");
break;
case WAIT_FAILED:
ERR("WaitForSingleObject() failed, error %u\n", GetLastError());
int count = 0;
int skin_server_ready = 0;
- while( 1 ) {
+ while(1) {
- if( 100 * SKIN_SERVER_READY_TIME < count ) {
+ if (100 * SKIN_SERVER_READY_TIME < count) {
break;
}
- if ( is_ready_skin_server() ) {
+ if (is_ready_skin_server()) {
skin_server_ready = 1;
break;
} else {
count++;
- INFO( "sleep for ready. count:%d\n", count );
+ INFO("sleep for ready. count:%d\n", count);
#ifdef CONFIG_WIN32
- Sleep( SKIN_SERVER_SLEEP_TIME );
+ Sleep(SKIN_SERVER_SLEEP_TIME);
#else
- usleep( 1000 * SKIN_SERVER_SLEEP_TIME );
+ usleep(1000 * SKIN_SERVER_SLEEP_TIME);
#endif
}
}
- if ( !skin_server_ready ) {
- ERR( "skin_server is not ready.\n" );
+ if (!skin_server_ready) {
+ ERR("skin_server is not ready.\n");
return -1;
}
return 1;
}
-
-int start_simple_client(char* msg) {
+int start_simple_client(char* msg)
+{
int ret = 0;
char cmd[JAVA_MAX_COMMAND_LENGTH] = { 0, };
#ifdef CONFIG_WIN32
// find java path in 64bit windows
JAVA_EXEFILE_PATH = malloc(JAVA_MAX_COMMAND_LENGTH);
- memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH);
+ memset(JAVA_EXEFILE_PATH, 0, JAVA_MAX_COMMAND_LENGTH);
if (is_wow64()) {
INFO("This process is running under WOW64.\n");
if (!get_java_path(&JAVA_EXEFILE_PATH)) {
strcpy(JAVA_EXEFILE_PATH, "java");
- }
+ }
} else {
strcpy(JAVA_EXEFILE_PATH, "java");
}
if (!fnIsWow64Process(GetCurrentProcess(),&result))
{
//handle error
- INFO("Can not find 'IsWow64Process'\n");
+ INFO("Can not find 'IsWow64Process'\n");
}
}
return result;
int get_java_path(char** java_path)
{
- HKEY hKeyNew;
- HKEY hKey;
- //char strJavaRuntimePath[JAVA_MAX_COMMAND_LENGTH] = {0};
- char strChoosenName[JAVA_MAX_COMMAND_LENGTH] = {0};
- char strSubKeyName[JAVA_MAX_COMMAND_LENGTH] = {0};
- char strJavaHome[JAVA_MAX_COMMAND_LENGTH] = {0};
- int index;
- DWORD dwSubKeyNameMax = JAVA_MAX_COMMAND_LENGTH;
- DWORD dwBufLen = JAVA_MAX_COMMAND_LENGTH;
+ HKEY hKeyNew;
+ HKEY hKey;
+ //char strJavaRuntimePath[JAVA_MAX_COMMAND_LENGTH] = {0};
+ char strChoosenName[JAVA_MAX_COMMAND_LENGTH] = {0};
+ char strSubKeyName[JAVA_MAX_COMMAND_LENGTH] = {0};
+ char strJavaHome[JAVA_MAX_COMMAND_LENGTH] = {0};
+ int index;
+ DWORD dwSubKeyNameMax = JAVA_MAX_COMMAND_LENGTH;
+ DWORD dwBufLen = JAVA_MAX_COMMAND_LENGTH;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Runtime Environment", 0,
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | MY_KEY_WOW64_64KEY, &hKey);
RegEnumKeyEx(hKey, 0, (LPSTR)strSubKeyName, &dwSubKeyNameMax, NULL, NULL, NULL, NULL);
strcpy(strChoosenName, strSubKeyName);
- index = 1;
- while (ERROR_SUCCESS == RegEnumKeyEx(hKey, index, (LPSTR)strSubKeyName, &dwSubKeyNameMax,
- NULL, NULL, NULL, NULL)) {
+ index = 1;
+ while (ERROR_SUCCESS == RegEnumKeyEx(hKey, index, (LPSTR)strSubKeyName, &dwSubKeyNameMax,
+ NULL, NULL, NULL, NULL)) {
if (strcmp(strChoosenName, strSubKeyName) < 0) {
strcpy(strChoosenName, strSubKeyName);
}
index++;
- }
+ }
- RegOpenKeyEx(hKey, strChoosenName, 0, KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hKeyNew);
- RegQueryValueEx(hKeyNew, "JavaHome", NULL, NULL, (LPBYTE)strJavaHome, &dwBufLen);
- RegCloseKey(hKey);
- if (strJavaHome[0] != '\0') {
+ RegOpenKeyEx(hKey, strChoosenName, 0, KEY_QUERY_VALUE | MY_KEY_WOW64_64KEY, &hKeyNew);
+ RegQueryValueEx(hKeyNew, "JavaHome", NULL, NULL, (LPBYTE)strJavaHome, &dwBufLen);
+ RegCloseKey(hKey);
+ if (strJavaHome[0] != '\0') {
sprintf(*java_path, "\"%s\\bin\\java\"", strJavaHome);
//strcpy(*java_path, strJavaHome);
//strcat(*java_path, "\\bin\\java");
} else {
- return 0;
- }
+ return 0;
+ }
return 1;
}
#endif
static int qmu_argc = 0;
static char** qmu_argv = NULL;
-static void parse_skin_args( void );
-static void parse_skinconfig_prop( void );
-static void* run_skin_server( void* args );
-static int recv_n( int client_sock, char* read_buf, int recv_len );
-static void make_header( int client_sock, short send_cmd, int data_length, char* sendbuf, int print_log );
-static int send_skin_header_only( int client_sock, short send_cmd, int print_log );
-static int send_skin_data( int client_sock, short send_cmd, unsigned char* data, int length, int big_data );
-static int send_n( int client_sock, unsigned char* data, int length, int big_data );
+static void parse_skin_args(void);
+static void parse_skinconfig_prop(void);
+static void* run_skin_server(void* args);
-static void* do_heart_beat( void* args );
-static int start_heart_beat( void );
-static void stop_heart_beat( void );
+static int recv_n(int client_sock, char* read_buf, int recv_len);
+static int send_n(int client_sock, unsigned char* data, int length, int big_data);
-int start_skin_server( int argc, char** argv, int qemu_argc, char** qemu_argv ) {
+static void make_header(int client_sock,
+ short send_cmd, int data_length, char* sendbuf, int print_log);
+static int send_skin_header_only(int client_sock,
+ short send_cmd, int print_log);
+static int send_skin_data(int client_sock,
+ short send_cmd, unsigned char* data, int length, int big_data);
+
+static void* do_heart_beat(void* args);
+static int start_heart_beat(void);
+static void stop_heart_beat(void);
+
+int start_skin_server(int argc, char** argv,
+ int qemu_argc, char** qemu_argv)
+{
skin_argc = argc;
skin_argv = argv;
// arguments have higher priority than '.skinconfig.properties'
parse_skin_args();
- INFO( "ignore_heartbeat:%d\n", ignore_heartbeat );
+ INFO("ignore_heartbeat:%d\n", ignore_heartbeat);
qmu_argc = qemu_argc;
qmu_argv = qemu_argv;
}
-void shutdown_skin_server( void ) {
-
- INFO( "shutdown_skin_server\n" );
+void shutdown_skin_server(void)
+{
+ INFO("shutdown_skin_server\n");
int close_server_socket = 0;
int success_send = 0;
- if ( client_sock ) {
- INFO( "send shutdown to skin.\n" );
- if ( 0 > send_skin_header_only( client_sock, SEND_SHUTDOWN, 1 ) ) {
- ERR( "fail to send SEND_SHUTDOWN to skin.\n" );
+ if (client_sock) {
+ INFO("send shutdown to skin.\n");
+ if (0 > send_skin_header_only(client_sock, SEND_SHUTDOWN, 1)) {
+ ERR("fail to send SEND_SHUTDOWN to skin.\n");
close_server_socket = 1;
} else {
success_send = 1;
- // skin sent RECV_RESPONSE_SHUTDOWN.
+ /* skin sent RECV_RESPONSE_SHUTDOWN */
}
}
- if ( success_send ) {
+ if (success_send) {
int count = 0;
int max_sleep_count = 10;
- while ( 1 ) {
+ while (1) {
- if ( max_sleep_count < count ) {
+ if (max_sleep_count < count) {
close_server_socket = 1;
break;
}
- if ( stop_server ) {
- INFO( "skin client sent normal shutdown response.\n" );
+ if (stop_server) {
+ INFO("skin client sent normal shutdown response.\n");
break;
} else {
#ifdef CONFIG_WIN32
- Sleep( 1 ); // 1ms
+ Sleep(1); // 1ms
#else
- usleep( 1000 ); // 1ms
+ usleep(1000); // 1ms
#endif
count++;
}
stop_server = 1;
is_force_close_client = 1;
- if ( client_sock ) {
+ if (client_sock) {
#ifdef CONFIG_WIN32
- closesocket( client_sock );
+ closesocket(client_sock);
#else
- close( client_sock );
+ close(client_sock);
#endif
client_sock = 0;
}
- if ( close_server_socket ) {
- INFO( "skin client did not send normal shutdown response.\n" );
- if ( server_sock ) {
+ if (close_server_socket) {
+ INFO("skin client did not send normal shutdown response.\n");
+ if (server_sock) {
#ifdef CONFIG_WIN32
- closesocket( server_sock );
+ closesocket(server_sock);
#else
- close( server_sock );
+ close(server_sock);
#endif
server_sock = 0;
}