1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <android/hardware/sensors/2.1/types.h> 20 #include <fmq/AidlMessageQueue.h> 21 #include "WakeLockMessageQueueWrapper.h" 22 23 namespace aidl { 24 namespace android { 25 namespace hardware { 26 namespace sensors { 27 namespace implementation { 28 29 class WakeLockMessageQueueWrapperAidl 30 : public ::android::hardware::sensors::V2_1::implementation::WakeLockMessageQueueWrapperBase { 31 public: WakeLockMessageQueueWrapperAidl(std::unique_ptr<::android::AidlMessageQueue<int32_t,::aidl::android::hardware::common::fmq::SynchronizedReadWrite>> & queue)32 WakeLockMessageQueueWrapperAidl( 33 std::unique_ptr<::android::AidlMessageQueue< 34 int32_t, ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>>& queue) 35 : mQueue(std::move(queue)) {} 36 getEventFlagWord()37 virtual std::atomic<uint32_t>* getEventFlagWord() override { 38 return mQueue->getEventFlagWord(); 39 } 40 readBlocking(uint32_t * wakeLocks,size_t numToRead,uint32_t readNotification,uint32_t writeNotification,int64_t timeOutNanos,::android::hardware::EventFlag * evFlag)41 bool readBlocking(uint32_t* wakeLocks, size_t numToRead, uint32_t readNotification, 42 uint32_t writeNotification, int64_t timeOutNanos, 43 ::android::hardware::EventFlag* evFlag) override { 44 return mQueue->readBlocking(reinterpret_cast<int32_t*>(wakeLocks), numToRead, 45 readNotification, writeNotification, timeOutNanos, evFlag); 46 } 47 write(const uint32_t * wakeLock)48 bool write(const uint32_t* wakeLock) override { 49 return mQueue->write(reinterpret_cast<const int32_t*>(wakeLock)); 50 } 51 52 private: 53 std::unique_ptr<::android::AidlMessageQueue< 54 int32_t, ::aidl::android::hardware::common::fmq::SynchronizedReadWrite>> 55 mQueue; 56 }; 57 58 } // namespace implementation 59 } // namespace sensors 60 } // namespace hardware 61 } // namespace android 62 } // namespace aidl 63