/* * Copyright (c) Hisilicon Technologies Co., Ltd.. 2012-2019. All rights reserved. * Description: * Author: * Create: */ #define LOG_NDEBUG 0 #define LOG_TAG "TvMW_ITVClient" #include #include #include #include "ITVClient.h" namespace android { enum { NOTIFY = IBinder::FIRST_CALL_TRANSACTION, }; class BpTVClient : public BpInterface { public: explicit BpTVClient(const sp &impl) : BpInterface(impl) {} ~BpTVClient() override {} void notify(unsigned int type, const void *data, unsigned int len, const void *prev) override { TD_UNUSED(prev); Parcel request, reply; request.writeInterfaceToken(ITVClient::getInterfaceDescriptor()); request.writeInt32(type); if (data != nullptr && len > 0) { request.write(data, len); } remote()->transact(NOTIFY, request, &reply, IBinder::FLAG_ONEWAY); } }; IMPLEMENT_META_INTERFACE(TVClient, "android.ITVClient"); // ---------------------------------------------------------------------- Mutex BnTVClient::mNotifyLock; status_t BnTVClient::onTransact(uint32_t code, const Parcel &request, Parcel *reply, uint32_t flags) { Mutex::Autolock _l(mNotifyLock); switch (code) { case NOTIFY: { CHECK_INTERFACE(ITVClient, request, reply); int type = request.readInt32(); int len = static_cast(request.dataAvail()); if (len <= 0) { return -1; } char *data = new char[len]; request.read(data, len); notify(type, data, len, nullptr); if (data != nullptr) { delete[] data; data = nullptr; } return NO_ERROR; } default: return BBinder::onTransact(code, request, reply, flags); } } BnTVClient::~BnTVClient() { } }; // namespace android