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

Commit 4a1e00fb authored by Aravind Akella's avatar Aravind Akella Committed by Android Git Automerger
Browse files

am 1f1e5768: am 5d6aa951: Merge "Change API from flush(handle) to flush()....

am 1f1e5768: am 5d6aa951: Merge "Change API from flush(handle) to flush(). Call flush on all active sensors in the given SensorEventConnection." into klp-dev

* commit '1f1e5768':
  Change API from flush(handle) to flush(). Call flush on all active sensors in the given SensorEventConnection.
parents 19cd5bc7 1f1e5768
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ public:
    virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs,
    virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs,
                                   nsecs_t maxBatchReportLatencyNs, int reservedFlags) = 0;
                                   nsecs_t maxBatchReportLatencyNs, int reservedFlags) = 0;
    virtual status_t setEventRate(int handle, nsecs_t ns) = 0;
    virtual status_t setEventRate(int handle, nsecs_t ns) = 0;
    virtual status_t flushSensor(int handle) = 0;
    virtual status_t flush() = 0;
};
};


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
+1 −1
Original line number Original line Diff line number Diff line
@@ -74,7 +74,7 @@ public:
    status_t enableSensor(int32_t handle, int32_t samplingPeriodUs, int maxBatchReportLatencyUs,
    status_t enableSensor(int32_t handle, int32_t samplingPeriodUs, int maxBatchReportLatencyUs,
                          int reservedFlags) const;
                          int reservedFlags) const;
    status_t disableSensor(int32_t handle) const;
    status_t disableSensor(int32_t handle) const;
    status_t flushSensor(int32_t handle) const;
    status_t flush() const;


private:
private:
    sp<Looper> getLooper() const;
    sp<Looper> getLooper() const;
+2 −4
Original line number Original line Diff line number Diff line
@@ -77,10 +77,9 @@ public:
        return reply.readInt32();
        return reply.readInt32();
    }
    }


    virtual status_t flushSensor(int handle) {
    virtual status_t flush() {
        Parcel data, reply;
        Parcel data, reply;
        data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
        data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
        data.writeInt32(handle);
        remote()->transact(FLUSH_SENSOR, data, &reply);
        remote()->transact(FLUSH_SENSOR, data, &reply);
        return reply.readInt32();
        return reply.readInt32();
    }
    }
@@ -122,8 +121,7 @@ status_t BnSensorEventConnection::onTransact(
        } break;
        } break;
        case FLUSH_SENSOR: {
        case FLUSH_SENSOR: {
            CHECK_INTERFACE(ISensorEventConnection, data, reply);
            CHECK_INTERFACE(ISensorEventConnection, data, reply);
            int handle = data.readInt32();
            status_t result = flush();
            status_t result = flushSensor(handle);
            reply->writeInt32(result);
            reply->writeInt32(result);
            return NO_ERROR;
            return NO_ERROR;
        } break;
        } break;
+2 −2
Original line number Original line Diff line number Diff line
@@ -132,8 +132,8 @@ status_t SensorEventQueue::enableSensor(int32_t handle, int32_t samplingPeriodUs
                                                 us2ns(maxBatchReportLatencyUs), reservedFlags);
                                                 us2ns(maxBatchReportLatencyUs), reservedFlags);
}
}


status_t SensorEventQueue::flushSensor(int32_t handle) const {
status_t SensorEventQueue::flush() const {
    return mSensorEventConnection->flushSensor(handle);
    return mSensorEventConnection->flush();
}
}


status_t SensorEventQueue::disableSensor(int32_t handle) const {
status_t SensorEventQueue::disableSensor(int32_t handle) const {
+18 −4
Original line number Original line Diff line number Diff line
@@ -682,6 +682,10 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection,
  if (sensor == NULL) {
  if (sensor == NULL) {
      return BAD_VALUE;
      return BAD_VALUE;
  }
  }
  if (sensor->getSensor().getType() == SENSOR_TYPE_SIGNIFICANT_MOTION) {
      ALOGE("flush called on Significant Motion sensor");
      return INVALID_OPERATION;
  }
  SensorDevice& dev(SensorDevice::getInstance());
  SensorDevice& dev(SensorDevice::getInstance());


  if (dev.getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_1) {
  if (dev.getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_1) {
@@ -934,8 +938,18 @@ status_t SensorService::SensorEventConnection::setEventRate(
    return mService->setEventRate(this, handle, samplingPeriodNs);
    return mService->setEventRate(this, handle, samplingPeriodNs);
}
}


status_t  SensorService::SensorEventConnection::flushSensor(int handle) {
status_t  SensorService::SensorEventConnection::flush() {
    return mService->flushSensor(this, handle);
    Mutex::Autolock _l(mConnectionLock);
    status_t err(NO_ERROR);
    for (size_t i = 0; i < mSensorInfo.size(); ++i) {
        const int handle = mSensorInfo.keyAt(i);
        status_t err_flush = mService->flushSensor(this, handle);
        if (err_flush != NO_ERROR) {
            ALOGE("Flush error handle=%d %s", handle, strerror(-err_flush));
        }
        err = (err_flush != NO_ERROR) ? err_flush : err;
    }
    return err;
}
}


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
Loading