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