Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11bed4a7 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android Git Automerger
Browse files

am 08710dcd: Merge "part of fix for [3004226] Cannot end the call - Proximity...

am 08710dcd: Merge "part of fix for [3004226] Cannot end the call - Proximity sensor doesn\'t work" into gingerbread

Merge commit '08710dcd589432c5828cefce25e4b565b15de9a6' into gingerbread-plus-aosp

* commit '08710dcd589432c5828cefce25e4b565b15de9a6':
  part of fix for [3004226] Cannot end the call - Proximity sensor doesn't work
parents a51d696a 9e110d53
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -70,9 +70,13 @@ ssize_t SensorEventQueue::write(ASensorEvent const* events, size_t numEvents)
ssize_t SensorEventQueue::read(ASensorEvent* events, size_t numEvents)
{
    ssize_t size = mSensorChannel->read(events, numEvents*sizeof(events[0]));
    LOGE_IF(size<0 && size!=-EAGAIN,
            "SensorChannel::read error (%s)", strerror(-size));
    if (size >= 0) {
        if (size % sizeof(events[0])) {
            // partial read!!! should never happen.
            LOGE("SensorEventQueue partial read (event-size=%u, read=%d)",
                    sizeof(events[0]), int(size));
            return -EINVAL;
        }
        // returns number of events read
@@ -95,8 +99,18 @@ status_t SensorEventQueue::waitForEvent() const
{
    const int fd = getFd();
    sp<Looper> looper(getLooper());
    int32_t result = looper->pollOnce(-1);
    return (result == fd) ? status_t(NO_ERROR) : status_t(-1);

    int32_t result;
    do {
        result = looper->pollOnce(-1);
        if (result == ALOOPER_EVENT_ERROR) {
            LOGE("SensorChannel::waitForEvent error (errno=%d)", errno);
            result = -EPIPE; // unknown error, so we make up one
            break;
        }
    } while (result != fd);

    return result;
}

status_t SensorEventQueue::wake() const