1 /** 2 * Copyright 2022, 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 #ifndef CPP_EVS_MANAGER_AIDL_STATS_INCLUDE_LOOPERWRAPPER_H 18 #define CPP_EVS_MANAGER_AIDL_STATS_INCLUDE_LOOPERWRAPPER_H 19 20 #include <utils/Looper.h> 21 #include <utils/RefBase.h> 22 #include <utils/Timers.h> 23 24 namespace aidl::android::automotive::evs::implementation { 25 26 // This class wraps around android::Looper methods. Please refer to 27 // utils/Looper.h for the details. 28 class LooperWrapper : public ::android::RefBase { 29 public: LooperWrapper()30 LooperWrapper() : mLooper(nullptr) {} ~LooperWrapper()31 virtual ~LooperWrapper() {} 32 setLooper(::android::sp<::android::Looper> looper)33 void setLooper(::android::sp<::android::Looper> looper) { mLooper = looper; } 34 void wake(); now()35 virtual nsecs_t now() { return systemTime(SYSTEM_TIME_MONOTONIC); } 36 virtual int pollAll(int timeoutMillis); 37 virtual void sendMessage(const ::android::sp<::android::MessageHandler>& handler, 38 const ::android::Message& message); 39 virtual void sendMessageAtTime(nsecs_t uptime, 40 const ::android::sp<::android::MessageHandler>& handler, 41 const ::android::Message& message); 42 virtual void removeMessages(const ::android::sp<::android::MessageHandler>& handler); 43 44 protected: 45 ::android::sp<::android::Looper> mLooper; 46 }; 47 48 } // namespace aidl::android::automotive::evs::implementation 49 50 #endif // CPP_EVS_MANAGER_AIDL_STATS_INCLUDE_LOOPERWRAPPER_H 51