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
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index c749806..89314e1 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -602,7 +602,8 @@
class FakeInputReceiver {
public:
- explicit FakeInputReceiver(const sp<InputChannel>& clientChannel, const std::string name)
+ explicit FakeInputReceiver(const std::shared_ptr<InputChannel>& clientChannel,
+ const std::string name)
: mName(name) {
mConsumer = std::make_unique<InputConsumer>(clientChannel);
}
@@ -754,7 +755,7 @@
int32_t displayId, sp<IBinder> token = nullptr)
: mName(name) {
if (token == nullptr) {
- sp<InputChannel> serverChannel, clientChannel;
+ std::shared_ptr<InputChannel> serverChannel, clientChannel;
InputChannel::openInputChannelPair(name, serverChannel, clientChannel);
mInputReceiver = std::make_unique<FakeInputReceiver>(clientChannel, name);
dispatcher->registerInputChannel(serverChannel);
@@ -1767,7 +1768,7 @@
public:
FakeMonitorReceiver(const sp<InputDispatcher>& dispatcher, const std::string name,
int32_t displayId, bool isGestureMonitor = false) {
- sp<InputChannel> serverChannel, clientChannel;
+ std::shared_ptr<InputChannel> serverChannel, clientChannel;
InputChannel::openInputChannelPair(name, serverChannel, clientChannel);
mInputReceiver = std::make_unique<FakeInputReceiver>(clientChannel, name);
dispatcher->registerInputMonitor(serverChannel, displayId, isGestureMonitor);