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 11 // VirtualTouchpadService implements the service side of 12 // the Binder interface defined in VirtualTouchpadService.aidl. 13 // 14 class VirtualTouchpadService : public BnVirtualTouchpadService { 15 public: VirtualTouchpadService(std::unique_ptr<VirtualTouchpad> touchpad)16 explicit VirtualTouchpadService(std::unique_ptr<VirtualTouchpad> touchpad) 17 : touchpad_(std::move(touchpad)), client_pid_(0) {} 18 ~VirtualTouchpadService() override; 19 20 protected: 21 // Implements IVirtualTouchpadService. 22 binder::Status attach() override; 23 binder::Status detach() override; 24 binder::Status touch(int touchpad, float x, float y, float pressure) override; 25 binder::Status buttonState(int touchpad, int buttons) override; 26 binder::Status scroll(int touchpad, float x, float y) override; 27 28 // Implements BBinder::dump(). 29 status_t dump(int fd, const Vector<String16>& args) override; 30 31 private: 32 bool CheckPermissions(); 33 bool CheckTouchPermission(pid_t* out_pid); 34 35 std::unique_ptr<VirtualTouchpad> touchpad_; 36 37 // Only one client at a time can use the virtual touchpad. 38 pid_t client_pid_; 39 40 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 48