1 /* 2 * Copyright 2014 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 <binder/Parcel.h> 18 19 #include <gui/IProducerListener.h> 20 21 namespace android { 22 23 enum { 24 ON_BUFFER_RELEASED = IBinder::FIRST_CALL_TRANSACTION, 25 }; 26 27 class BpProducerListener : public BpInterface<IProducerListener> 28 { 29 public: 30 BpProducerListener(const sp<IBinder>& impl) 31 : BpInterface<IProducerListener>(impl) {} 32 33 virtual void onBufferReleased() { 34 Parcel data, reply; 35 data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor()); 36 remote()->transact(ON_BUFFER_RELEASED, data, &reply, IBinder::FLAG_ONEWAY); 37 } 38 }; 39 40 IMPLEMENT_META_INTERFACE(ProducerListener, "android.gui.IProducerListener") 41 42 status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data, 43 Parcel* reply, uint32_t flags) { 44 switch (code) { 45 case ON_BUFFER_RELEASED: 46 CHECK_INTERFACE(IProducerListener, data, reply); 47 onBufferReleased(); 48 return NO_ERROR; 49 } 50 return BBinder::onTransact(code, data, reply, flags); 51 } 52 53 } // namespace android 54