1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <gui/IDisplayEventConnection.h> 18 19 #include <private/gui/BitTube.h> 20 21 namespace android { 22 23 namespace { // Anonymous 24 25 enum class Tag : uint32_t { 26 STEAL_RECEIVE_CHANNEL = IBinder::FIRST_CALL_TRANSACTION, 27 SET_VSYNC_RATE, 28 REQUEST_NEXT_VSYNC, 29 LAST = REQUEST_NEXT_VSYNC, 30 }; 31 32 } // Anonymous namespace 33 34 class BpDisplayEventConnection : public SafeBpInterface<IDisplayEventConnection> { 35 public: 36 explicit BpDisplayEventConnection(const sp<IBinder>& impl) 37 : SafeBpInterface<IDisplayEventConnection>(impl, "BpDisplayEventConnection") {} 38 39 ~BpDisplayEventConnection() override; 40 41 status_t stealReceiveChannel(gui::BitTube* outChannel) override { 42 return callRemote<decltype( 43 &IDisplayEventConnection::stealReceiveChannel)>(Tag::STEAL_RECEIVE_CHANNEL, 44 outChannel); 45 } 46 47 status_t setVsyncRate(uint32_t count) override { 48 return callRemote<decltype(&IDisplayEventConnection::setVsyncRate)>(Tag::SET_VSYNC_RATE, 49 count); 50 } 51 52 void requestNextVsync() override { 53 callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( 54 Tag::REQUEST_NEXT_VSYNC); 55 } 56 }; 57 58 // Out-of-line virtual method definition to trigger vtable emission in this translation unit (see 59 // clang warning -Wweak-vtables) 60 BpDisplayEventConnection::~BpDisplayEventConnection() = default; 61 62 IMPLEMENT_META_INTERFACE(DisplayEventConnection, "android.gui.DisplayEventConnection"); 63 64 status_t BnDisplayEventConnection::onTransact(uint32_t code, const Parcel& data, Parcel* reply, 65 uint32_t flags) { 66 if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) { 67 return BBinder::onTransact(code, data, reply, flags); 68 } 69 auto tag = static_cast<Tag>(code); 70 switch (tag) { 71 case Tag::STEAL_RECEIVE_CHANNEL: 72 return callLocal(data, reply, &IDisplayEventConnection::stealReceiveChannel); 73 case Tag::SET_VSYNC_RATE: 74 return callLocal(data, reply, &IDisplayEventConnection::setVsyncRate); 75 case Tag::REQUEST_NEXT_VSYNC: 76 return callLocalAsync(data, reply, &IDisplayEventConnection::requestNextVsync); 77 } 78 } 79 80 } // namespace android 81