blob: 2c46209228d8e509839c752d3d60ee4de4e8ef71 [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 Schoedelde1cdae2017-03-17 11:07:06 -040016 VirtualTouchpadService(std::unique_ptr<VirtualTouchpad> touchpad)
17 : touchpad_(std::move(touchpad)), client_pid_(0) {}
Kevin Schoedel4b64dd42017-03-07 13:06:25 -050018 ~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;
Kevin Schoedeld8fccf02017-06-05 11:13:20 -040026 binder::Status scroll(int touchpad, float x, float y) override;
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080027
Kevin Schoedel4b64dd42017-03-07 13:06:25 -050028 // Implements BBinder::dump().
29 status_t dump(int fd, const Vector<String16>& args) override;
30
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080031 private:
Kevin Schoedel4b64dd42017-03-07 13:06:25 -050032 bool CheckPermissions();
33 bool CheckTouchPermission(pid_t* out_pid);
34
Kevin Schoedelde1cdae2017-03-17 11:07:06 -040035 std::unique_ptr<VirtualTouchpad> touchpad_;
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080036
Kevin Schoedel4b64dd42017-03-07 13:06:25 -050037 // Only one client at a time can use the virtual touchpad.
38 pid_t client_pid_;
39
Alex Vakulenkoe4eec202017-01-27 14:41:04 -080040 VirtualTouchpadService(const VirtualTouchpadService&) = delete;
41 void operator=(const VirtualTouchpadService&) = delete;
42};
43
44} // namespace dvr
45} // namespace android
46
47#endif // ANDROID_DVR_VIRTUAL_TOUCHPAD_SERVICE_H