1
0
mirror of https://github.com/ioacademy-jikim/android_framwork synced 2025-06-07 16:06:29 +00:00
android_framwork/04_day/binder_6/ILedService.cpp
ioacademy-jikim 7a0a2db279 9
2018-06-15 10:55:16 +09:00

50 lines
1.2 KiB
C++

#define LOG_TAG "LedService"
#include "ILedService.h"
#include <binder/IPCThreadState.h>
#include <binder/Parcel.h>
#include <unistd.h>
namespace android {
// ----------------------------------------------------------------------
class BpLedService : public BpInterface<ILedService>
{
public:
explicit BpLedService(const sp<IBinder>& impl)
: BpInterface<ILedService>(impl)
{
}
virtual void connect(sp<ILedClient>& client)
{
printf("BpLedService::ledOn()\n");
Parcel data, reply;
data.writeStrongBinder(ILedClient::asBinder(client));
remote()->transact(CONNECT, data, &reply);
}
};
IMPLEMENT_META_INTERFACE(LedService, "android.os.ILedService");
// ----------------------------------------------------------------------
status_t BnLedService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch (code) {
case CONNECT: {
sp<ILedClient> client;
data.readStrongBinder(&client);
connect(client);
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
// ----------------------------------------------------------------------
}; // namespace android