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