1 /**
2 * Copyright (c) 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 #include "LooperWrapper.h"
18
19 #include <utils/Looper.h>
20
21 namespace android {
22 namespace automotive {
23 namespace watchdog {
24
25 using android::sp;
26
wake()27 void LooperWrapper::wake() {
28 if (mLooper == nullptr) {
29 ALOGW("No looper in LooperWrapper");
30 return;
31 }
32 return mLooper->wake();
33 }
34
pollAll(int timeoutMillis)35 int LooperWrapper::pollAll(int timeoutMillis) {
36 if (mLooper == nullptr) {
37 ALOGW("No looper in LooperWrapper");
38 return 0;
39 }
40 return mLooper->pollAll(timeoutMillis);
41 }
42
sendMessage(const sp<MessageHandler> & handler,const Message & message)43 void LooperWrapper::sendMessage(const sp<MessageHandler>& handler, const Message& message) {
44 if (mLooper == nullptr) {
45 ALOGW("No looper in LooperWrapper");
46 return;
47 }
48 return mLooper->sendMessage(handler, message);
49 }
50
sendMessageAtTime(nsecs_t uptime,const sp<MessageHandler> & handler,const Message & message)51 void LooperWrapper::sendMessageAtTime(nsecs_t uptime, const sp<MessageHandler>& handler,
52 const Message& message) {
53 if (mLooper == nullptr) {
54 ALOGW("No looper in LooperWrapper");
55 return;
56 }
57 return mLooper->sendMessageAtTime(uptime, handler, message);
58 }
59
removeMessages(const sp<MessageHandler> & handler)60 void LooperWrapper::removeMessages(const sp<MessageHandler>& handler) {
61 if (mLooper == nullptr) {
62 ALOGW("No looper in LooperWrapper");
63 return;
64 }
65 return mLooper->removeMessages(handler);
66 }
67
68 } // namespace watchdog
69 } // namespace automotive
70 } // namespace android
71