IDisplayEventConnection.cpp revision d0566bc26fcf6ca396118701fa11900b627f2c09
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 <stdint.h> 18#include <sys/types.h> 19 20#include <utils/Errors.h> 21#include <utils/RefBase.h> 22#include <utils/Timers.h> 23 24#include <binder/Parcel.h> 25#include <binder/IInterface.h> 26 27#include <gui/IDisplayEventConnection.h> 28#include <gui/BitTube.h> 29 30namespace android { 31// ---------------------------------------------------------------------------- 32 33enum { 34 GET_DATA_CHANNEL = IBinder::FIRST_CALL_TRANSACTION, 35}; 36 37class BpDisplayEventConnection : public BpInterface<IDisplayEventConnection> 38{ 39public: 40 BpDisplayEventConnection(const sp<IBinder>& impl) 41 : BpInterface<IDisplayEventConnection>(impl) 42 { 43 } 44 45 virtual sp<BitTube> getDataChannel() const 46 { 47 Parcel data, reply; 48 data.writeInterfaceToken(IDisplayEventConnection::getInterfaceDescriptor()); 49 remote()->transact(GET_DATA_CHANNEL, data, &reply); 50 return new BitTube(reply); 51 } 52}; 53 54IMPLEMENT_META_INTERFACE(DisplayEventConnection, "android.gui.DisplayEventConnection"); 55 56// ---------------------------------------------------------------------------- 57 58status_t BnDisplayEventConnection::onTransact( 59 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) 60{ 61 switch(code) { 62 case GET_DATA_CHANNEL: { 63 CHECK_INTERFACE(IDisplayEventConnection, data, reply); 64 sp<BitTube> channel(getDataChannel()); 65 channel->writeToParcel(reply); 66 return NO_ERROR; 67 } break; 68 } 69 return BBinder::onTransact(code, data, reply, flags); 70} 71 72// ---------------------------------------------------------------------------- 73}; // namespace android 74