blob: 194d78711c9d278dbc98c90d1b10e0acb1b2bec1 [file] [log] [blame]
Alex Vakulenkoe4eec202017-01-27 14:41:04 -08001#ifndef ANDROID_DVR_VIRTUAL_TOUCHPAD_SERVICE_H
2#define ANDROID_DVR_VIRTUAL_TOUCHPAD_SERVICE_H
3
4#include <android/dvr/BnVirtualTouchpadService.h>
5
6#include "VirtualTouchpad.h"
7
8namespace android {
9namespace dvr {
10
Kevin Schoedel43b5b062017-01-19 13:46:17 -050011// VirtualTouchpadService implements the service side of
12// the Binder interface defined in VirtualTouchpadService.aidl.
13//
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080014class VirtualTouchpadService : public BnVirtualTouchpadService {
15 public:
Kevin Schoedel89af70b2017-03-03 18:11:37 -050016 VirtualTouchpadService(sp<VirtualTouchpad> touchpad)
Kevin Schoedel4b64dd42017-03-07 13:06:25 -050017 : touchpad_(touchpad), client_pid_(0) {}
18 ~VirtualTouchpadService() override;
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080019
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080020 protected:
21 // Implements IVirtualTouchpadService.
Kevin Schoedel4b64dd42017-03-07 13:06:25 -050022 binder::Status attach() override;
23 binder::Status detach() override;
Kevin Schoedel3002b8a2017-03-06 14:34:39 -050024 binder::Status touch(int touchpad, float x, float y, float pressure) override;
25 binder::Status buttonState(int touchpad, int buttons) override;
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080026
Kevin Schoedel4b64dd42017-03-07 13:06:25 -050027 // Implements BBinder::dump().
28 status_t dump(int fd, const Vector<String16>& args) override;
29
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080030 private:
Kevin Schoedel4b64dd42017-03-07 13:06:25 -050031 bool CheckPermissions();
32 bool CheckTouchPermission(pid_t* out_pid);
33
Kevin Schoedel89af70b2017-03-03 18:11:37 -050034 sp<VirtualTouchpad> touchpad_;
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080035
Kevin Schoedel4b64dd42017-03-07 13:06:25 -050036 // Only one client at a time can use the virtual touchpad.
37 pid_t client_pid_;
38
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080039 VirtualTouchpadService(const VirtualTouchpadService&) = delete;
40 void operator=(const VirtualTouchpadService&) = delete;
41};
42
43} // namespace dvr
44} // namespace android
45
46#endif // ANDROID_DVR_VIRTUAL_TOUCHPAD_SERVICE_H