This commit is contained in:
ioacademy-jikim
2018-06-14 15:59:12 +09:00
parent ecb311055a
commit 46d02d8dd3
11 changed files with 236 additions and 1 deletions
+8
View File
@@ -5,3 +5,11 @@ cc_binary {
"my_server.cpp",
],
}
cc_binary {
name: "my_client_cpp_1",
shared_libs: ["liblog", "libutils", "libbinder"],
srcs: [
"my_client.cpp",
],
}
+22
View File
@@ -0,0 +1,22 @@
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <binder/Binder.h>
#include <binder/IPCThreadState.h>
#include <utils/String16.h>
using namespace android;
int main()
{
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm(defaultServiceManager());
sp<IBinder> binder = sm->getService( String16("led.service") );
Parcel data, reply;
binder->transact(1, data, &reply);
return 0;
}
+18 -1
View File
@@ -7,11 +7,28 @@
using namespace android;
class LedService : public BBinder
{
public:
status_t onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch (code) {
case 1:
printf("LedService::LED_ON\n");
return NO_ERROR;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
};
int main()
{
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm(defaultServiceManager());
sm->addService( String16("led.service"), new BBinder );
sm->addService( String16("led.service"), new LedService );
IPCThreadState::self()->joinThreadPool();
return 0;