-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHidlService.h
72 lines (59 loc) · 2.4 KB
/
HidlService.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef ANDROID_HARDWARE_MANAGER_HIDLSERVICE_H
#define ANDROID_HARDWARE_MANAGER_HIDLSERVICE_H
#include <set>
#include <android/hidl/manager/1.1/IServiceManager.h>
#include <hidl/Status.h>
#include <hidl/MQDescriptor.h>
namespace android {
namespace hidl {
namespace manager {
namespace implementation {
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hidl::base::V1_0::IBase;
using ::android::hidl::manager::V1_0::IServiceNotification;
using ::android::hidl::manager::V1_1::IServiceManager;
using ::android::sp;
struct HidlService {
HidlService(const std::string &interfaceName,
const std::string &instanceName,
const sp<IBase> &service,
const pid_t pid);
HidlService(const std::string &interfaceName,
const std::string &instanceName)
: HidlService(
interfaceName,
instanceName,
nullptr,
static_cast<pid_t>(IServiceManager::PidConstant::NO_PID))
{}
/**
* Note, getService() can be nullptr. This is because you can have a HidlService
* with registered IServiceNotification objects but no service registered yet.
*/
sp<IBase> getService() const;
void setService(sp<IBase> service, pid_t pid);
pid_t getPid() const;
const std::string &getInterfaceName() const;
const std::string &getInstanceName() const;
void addListener(const sp<IServiceNotification> &listener);
bool removeListener(const wp<IBase> &listener);
void registerPassthroughClient(pid_t pid);
std::string string() const; // e.x. "[email protected]::IServiceManager/manager"
const std::set<pid_t> &getPassthroughClients() const;
private:
void sendRegistrationNotifications();
const std::string mInterfaceName; // e.x. "[email protected]::IServiceManager"
const std::string mInstanceName; // e.x. "manager"
sp<IBase> mService;
std::vector<sp<IServiceNotification>> mListeners{};
std::set<pid_t> mPassthroughClients{};
pid_t mPid = static_cast<pid_t>(IServiceManager::PidConstant::NO_PID);
};
} // namespace implementation
} // namespace manager
} // namespace hidl
} // namespace android
#endif // ANDROID_HARDWARE_MANAGER_HIDLSERVICE_H