summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dan Stoza <stoza@google.com> 2017-03-30 16:37:19 -0700
committer Dan Stoza <stoza@google.com> 2017-04-06 11:42:38 -0700
commite1c599b52fcce94bd27ebbc4d74cd59c9e71b452 (patch)
treedf4b3a3a154ecc3950d03ed37e912526fa6c6f6c
parenta5f61dd70ac151c8adbde20d3bc4cd7d27808d21 (diff)
libgui: Normalize IDisplayEventConnection methods
This change modifies the IDisplayEventConnection API such that every synchronous method returns a status_t (to be able to return transport errors). This required changing getDataChannel to return its channel by output parameter rather than return type. Currently no more error messages are checked than before, but this will both enable calling code to check error messages if it desires and, more importantly, allow the Bp/Bn code to be semi-automatically generated using SafeInterface. Test: libgui_tests + manual testing Change-Id: I8d5bc5ef0475cee07b638a97079b234f0384c022
-rw-r--r--include/gui/IDisplayEventConnection.h4
-rw-r--r--libs/gui/DisplayEventReceiver.cpp2
-rw-r--r--libs/gui/IDisplayEventConnection.cpp15
-rw-r--r--services/surfaceflinger/EventThread.cpp8
-rw-r--r--services/surfaceflinger/EventThread.h6
-rw-r--r--services/surfaceflinger/MessageQueue.cpp2
6 files changed, 21 insertions, 16 deletions
diff --git a/include/gui/IDisplayEventConnection.h b/include/gui/IDisplayEventConnection.h
index 6512adb396..ebebfbe57e 100644
--- a/include/gui/IDisplayEventConnection.h
+++ b/include/gui/IDisplayEventConnection.h
@@ -34,14 +34,14 @@ public:
/*
* getDataChannel() returns a BitTube where to receive the events from
*/
- virtual sp<BitTube> getDataChannel() const = 0;
+ virtual status_t getDataChannel(sp<BitTube>* outChannel) const = 0;
/*
* setVsyncRate() sets the vsync event delivery rate. A value of 1 returns every vsync event.
* A value of 2 returns every other event, etc. A value of 0 returns no event unless
* requestNextVsync() has been called.
*/
- virtual void setVsyncRate(uint32_t count) = 0;
+ virtual status_t setVsyncRate(uint32_t count) = 0;
/*
* requestNextVsync() schedules the next vsync event. It has no effect if the vsync rate is > 0.
diff --git a/libs/gui/DisplayEventReceiver.cpp b/libs/gui/DisplayEventReceiver.cpp
index 07e07e058b..16b06e9a6e 100644
--- a/libs/gui/DisplayEventReceiver.cpp
+++ b/libs/gui/DisplayEventReceiver.cpp
@@ -37,7 +37,7 @@ DisplayEventReceiver::DisplayEventReceiver() {
if (sf != NULL) {
mEventConnection = sf->createDisplayEventConnection();
if (mEventConnection != NULL) {
- mDataChannel = mEventConnection->getDataChannel();
+ mEventConnection->getDataChannel(&mDataChannel);
}
}
}
diff --git a/libs/gui/IDisplayEventConnection.cpp b/libs/gui/IDisplayEventConnection.cpp
index 4d2d7e90f7..2de2f8a2f4 100644
--- a/libs/gui/IDisplayEventConnection.cpp
+++ b/libs/gui/IDisplayEventConnection.cpp
@@ -29,23 +29,25 @@ public:
explicit BpDisplayEventConnection(const sp<IBinder>& impl)
: BpInterface<IDisplayEventConnection>(impl) {}
- virtual ~BpDisplayEventConnection();
+ ~BpDisplayEventConnection() override;
- virtual sp<BitTube> getDataChannel() const {
+ status_t getDataChannel(sp<BitTube>* outChannel) const override {
Parcel data, reply;
data.writeInterfaceToken(IDisplayEventConnection::getInterfaceDescriptor());
remote()->transact(GET_DATA_CHANNEL, data, &reply);
- return new BitTube(reply);
+ *outChannel = new BitTube(reply);
+ return NO_ERROR;
}
- virtual void setVsyncRate(uint32_t count) {
+ status_t setVsyncRate(uint32_t count) override {
Parcel data, reply;
data.writeInterfaceToken(IDisplayEventConnection::getInterfaceDescriptor());
data.writeUint32(count);
remote()->transact(SET_VSYNC_RATE, data, &reply);
+ return NO_ERROR;
}
- virtual void requestNextVsync() {
+ void requestNextVsync() override {
Parcel data, reply;
data.writeInterfaceToken(IDisplayEventConnection::getInterfaceDescriptor());
remote()->transact(REQUEST_NEXT_VSYNC, data, &reply, IBinder::FLAG_ONEWAY);
@@ -63,7 +65,8 @@ status_t BnDisplayEventConnection::onTransact(uint32_t code, const Parcel& data,
switch (code) {
case GET_DATA_CHANNEL: {
CHECK_INTERFACE(IDisplayEventConnection, data, reply);
- sp<BitTube> channel(getDataChannel());
+ sp<BitTube> channel;
+ getDataChannel(&channel);
channel->writeToParcel(reply);
return NO_ERROR;
}
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp
index 486bce4930..463e60c08b 100644
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -403,12 +403,14 @@ void EventThread::Connection::onFirstRef() {
mEventThread->registerDisplayEventConnection(this);
}
-sp<BitTube> EventThread::Connection::getDataChannel() const {
- return mChannel;
+status_t EventThread::Connection::getDataChannel(sp<BitTube>* outChannel) const {
+ *outChannel = mChannel;
+ return NO_ERROR;
}
-void EventThread::Connection::setVsyncRate(uint32_t count) {
+status_t EventThread::Connection::setVsyncRate(uint32_t count) {
mEventThread->setVsyncRate(count, this);
+ return NO_ERROR;
}
void EventThread::Connection::requestNextVsync() {
diff --git a/services/surfaceflinger/EventThread.h b/services/surfaceflinger/EventThread.h
index 3f1d0bba3f..c0b5532562 100644
--- a/services/surfaceflinger/EventThread.h
+++ b/services/surfaceflinger/EventThread.h
@@ -68,9 +68,9 @@ class EventThread : public Thread, private VSyncSource::Callback {
private:
virtual ~Connection();
virtual void onFirstRef();
- virtual sp<BitTube> getDataChannel() const;
- virtual void setVsyncRate(uint32_t count);
- virtual void requestNextVsync(); // asynchronous
+ status_t getDataChannel(sp<BitTube>* outChannel) const override;
+ status_t setVsyncRate(uint32_t count) override;
+ void requestNextVsync() override; // asynchronous
sp<EventThread> const mEventThread;
sp<BitTube> const mChannel;
};
diff --git a/services/surfaceflinger/MessageQueue.cpp b/services/surfaceflinger/MessageQueue.cpp
index debea58e55..6ef26fe3df 100644
--- a/services/surfaceflinger/MessageQueue.cpp
+++ b/services/surfaceflinger/MessageQueue.cpp
@@ -94,7 +94,7 @@ void MessageQueue::setEventThread(const sp<EventThread>& eventThread)
{
mEventThread = eventThread;
mEvents = eventThread->createEventConnection();
- mEventTube = mEvents->getDataChannel();
+ mEvents->getDataChannel(&mEventTube);
mLooper->addFd(mEventTube->getFd(), 0, Looper::EVENT_INPUT,
MessageQueue::cb_eventReceiver, this);
}