mirror of
https://github.com/ioacademy-jikim/android_framwork.git
synced 2026-08-11 08:22:53 +00:00
7
This commit is contained in:
@@ -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",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user