diff --git a/sensors/HalProxy.cpp b/sensors/HalProxy.cpp index 1a73265..58509eb 100644 --- a/sensors/HalProxy.cpp +++ b/sensors/HalProxy.cpp @@ -193,7 +193,13 @@ Return HalProxy::initialize_2_1( std::unique_ptr queue = std::make_unique(eventQueue); - return initializeCommon(queue, wakeLockDescriptor, dynamicCallback); + // Create the Wake Lock FMQ from the wakeLockDescriptor. Reset the read/write positions. + auto hidlWakeLockQueue = + std::make_unique(wakeLockDescriptor, true /* resetPointers */); + std::unique_ptr wakeLockQueue = + std::make_unique(hidlWakeLockQueue); + + return initializeCommon(queue, wakeLockQueue, dynamicCallback); } Return HalProxy::initialize( @@ -209,12 +215,18 @@ Return HalProxy::initialize( std::unique_ptr queue = std::make_unique(eventQueue); - return initializeCommon(queue, wakeLockDescriptor, dynamicCallback); + // Create the Wake Lock FMQ from the wakeLockDescriptor. Reset the read/write positions. + auto hidlWakeLockQueue = + std::make_unique(wakeLockDescriptor, true /* resetPointers */); + std::unique_ptr wakeLockQueue = + std::make_unique(hidlWakeLockQueue); + + return initializeCommon(queue, wakeLockQueue, dynamicCallback); } Return HalProxy::initializeCommon( std::unique_ptr& eventQueue, - const ::android::hardware::MQDescriptorSync& wakeLockDescriptor, + std::unique_ptr& wakeLockQueue, const sp& sensorsCallback) { Result result = Result::OK; @@ -239,8 +251,7 @@ Return HalProxy::initializeCommon( // Create the Wake Lock FMQ that is used by the framework to communicate whenever WAKE_UP // events have been successfully read and handled by the framework. - mWakeLockQueue = - std::make_unique(wakeLockDescriptor, true /* resetPointers */); + mWakeLockQueue = std::move(wakeLockQueue); if (mEventQueueFlag != nullptr) { EventFlag::deleteEventFlag(&mEventQueueFlag);