libgui: Remove RefBase from BitTube
Removes RefBase from BitTube, since because it is not a Binder object,
it doesn't need to be reference-counted in this way.
In the process, we rename IDisplayEventConnection::getDataChannel to
IDEC::stealReceiveChannel to make it clearer that this is a non-const
operation on the remote end that removes its access to the receive
channel.
This also adds a couple of methods for moving the receive file
descriptor out of one BitTube and into another, since this is the
essence of the IDisplayEventConnection::stealReceiveChannel method,
and now with C++11 move semantics, we can do this without needing to
return an sp<> from EventThread's implementation of stealReceiveChannel.
Test: m -j + manual testing
Change-Id: Ibaaca2a14fb6155052fe5434c14bc3e671b43743
diff --git a/libs/gui/DisplayEventReceiver.cpp b/libs/gui/DisplayEventReceiver.cpp
index a3ae68c..1507d51 100644
--- a/libs/gui/DisplayEventReceiver.cpp
+++ b/libs/gui/DisplayEventReceiver.cpp
@@ -37,7 +37,8 @@
if (sf != NULL) {
mEventConnection = sf->createDisplayEventConnection();
if (mEventConnection != NULL) {
- mEventConnection->getDataChannel(&mDataChannel);
+ mDataChannel = std::make_unique<gui::BitTube>();
+ mEventConnection->stealReceiveChannel(mDataChannel.get());
}
}
}
@@ -80,16 +81,16 @@
ssize_t DisplayEventReceiver::getEvents(DisplayEventReceiver::Event* events,
size_t count) {
- return DisplayEventReceiver::getEvents(mDataChannel, events, count);
+ return DisplayEventReceiver::getEvents(mDataChannel.get(), events, count);
}
-ssize_t DisplayEventReceiver::getEvents(const sp<gui::BitTube>& dataChannel,
+ssize_t DisplayEventReceiver::getEvents(gui::BitTube* dataChannel,
Event* events, size_t count)
{
return gui::BitTube::recvObjects(dataChannel, events, count);
}
-ssize_t DisplayEventReceiver::sendEvents(const sp<gui::BitTube>& dataChannel,
+ssize_t DisplayEventReceiver::sendEvents(gui::BitTube* dataChannel,
Event const* events, size_t count)
{
return gui::BitTube::sendObjects(dataChannel, events, count);