static void android_util_EventLog_readEvents(JNIEnv* env, jobject clazz,
if (tags == NULL || out == NULL) {
jniThrowException(env, "java/lang/NullPointerException", NULL); int fd = open("/dev/" LOGGER_LOG_EVENTS, O_RDONLY | O_NONBLOCK);
jniThrowIOException(env, errno); jsize tagLength = env->GetArrayLength(tags);
jint *tagValues = env->GetIntArrayElements(tags, NULL);
uint8_t buf[LOGGER_ENTRY_MAX_LEN];
struct timeval timeout = {0, 0};
// Use a short select() to try to avoid problems hanging on read().
// This means we block for 5ms at the end of the log -- oh well.
int r = select(fd + 1, &readset, NULL, NULL, &timeout);
} else if (r < 0 && errno == EINTR) {
continue; // interrupted by signal, try again
jniThrowIOException(env, errno); // Will throw on return int len = read(fd, buf, sizeof(buf));
if (len == 0 || (len < 0 && errno == EAGAIN)) {
} else if (len < 0 && errno == EINTR) {
continue; // interrupted by signal, try again
jniThrowIOException(env, errno); // Will throw on return } else if ((size_t) len < sizeof(logger_entry) + sizeof(int32_t)) {
jniThrowException(env, "java/io/IOException", "Event too short"); env->ReleaseIntArrayElements(tags, tagValues, 0);