Skip to content

Commit 0b6d77b

Browse files
committed
better error handling in SensorManager
Change-Id: Id0498e950f1407a10e3b2d88e63c2141ac95d103
1 parent ff0e8cd commit 0b6d77b

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)