Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 1 | #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 | |
| 8 | namespace android { |
| 9 | namespace dvr { |
| 10 | |
Kevin Schoedel | 43b5b06 | 2017-01-19 13:46:17 -0500 | [diff] [blame] | 11 | // VirtualTouchpadService implements the service side of |
| 12 | // the Binder interface defined in VirtualTouchpadService.aidl. |
| 13 | // |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 14 | class VirtualTouchpadService : public BnVirtualTouchpadService { |
| 15 | public: |
Kevin Schoedel | 89af70b | 2017-03-03 18:11:37 -0500 | [diff] [blame] | 16 | VirtualTouchpadService(sp<VirtualTouchpad> touchpad) |
Kevin Schoedel | 4b64dd4 | 2017-03-07 13:06:25 -0500 | [diff] [blame^] | 17 | : touchpad_(touchpad), client_pid_(0) {} |
| 18 | ~VirtualTouchpadService() override; |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 19 | |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 20 | protected: |
| 21 | // Implements IVirtualTouchpadService. |
Kevin Schoedel | 4b64dd4 | 2017-03-07 13:06:25 -0500 | [diff] [blame^] | 22 | binder::Status attach() override; |
| 23 | binder::Status detach() override; |
Kevin Schoedel | 3002b8a | 2017-03-06 14:34:39 -0500 | [diff] [blame] | 24 | binder::Status touch(int touchpad, float x, float y, float pressure) override; |
| 25 | binder::Status buttonState(int touchpad, int buttons) override; |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 26 | |
Kevin Schoedel | 4b64dd4 | 2017-03-07 13:06:25 -0500 | [diff] [blame^] | 27 | // Implements BBinder::dump(). |
| 28 | status_t dump(int fd, const Vector<String16>& args) override; |
| 29 | |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 30 | private: |
Kevin Schoedel | 4b64dd4 | 2017-03-07 13:06:25 -0500 | [diff] [blame^] | 31 | bool CheckPermissions(); |
| 32 | bool CheckTouchPermission(pid_t* out_pid); |
| 33 | |
Kevin Schoedel | 89af70b | 2017-03-03 18:11:37 -0500 | [diff] [blame] | 34 | sp<VirtualTouchpad> touchpad_; |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 35 | |
Kevin Schoedel | 4b64dd4 | 2017-03-07 13:06:25 -0500 | [diff] [blame^] | 36 | // Only one client at a time can use the virtual touchpad. |
| 37 | pid_t client_pid_; |
| 38 | |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 39 | 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 |