• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
BpProducerListener(const sp<IBinder> & impl)30     BpProducerListener(const sp<IBinder>& impl)
31         : BpInterface<IProducerListener>(impl) {}
32 
33     virtual ~BpProducerListener();
34 
onBufferReleased()35     virtual void onBufferReleased() {
36         Parcel data, reply;
37         data.writeInterfaceToken(IProducerListener::getInterfaceDescriptor());
38         remote()->transact(ON_BUFFER_RELEASED, data, &reply, IBinder::FLAG_ONEWAY);
39     }
40 };
41 
42 // Out-of-line virtual method definition to trigger vtable emission in this
43 // translation unit (see clang warning -Wweak-vtables)
~BpProducerListener()44 BpProducerListener::~BpProducerListener() {}
45 
46 IMPLEMENT_META_INTERFACE(ProducerListener, "android.gui.IProducerListener")
47 
onTransact(uint32_t code,const Parcel & data,Parcel * reply,uint32_t flags)48 status_t BnProducerListener::onTransact(uint32_t code, const Parcel& data,
49         Parcel* reply, uint32_t flags) {
50     switch (code) {
51         case ON_BUFFER_RELEASED:
52             CHECK_INTERFACE(IProducerListener, data, reply);
53             onBufferReleased();
54             return NO_ERROR;
55     }
56     return BBinder::onTransact(code, data, reply, flags);
57 }
58 
59 } // namespace android
60