return gTid;
}
+
+/* 0 - continue reading, 1 - break */
+static int msg_handler(log_t *log)
+{
+ if (log->type == APP_MSG_CAPTURE_SCREEN) {
+ capture_screen_call();
+ } else if (log->type == APP_MSG_CONFIG) {
+ _configure((char *)log->data);
+ } else if (log->type == APP_MSG_TARGET_BINS) {
+ _process_target_bins((char *)log->data, log->length);
+ } else if (log->type == APP_MSG_STOP) {
+ /* Do leaks check if LSan is enabled. */
+ lsan_do_leak_check();
+
+ /* Send acknowlege message to manager */
+ printLog(log, APP_MSG_STOP);
+ application_exit();
+
+ return 1;
+ } else if (log->type == APP_MSG_STOP_WITHOUT_KILL) {
+ /* Do leaks check if LSan is enabled. */
+ lsan_do_leak_check();
+
+ /* Send acknowlege message to manager */
+ printLog(log, APP_MSG_STOP);
+ _uninit_();
+
+ return 1;
+ } else if (log->type == APP_MSG_GET_UI_HIERARCHY) {
+ PRINTMSG("APP_MSG_GET_UI_HIERARCHY");
+ /* do nothing */
+ } else if (log->type == APP_MSG_GET_UI_SCREENSHOT) {
+ PRINTMSG("APP_MSG_GET_UI_SCREENSHOT");
+ /* do nothing */
+ } else if (log->type == APP_MSG_GET_UI_HIERARCHY_CANCEL) {
+ PRINTMSG("APP_MSG_GET_UI_HIERARCHY_CANCEL");
+ /* do nothing */
+ } else {
+ PRINTERR("recv unknown message. id = (%d)", log->type);
+ }
+
+ return 0;
+}
+
static void *recv_thread(void __unused * data)
{
fd_set readfds, workfds;
continue;
} else if (FD_ISSET(gTraceInfo.socket.daemonSock, &workfds)) {
int ret;
- const char *data_buf;
- size_t data_size;
ret = read_log(gTraceInfo.socket.daemonSock, &log);
if (ret) {
return NULL;
}
- data_buf = log.data;
- data_size = log.length;
- if (log.type == APP_MSG_CAPTURE_SCREEN) {
- capture_screen_call();
- } else if (log.type == APP_MSG_CONFIG) {
- _configure((char *)data_buf);
- } else if (log.type == APP_MSG_TARGET_BINS) {
- _process_target_bins((char *)data_buf, data_size);
- } else if (log.type == APP_MSG_STOP) {
- /* Do leaks check if LSan is enabled. */
- lsan_do_leak_check();
-
- /* Send acknowlege message to manager */
- printLog(&log, APP_MSG_STOP);
-
- application_exit();
+ if (msg_handler(&log))
break;
- } else if (log.type == APP_MSG_STOP_WITHOUT_KILL) {
- /* Do leaks check if LSan is enabled. */
- lsan_do_leak_check();
-
- /* Send acknowlege message to manager */
- printLog(&log, APP_MSG_STOP);
- _uninit_();
- break;
- } else if(log.type == APP_MSG_GET_UI_HIERARCHY) {
- PRINTMSG("APP_MSG_GET_UI_HIERARCHY");
- /* do nothing */
- } else if(log.type == APP_MSG_GET_UI_SCREENSHOT) {
- PRINTMSG("APP_MSG_GET_UI_SCREENSHOT");
- /* do nothing */
- } else if(log.type == APP_MSG_GET_UI_HIERARCHY_CANCEL) {
- PRINTMSG("APP_MSG_GET_UI_HIERARCHY_CANCEL");
- /* do nothing */
- } else {
- PRINTERR("recv unknown message. id = (%d)",
- log.type);
- }
} else { /* unknown case */
continue;
}