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

Commit 6c2664ae authored by Aravind Akella's avatar Aravind Akella
Browse files

SensorService fixes.

   1) Flush should only be received by the app calling flush(). Maintain
      a queue of all flush() calls and send flush_complete events in that
      order.
   2) Log warnings for older HALs. Remove batch() calls with DRY_RUN flag.
   3) Reallocate event cache when more sensors register and the desired
      maxCacheSize increases. Clear NEEDS_ACK flag in the buffer whenever
      there is a write() failure.
   4) More dump information. Add wake-up flag, maxDelay and timestamps for
      sensor events.

Bug: 16874778
Change-Id: I195646191059fd31f75f2f07886c0f98bf9b509a
parent b1f0f288
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
#include <gui/BitTube.h>

// ----------------------------------------------------------------------------
#define WAKE_UP_SENSOR_EVENT_NEEDS_ACK (1 << 31)
#define WAKE_UP_SENSOR_EVENT_NEEDS_ACK (1U << 31)
struct ALooper;
struct ASensorEvent;

+8 −18
Original line number Diff line number Diff line
@@ -54,6 +54,11 @@ SensorDevice::SensorDevice()
                SENSORS_HARDWARE_MODULE_ID, strerror(-err));

        if (mSensorDevice) {
            if (mSensorDevice->common.version == SENSORS_DEVICE_API_VERSION_1_1 ||
                mSensorDevice->common.version == SENSORS_DEVICE_API_VERSION_1_2) {
                ALOGE(">>>> WARNING <<< Upgrade sensor HAL to version 1_3");
            }

            sensor_t const* list;
            ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list);
            mActivationCount.setCapacity(count);
@@ -74,6 +79,7 @@ void SensorDevice::dump(String8& result)
    sensor_t const* list;
    ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list);

    result.appendFormat("halVersion %d\n", getHalDeviceVersion());
    result.appendFormat("%d h/w sensors:\n", int(count));

    Mutex::Autolock _l(mLock);
@@ -210,24 +216,8 @@ status_t SensorDevice::batch(void* ident, int handle, int flags, int64_t samplin
    }

    const int halVersion = getHalDeviceVersion();
    if (halVersion >= SENSORS_DEVICE_API_VERSION_1_1) {
        if (flags & SENSORS_BATCH_DRY_RUN) {
            return mSensorDevice->batch(mSensorDevice, handle, flags, samplingPeriodNs,
                                        maxBatchReportLatencyNs);
        } else {
            // Call h/w with dry run to see if the given parameters are feasible or not. Return if
            // there is an error.
            status_t errDryRun(NO_ERROR);
            errDryRun = mSensorDevice->batch(mSensorDevice, handle, flags | SENSORS_BATCH_DRY_RUN,
                                             samplingPeriodNs, maxBatchReportLatencyNs);
            if (errDryRun != NO_ERROR) {
                ALOGD_IF(DEBUG_CONNECTIONS, "SensorDevice::batch dry run error %s",
                         strerror(-errDryRun));
                return errDryRun;
            }
        }
    } else if (maxBatchReportLatencyNs != 0) {
        // Batch is not supported on older devices.
    if (halVersion < SENSORS_DEVICE_API_VERSION_1_1 && maxBatchReportLatencyNs != 0) {
        // Batch is not supported on older devices return invalid operation.
        return INVALID_OPERATION;
    }

+188 −89

File changed.

Preview size limit exceeded, changes collapsed.

+25 −11

File changed.

Preview size limit exceeded, changes collapsed.