Skip to content

Commit 37d95f6

Browse files
committed
handle EINTR when calling sensor HAL's poll function
some sensor HALs don't handle EINTR, make sure to catch it in the sensorservice. also if we ever encounter an error that we can't handle, we abort which will restart us (or the whole system process if we're running in it) Bug: 5511741 Change-Id: I7051882b06980f778736b53d6cd021a99b5ca8d2
1 parent 270826a commit 37d95f6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

services/sensorservice/SensorDevice.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ status_t SensorDevice::initCheck() const {
166166

167167
ssize_t SensorDevice::poll(sensors_event_t* buffer, size_t count) {
168168
if (!mSensorDevice) return NO_INIT;
169-
return mSensorDevice->poll(mSensorDevice, buffer, count);
169+
ssize_t c;
170+
do {
171+
c = mSensorDevice->poll(mSensorDevice, buffer, count);
172+
} while (c == -EINTR);
173+
return c;
170174
}
171175

172176
status_t SensorDevice::activate(void* ident, int handle, int enabled)

services/sensorservice/SensorService.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ bool SensorService::threadLoop()
286286
}
287287
} while (count >= 0 || Thread::exitPending());
288288

289-
LOGW("Exiting SensorService::threadLoop!");
289+
LOGW("Exiting SensorService::threadLoop => aborting...");
290+
abort();
290291
return false;
291292
}
292293

0 commit comments

Comments
 (0)