int
set_screen_state(int on)
{
    QEMU_FALLBACK(set_screen_state(on));

    LOGI("*** set_screen_state %d", on);

    initialize_fds();

    //LOGI("go_to_sleep eventTime=%lld now=%lld g_error=%s\n", eventTime,
      //      systemTime(), strerror(g_error));

    if (g_error) return g_error;

    char buf[32];
    int len;
    if(on)
        len = sprintf(buf, on_state);
    else
        len = sprintf(buf, off_state);
    len = write(g_fds[REQUEST_STATE], buf, len);
    if(len < 0) {
        LOGE("Failed setting last user activity: g_error=%d\n", g_error);
    }
    return 0;
}
int
acquire_wake_lock(int lock, const char* id)
{
    initialize_fds();

//    ALOGI("acquire_wake_lock lock=%d id='%s'\n", lock, id);

    if (g_error) return g_error;

    int fd;
    size_t len;
    ssize_t ret;

    if (lock != PARTIAL_WAKE_LOCK) {
        return -EINVAL;
    }

    fd = g_fds[ACQUIRE_PARTIAL_WAKE_LOCK];

    ret = write(fd, id, strlen(id));
    if (ret < 0) {
        return -errno;
    }

    return ret;
}
예제 #3
0
int
release_wake_lock(const char* id)
{
    initialize_fds();

//    LOGI("release_wake_lock id='%s'\n", id);

    if (g_error) return g_error;

    ssize_t len = write(g_fds[RELEASE_WAKE_LOCK], id, strlen(id));
    return len >= 0;
}
예제 #4
0
int
set_screen_state(int on)
{
    QEMU_FALLBACK(set_screen_state(on));

    LOGI("*** set_screen_state %d", on);

    initialize_fds();

    //LOGI("go_to_sleep eventTime=%lld now=%lld g_error=%s\n", eventTime,
      //      systemTime(), strerror(g_error));

    if (g_error) {
        LOGE("Failed setting last user activity: g_error=%d\n", g_error);
        return 0;
    }

    char buf[32];
    int len;
    if (on == 1) {
        len = sprintf(buf, "%s", on_state);
        len = write(g_fds[REQUEST_STATE], buf, len);
        if (len < 0)
            LOGE("Failed setting last user activity: g_error=%d\n", g_error);
    } else if(on == 0){
        /*Check it is safe to enter suspend*/
        if (is_safe_suspend()) {
            len = sprintf(buf, "%s", off_state);
            len = write(g_fds[REQUEST_STATE], buf, len);
            if (len < 0)
                LOGE("Failed setting last user activity: g_error=%d\n", g_error);
        } else{
           pthread_t threadId;
           pthread_create(&threadId, NULL, set_state_off_sync, NULL);
        }
    }else if(on == 2){
        /*Check it is safe to enter suspend*/
        if (is_safe_suspend()) {
            len = sprintf(buf, "%s", eink_state);
            len = write(g_fds[REQUEST_STATE], buf, len);
            if (len < 0)
                LOGE("Failed setting last user activity: g_error=%d\n", g_error);
        } else{
           pthread_t threadId;
           pthread_create(&threadId, NULL, set_state_eink_sync, NULL);
        }
    }

    return 0;
}
int
set_screen_state(int on)
{
    QEMU_FALLBACK(set_screen_state(on));

    LOGI("*** set_screen_state %d", on);

    initialize_fds();

    //LOGI("go_to_sleep eventTime=%lld now=%lld g_error=%s\n", eventTime,
      //      systemTime(), strerror(g_error));

    if (g_error) return g_error;

    char buf[32];
    int len;
    FILE *fp;
    if(on) {
        system("echo 4 > /sys/devices/system/cpu/cpu0/op");
        system("echo 0 > /sys/class/backlight/pxa3xx_pwm_bl/bl_power");
        system("echo everlife > /sys/power/wake_unlock");
        len = sprintf(buf, on_state);
    }
    else {
        fp = fopen("/tmp/wakeup", "r");
        
        if (fp != 0) {
            fclose(fp);
            system("echo everlife > /sys/power/wake_lock");
            system("rm /tmp/wakeup");
        }
 
        //system("echo everlife > /sys/power/wake_lock");
        //system("echo 1 > /sys/class/backlight/pxa3xx_pwm_bl/bl_power");
        //system("echo 1 > /sys/devices/system/cpu/cpu0/op");
        len = sprintf(buf, off_state);
    }
    len = write(g_fds[REQUEST_STATE], buf, len);
    if(len < 0) {
        LOGE("Failed setting last user activity: g_error=%d\n", g_error);
    }
    return 0;
}
예제 #6
0
int
acquire_wake_lock(int lock, const char* id)
{
    initialize_fds();

//    LOGI("acquire_wake_lock lock=%d id='%s'\n", lock, id);

    if (g_error) return g_error;

    int fd;

    if (lock == PARTIAL_WAKE_LOCK) {
        fd = g_fds[ACQUIRE_PARTIAL_WAKE_LOCK];
    }
    else {
        return EINVAL;
    }

    return write(fd, id, strlen(id));
}