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

Commit 28b05081 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Fix registerDirectChannel in HAL wrappers

Bug: 228645167
Test: CTS+VTS
Change-Id: I14348a7fe98a9681bc03109af8610c0aab679265
parent 7f3ca032
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -281,7 +281,7 @@ status_t HidlSensorHalWrapper::injectSensorData(const sensors_event_t* event) {
}
}


status_t HidlSensorHalWrapper::registerDirectChannel(const sensors_direct_mem_t* memory,
status_t HidlSensorHalWrapper::registerDirectChannel(const sensors_direct_mem_t* memory,
                                                     int32_t* /*channelHandle*/) {
                                                     int32_t* outChannelHandle) {
    if (mSensors == nullptr) return NO_INIT;
    if (mSensors == nullptr) return NO_INIT;


    SharedMemType type;
    SharedMemType type;
@@ -309,10 +309,12 @@ status_t HidlSensorHalWrapper::registerDirectChannel(const sensors_direct_mem_t*
            .memoryHandle = memory->handle,
            .memoryHandle = memory->handle,
    };
    };


    status_t ret;
    status_t ret = OK;
    checkReturn(mSensors->registerDirectChannel(mem, [&ret](auto result, auto channelHandle) {
    checkReturn(mSensors->registerDirectChannel(mem,
                                                [&ret, &outChannelHandle](auto result,
                                                                          auto channelHandle) {
                                                    if (result == Result::OK) {
                                                    if (result == Result::OK) {
            ret = channelHandle;
                                                        *outChannelHandle = channelHandle;
                                                    } else {
                                                    } else {
                                                        ret = statusFromResult(result);
                                                        ret = statusFromResult(result);
                                                    }
                                                    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -112,7 +112,7 @@ public:
    virtual status_t injectSensorData(const sensors_event_t* event) override;
    virtual status_t injectSensorData(const sensors_event_t* event) override;


    virtual status_t registerDirectChannel(const sensors_direct_mem_t* memory,
    virtual status_t registerDirectChannel(const sensors_direct_mem_t* memory,
                                           int32_t* channelHandle) override;
                                           int32_t* outChannelHandle) override;


    virtual status_t unregisterDirectChannel(int32_t channelHandle) override;
    virtual status_t unregisterDirectChannel(int32_t channelHandle) override;


+7 −1
Original line number Original line Diff line number Diff line
@@ -766,7 +766,13 @@ int32_t SensorDevice::registerDirectChannel(const sensors_direct_mem_t* memory)
    if (mHalWrapper == nullptr) return NO_INIT;
    if (mHalWrapper == nullptr) return NO_INIT;
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);


    return mHalWrapper->registerDirectChannel(memory, nullptr);
    int32_t channelHandle;
    status_t status = mHalWrapper->registerDirectChannel(memory, &channelHandle);
    if (status != OK) {
        channelHandle = -1;
    }

    return channelHandle;
}
}


void SensorDevice::unregisterDirectChannel(int32_t channelHandle) {
void SensorDevice::unregisterDirectChannel(int32_t channelHandle) {