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

Commit bc78e537 authored by Stan Rokita's avatar Stan Rokita Committed by Android (Google) Code Review
Browse files

Merge changes If9065255,I7d07003e

* changes:
  MultiHal 2.0 - activate, batch, flush methods of HalProxy
  MultiHal 2.0 - proxying api calls helper methods
parents d6b5b1e2 4b4c7b74
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -123,9 +123,9 @@ Return<Result> HalProxy::setOperationMode(OperationMode /* mode */) {
    return Result::INVALID_OPERATION;
}

Return<Result> HalProxy::activate(int32_t /* sensorHandle */, bool /* enabled */) {
    // TODO: Proxy API call to appropriate sub-HAL.
    return Result::INVALID_OPERATION;
Return<Result> HalProxy::activate(int32_t sensorHandle, bool enabled) {
    return getSubHalForSensorHandle(sensorHandle)
            ->activate(zeroOutFirstByte(sensorHandle), enabled);
}

Return<Result> HalProxy::initialize(
@@ -163,15 +163,14 @@ Return<Result> HalProxy::initialize(
    return result;
}

Return<Result> HalProxy::batch(int32_t /* sensorHandle */, int64_t /* samplingPeriodNs */,
                               int64_t /* maxReportLatencyNs */) {
    // TODO: Proxy API call to appropriate sub-HAL.
    return Result::INVALID_OPERATION;
Return<Result> HalProxy::batch(int32_t sensorHandle, int64_t samplingPeriodNs,
                               int64_t maxReportLatencyNs) {
    return getSubHalForSensorHandle(sensorHandle)
            ->batch(zeroOutFirstByte(sensorHandle), samplingPeriodNs, maxReportLatencyNs);
}

Return<Result> HalProxy::flush(int32_t /* sensorHandle */) {
    // TODO: Proxy API call to appropriate sub-HAL.
    return Result::INVALID_OPERATION;
Return<Result> HalProxy::flush(int32_t sensorHandle) {
    return getSubHalForSensorHandle(sensorHandle)->flush(zeroOutFirstByte(sensorHandle));
}

Return<Result> HalProxy::injectSensorData(const Event& /* event */) {
@@ -218,6 +217,14 @@ Return<void> HalProxy::onDynamicSensorsDisconnected(
    return Return<void>();
}

ISensorsSubHal* HalProxy::getSubHalForSensorHandle(uint32_t sensorHandle) {
    return mSubHalList[static_cast<size_t>(sensorHandle >> 24)];
}

uint32_t HalProxy::zeroOutFirstByte(uint32_t num) {
    return num & 0x00FFFFFF;
}

}  // namespace implementation
}  // namespace V2_0
}  // namespace sensors
+18 −0
Original line number Diff line number Diff line
@@ -118,6 +118,24 @@ struct HalProxy : public ISensors {
     * SubHal object pointers that have been saved from vendor dynamic libraries.
     */
    std::vector<ISensorsSubHal*> mSubHalList;

    /*
     * Get the subhal pointer which can be found by indexing into the mSubHalList vector
     * using the index from the first byte of sensorHandle.
     *
     * @param sensorHandle The handle used to identify a sensor in one of the subhals.
     */
    ISensorsSubHal* getSubHalForSensorHandle(uint32_t sensorHandle);

    /*
     * Zero out the first (most significant) byte in a number. Used in modifying the sensor handles
     * before passing them to subhals.
     *
     * @param num The uint32_t number to work with.
     *
     * @return The modified version of num param.
     */
    static uint32_t zeroOutFirstByte(uint32_t num);
};

}  // namespace implementation