diff options
| author | 2020-07-09 17:03:21 -0500 | |
|---|---|---|
| committer | 2020-07-20 14:46:20 -0500 | |
| commit | ce5ab0807a71ce53793dd2f8721f5258943b7f0a (patch) | |
| tree | 341972c76d894923861c1d92cc34c161693adf81 /services/inputflinger/InputManager.cpp | |
| parent | 98da25e58d33e7dadc2dc473b7563afcb232e3de (diff) | |
Use std::shared_ptr for InputChannel
Modernize the code by moving away from RefBase.
We can further improve this by switching to unique_ptr in some places.
Current refactor is to get off of RefBase only.
Test: interact with cf after device boots
Bug: 142581626
Change-Id: Ib90fc721970113310b87411bcc2ba62e30ddfd01
Diffstat (limited to 'services/inputflinger/InputManager.cpp')
| -rw-r--r-- | services/inputflinger/InputManager.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp index c5f60ade96..088c6f1f48 100644 --- a/services/inputflinger/InputManager.cpp +++ b/services/inputflinger/InputManager.cpp @@ -119,7 +119,7 @@ binder::Status InputManager::setInputWindows( } // Used by tests only. -binder::Status InputManager::registerInputChannel(const InputChannelInfo& info) { +binder::Status InputManager::registerInputChannel(const InputChannel& channel) { IPCThreadState* ipc = IPCThreadState::self(); const int uid = ipc->getCallingUid(); if (uid != AID_SHELL && uid != AID_ROOT) { @@ -127,15 +127,12 @@ binder::Status InputManager::registerInputChannel(const InputChannelInfo& info) "from non shell/root entity (PID: %d)", ipc->getCallingPid()); return binder::Status::ok(); } - android::base::unique_fd newFd(::dup(info.mFd)); - sp<InputChannel> channel = InputChannel::create(info.mName, std::move(newFd), info.mToken); - mDispatcher->registerInputChannel(channel); + + mDispatcher->registerInputChannel(channel.dup()); return binder::Status::ok(); } -binder::Status InputManager::unregisterInputChannel(const InputChannelInfo& info) { - android::base::unique_fd newFd(::dup(info.mFd)); - sp<InputChannel> channel = InputChannel::create(info.mName, std::move(newFd), info.mToken); +binder::Status InputManager::unregisterInputChannel(const InputChannel& channel) { mDispatcher->unregisterInputChannel(channel); return binder::Status::ok(); } |