From ce5ab0807a71ce53793dd2f8721f5258943b7f0a Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Thu, 9 Jul 2020 17:03:21 -0500 Subject: 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 --- services/inputflinger/InputManager.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'services/inputflinger/InputManager.cpp') 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 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 channel = InputChannel::create(info.mName, std::move(newFd), info.mToken); +binder::Status InputManager::unregisterInputChannel(const InputChannel& channel) { mDispatcher->unregisterInputChannel(channel); return binder::Status::ok(); } -- cgit v1.2.3-59-g8ed1b