summaryrefslogtreecommitdiff
path: root/tvapi/android/libtvbinder/ITvService.cpp (plain)
blob: d68c60d7b7bdb60ad01ed269f25600341c589f95
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>
12{
13public:
14 BpTvService(const sp<IBinder> &impl)
15 : BpInterface<ITvService>(impl)
16 {
17 }
18
19 // connect to tv service
20 virtual sp<ITv> connect(const sp<ITvClient> &tvClient)
21 {
22 Parcel data, reply;
23 data.writeInterfaceToken(ITvService::getInterfaceDescriptor());
24 data.writeStrongBinder(tvClient->asBinder());
25 remote()->transact(BnTvService::CONNECT, data, &reply);
26 return interface_cast<ITv>(reply.readStrongBinder());
27 }
28};
29
30IMPLEMENT_META_INTERFACE(TvService, "android.amlogic.ITvService");
31
32// ----------------------------------------------------------------------
33
34status_t BnTvService::onTransact(
35 uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags)
36{
37 switch (code) {
38 case CONNECT: {
39 CHECK_INTERFACE(ITvService, data, reply);
40 sp<ITvClient> tvClient = interface_cast<ITvClient>(data.readStrongBinder());
41 sp<ITv> tv = connect(tvClient);
42 ALOGD("BnTvService::onTransact( sp<ITv> tv = connect(tvClient);");
43 reply->writeStrongBinder(tv->asBinder());
44 return NO_ERROR;
45 }
46 break;
47 default:
48 return BBinder::onTransact(code, data, reply, flags);
49 }
50}
51
52