summaryrefslogtreecommitdiff
path: root/tvapi/android/libtvbinder/ITvClient.cpp (plain)
blob: 0c450afcd86dcece3e38713c7362f5dc5a7de90f
1#define LOG_TAG "ITvClient"
2#include <utils/Log.h>
3#include <stdint.h>
4#include <sys/types.h>
5#include <include/ITvClient.h>
6#include "../include/tvcmd.h"
7enum {
8 NOTIFY_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
9};
10
11class BpTvClient: public BpInterface<ITvClient> {
12public:
13 BpTvClient(const sp<IBinder> &impl) :
14 BpInterface<ITvClient> (impl)
15 {
16 }
17
18 // generic callback from tv service to app
19 void notifyCallback(int32_t msgType, const Parcel &p)
20 {
21 ALOGV("BpTvClient notifyCallback datasize = %d pos = %d", p.dataSize(), p.dataPosition());
22 Parcel data, reply;
23 data.writeInterfaceToken(ITvClient::getInterfaceDescriptor());
24 data.writeInt32(msgType);
25 data.write(p.data(), p.dataSize());
26 remote()->transact(NOTIFY_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
27 }
28};
29
30IMPLEMENT_META_INTERFACE(TvClient, "android.amlogic.ITvClient");
31
32// ----------------------------------------------------------------------
33status_t BnTvClient::onTransact(uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags)
34{
35 int i = 0, loop_count = 0;
36
37 switch (code) {
38 case NOTIFY_CALLBACK: {
39 CHECK_INTERFACE(ITvClient, data, reply);
40 Parcel ext;
41 int32_t msgType = data.readInt32();
42
43 ext.appendFrom(const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail());
44
45
46 switch (msgType) {
47 default:
48 ALOGE("BnTvClient::onTransact NOTIFY_CALLBACK msg type ----= %d", msgType);
49 break;
50 }
51 notifyCallback(msgType, ext);
52 return NO_ERROR;
53 }
54 break;
55 default:
56 return BBinder::onTransact(code, data, reply, flags);
57 }
58}
59