Loading libs/input/PointerController.cpp +25 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,29 @@ namespace android { // --- WeakLooperCallback --- class WeakLooperCallback: public LooperCallback { protected: virtual ~WeakLooperCallback() { } public: WeakLooperCallback(const wp<LooperCallback>& callback) : mCallback(callback) { } virtual int handleEvent(int fd, int events, void* data) { sp<LooperCallback> callback = mCallback.promote(); if (callback != NULL) { return callback->handleEvent(fd, events, data); } return 0; // the client is gone, remove the callback } private: wp<LooperCallback> mCallback; }; // --- PointerController --- // Time to wait before starting the fade when the pointer is inactive. Loading @@ -57,10 +80,11 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& const sp<Looper>& looper, const sp<SpriteController>& spriteController) : mPolicy(policy), mLooper(looper), mSpriteController(spriteController) { mHandler = new WeakMessageHandler(this); mCallback = new WeakLooperCallback(this); if (mDisplayEventReceiver.initCheck() == NO_ERROR) { mLooper->addFd(mDisplayEventReceiver.getFd(), Looper::POLL_CALLBACK, Looper::EVENT_INPUT, this, nullptr); Looper::EVENT_INPUT, mCallback, nullptr); } else { ALOGE("Failed to initialize DisplayEventReceiver."); } Loading libs/input/PointerController.h +1 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ private: sp<Looper> mLooper; sp<SpriteController> mSpriteController; sp<WeakMessageHandler> mHandler; sp<LooperCallback> mCallback; DisplayEventReceiver mDisplayEventReceiver; Loading Loading
libs/input/PointerController.cpp +25 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,29 @@ namespace android { // --- WeakLooperCallback --- class WeakLooperCallback: public LooperCallback { protected: virtual ~WeakLooperCallback() { } public: WeakLooperCallback(const wp<LooperCallback>& callback) : mCallback(callback) { } virtual int handleEvent(int fd, int events, void* data) { sp<LooperCallback> callback = mCallback.promote(); if (callback != NULL) { return callback->handleEvent(fd, events, data); } return 0; // the client is gone, remove the callback } private: wp<LooperCallback> mCallback; }; // --- PointerController --- // Time to wait before starting the fade when the pointer is inactive. Loading @@ -57,10 +80,11 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& const sp<Looper>& looper, const sp<SpriteController>& spriteController) : mPolicy(policy), mLooper(looper), mSpriteController(spriteController) { mHandler = new WeakMessageHandler(this); mCallback = new WeakLooperCallback(this); if (mDisplayEventReceiver.initCheck() == NO_ERROR) { mLooper->addFd(mDisplayEventReceiver.getFd(), Looper::POLL_CALLBACK, Looper::EVENT_INPUT, this, nullptr); Looper::EVENT_INPUT, mCallback, nullptr); } else { ALOGE("Failed to initialize DisplayEventReceiver."); } Loading
libs/input/PointerController.h +1 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ private: sp<Looper> mLooper; sp<SpriteController> mSpriteController; sp<WeakMessageHandler> mHandler; sp<LooperCallback> mCallback; DisplayEventReceiver mDisplayEventReceiver; Loading