Skip to content

Commit faf5b16

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge "better error handling in SensorManager" into jb-dev
2 parents 9cc5e76 + 0b6d77b commit faf5b16

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/jni/android_hardware_SensorManager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,13 @@ sensors_data_poll(JNIEnv *env, jclass clazz, jint nativeQueue,
130130
res = queue->waitForEvent();
131131
if (res != NO_ERROR)
132132
return -1;
133+
// here we're guaranteed to have an event
133134
res = queue->read(&event, 1);
135+
ALOGE_IF(res==0, "sensors_data_poll: nothing to read after waitForEvent()");
134136
}
135-
if (res < 0)
137+
if (res <= 0) {
136138
return -1;
139+
}
137140

138141
jint accuracy = event.vector.status;
139142
env->SetFloatArrayRegion(values, 0, 3, event.vector.v);

0 commit comments

Comments
 (0)