summaryrefslogtreecommitdiff
path: root/tvapi/android/libtvbinder/ITvService.cpp (plain)
blob: a60b032d515d28b142c600cfba260e71da6b24bf
1
2#include <stdint.h>
3#include <sys/types.h>
4#include <utils/Log.h>
5#include <binder/Parcel.h>
6#include <binder/IPCThreadState.h>
7#include <binder/IServiceManager.h>
8
9#include <include/ITvService.h>
10
11class BpTvService: public BpInterface<ITvService> {
12public:
13 BpTvService(const sp<IBinder> &impl)
14 : BpInterface<ITvService>(impl)
15 {
16 }
17
18 // connect to tv service
19 virtual sp<ITv> connect(const sp<ITvClient> &tvClient)
20 {
21 Parcel data, reply;
22 data.writeInterfaceToken(ITvService::getInterfaceDescriptor());
23 data.writeStrongBinder(IInterface::asBinder(tvClient));
24 remote()->transact(BnTvService::CONNECT, data, &reply);
25 return interface_cast<ITv>(reply.readStrongBinder());
26 }
27};
28
29IMPLEMENT_META_INTERFACE(TvService, "android.amlogic.ITvService");
30
31// ----------------------------------------------------------------------
32
33status_t BnTvService::onTransact(
34 uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags)
35{
36 switch (code) {
37 case CONNECT: {
38 CHECK_INTERFACE(ITvService, data, reply);
39 sp<ITvClient> tvClient = interface_cast<ITvClient>(data.readStrongBinder());
40 sp<ITv> tv = connect(tvClient);
41 ALOGD("BnTvService::onTransact( sp<ITv> tv = connect(tvClient);");
42 reply->writeStrongBinder(IInterface::asBinder(tv));
43 return NO_ERROR;
44 }
45 break;
46 default:
47 return BBinder::onTransact(code, data, reply, flags);
48 }
49}
50
51