Esempio n. 1
0
int main()
{
	ALOGI("usb 3g monitor v0.1 start");
	
	uevent_init();
	coldboot("/sys/devices");
	uevent_next_event(on_uevent);	
	return 0;
}
Esempio n. 2
0
int main()
{	
	SLOGI("-------------------------------------------------------------------");
	SLOGI("USB3G Monitor ver. 0.1f fixed by lolet -- built on %s, %s",__DATE__, __TIME__); 
	SLOGI("-------------------------------------------------------------------");
	uevent_init();
	coldboot("/sys/devices");
	uevent_next_event(on_uevent);	
	return 0;
}
static int
android_os_UEventObserver_next_event(JNIEnv *env, jclass clazz, jbyteArray jbuffer)
{
    int buf_sz = env->GetArrayLength(jbuffer);
    char *buffer = (char*)env->GetByteArrayElements(jbuffer, NULL);

    int length = uevent_next_event(buffer, buf_sz - 1);

    env->ReleaseByteArrayElements(jbuffer, (jbyte*)buffer, 0);

    return length;
}
bool ExtDisplayObserver::threadLoop()
{
    static char uEventString[1024];
    memset(uEventString, 0, sizeof(uEventString));
    int count = uevent_next_event(uEventString, sizeof(uEventString));
    if(count) {
        ALOGD_IF(EXT_OBSERVER_DEBUG, "%s: UeventString: %s len = %d",
                                          __FUNCTION__, uEventString, count);
        handleUEvent(uEventString);
    }
    return true;
}
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;
}
void UEventWatcher::run()
{
    if (uevent_init()) {
	char msg[UEVENT_MSG_LEN+2];
	int n;
	while ((n = uevent_next_event(msg, UEVENT_MSG_LEN)) > 0) {
	    if (n >= UEVENT_MSG_LEN)
		continue;
	    msg[n] = 0;
	    msg[n+1] = 0;
	    struct uevent uevent;
	    parse_event(msg, &uevent);
	    if (strcmp(uevent.subsystem,"power_supply") == 0) {
		emit activity();
	    }
	}
    }
}
String UEventObserver::NativeWaitForNextEvent()
{
    char buffer[1024];

    for (;;) {
        int length = uevent_next_event(buffer, sizeof(buffer) - 1);
        if (length <= 0) {
            return String(NULL);
        }
        buffer[length] = '\0';

        // Logger::V("Received uevent message: %s", buffer);

        if (IsMatch(buffer, length)) {
            // Assume the message is ASCII.
            return String(buffer);
        }
    }
}
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;
}
static jstring nativeWaitForNextEvent(JNIEnv *env, jclass clazz) {
    char buffer[1024];

    for (;;) {
        int length = uevent_next_event(buffer, sizeof(buffer) - 1);
        if (length <= 0) {
            return NULL;
        }
        buffer[length] = '\0';

        ALOGV("Received uevent message: %s", buffer);

        if (isMatch(buffer, length)) {
            // Assume the message is ASCII.
            jchar message[length];
            for (int i = 0; i < length; i++) {
                message[i] = buffer[i];
            }
            return env->NewString(message, length);
        }
    }
}