-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAHandler.cpp
More file actions
46 lines (44 loc) · 1.26 KB
/
AHandler.cpp
File metadata and controls
46 lines (44 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "AHandler.h"
#include "AMessage.h"
namespace android {
status_t AHandler::postEmptyMessage(uint32_t what, int64_t delayUs)
{
return std::make_shared<AMessage>(what, shared_from_this())->post(delayUs);
}
void AHandler::removeAllMessage()
{
auto looper = getLooper().lock();
if (looper == nullptr) {
return;
}
looper->remove(shared_from_this());
}
void AHandler::removeMessage(int what)
{
auto looper = getLooper().lock();
if (looper == nullptr) {
return;
}
looper->remove(shared_from_this(),what);
}
std::shared_ptr<AMessage> AHandler::obtainMessage()
{
return std::make_shared<AMessage>(shared_from_this());
}
void AHandler::deliverMessage(const std::shared_ptr<AMessage>& msg) {
onMessageReceived(msg);
mMessageCounter++;
if (mVerboseStats) {
uint32_t what = msg->what();
auto it = mMessages.find(what);
if (it == mMessages.end())
{
mMessages.emplace(what, 1);
}
else
{
it->second += 1;
}
}
}
} // namespace android