void start_uevent_polling() { struct sockaddr_nl nls; struct pollfd pfd; char uevent_msg[1024]; // Open hotplug event netlink socket //ALOGI("Starting dongled For UsbModeSwitch Management - Settings:modeswitch.d:%s length:%u debug:%u",hotplug_info.modeswitch_d,hotplug_info.modeswitch_length,hotplug_info.debug); memset(&nls,0,sizeof(struct sockaddr_nl)); nls.nl_family = AF_NETLINK; nls.nl_pid = getpid(); nls.nl_groups = -1; pfd.events = POLLIN; pfd.fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); if (pfd.fd==-1) ALOGE("dongled cannot create socket, are you root?\n"); // Listen to netlink socket if (bind(pfd.fd, (void *)&nls, sizeof(struct sockaddr_nl))) die("bind failed\n"); ALOGD("Give us a go on your UEVENT"); while (-1!=poll(&pfd, 1, -1)) { int uevent_buffer_length = recv(pfd.fd, uevent_msg, sizeof(uevent_msg), MSG_DONTWAIT); if (uevent_buffer_length == -1) die("receive error\n"); struct uevent uevent; parse_uevent(uevent_msg, &uevent); handle_uevent(&uevent); } die("poll error\n"); return; }
static void event_loop(void) { int len = 0; static char udata[4096]; memset(udata, 0, sizeof(udata)); uevent_init(); while (1) { len = uevent_next_event(udata, sizeof(udata) - 2); handle_uevent(udata); } }
static void *uevent_loop(void *param) { int len = 0; static char udata[PAGE_SIZE]; hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param); setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); uevent_init(); while(1) { len = uevent_next_event(udata, sizeof(udata) - 2); handle_uevent(ctx, udata, len); } return NULL; }
static void *uevent_loop(void *param) { int len = 0; static char udata[PAGE_SIZE]; hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param); char thread_name[64] = HWC_UEVENT_THREAD_NAME; prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0); setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); uevent_init(); while(1) { len = uevent_next_event(udata, sizeof(udata) - 2); handle_uevent(ctx, udata, len); } return NULL; }
static void *uevent_loop(void *param) { int len = 0; static char udata[PAGE_SIZE]; hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param); char thread_name[64] = HWC_UEVENT_THREAD_NAME; prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0); androidSetThreadPriority(0, HAL_PRIORITY_URGENT_DISPLAY); if(!uevent_init()) { ALOGE("%s: failed to init uevent ",__FUNCTION__); return NULL; } while(1) { len = uevent_next_event(udata, (int)sizeof(udata) - 2); handle_uevent(ctx, udata, len); } return NULL; }
void event_loop(event_t *event) { cold_boot(event); handle_uevent(event); }