1
0
mirror of https://github.com/ioacademy-jikim/android_framwork synced 2025-06-07 16:06:29 +00:00
This commit is contained in:
ioacademy-jikim 2018-06-14 15:08:04 +09:00
parent 2e9e084a4b
commit ecb311055a
4 changed files with 82 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,7 @@
cc_binary {
name: "my_server_cpp_1",
shared_libs: ["liblog", "libutils", "libbinder"],
srcs: [
"my_server.cpp",
],
}

View File

@ -0,0 +1,54 @@
#if 1
#include <stdio.h>
class ProcessState
{
static ProcessState *gProcess;
ProcessState()
{
printf("fd=open(\"/dev/binder\", O_RDWR)\n");
}
public:
static ProcessState *self()
{
if( gProcess == 0 )
gProcess = new ProcessState;
return gProcess;
}
~ProcessState()
{
printf("close(fd)\n");
}
};
ProcessState *ProcessState::gProcess = 0;
int main()
{
ProcessState *p1 = ProcessState::self();
ProcessState *p2 = ProcessState::self();
//ProcessState process;
return 0;
}
#endif
#if 0
#include <stdio.h>
class ProcessState
{
public:
ProcessState()
{
printf("fd=open(\"/dev/binder\", O_RDWR)\n");
}
~ProcessState()
{
printf("close(fd)\n");
}
};
int main()
{
ProcessState p1;
ProcessState p2;
return 0;
}
#endif

View File

@ -0,0 +1,21 @@
#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());
sm->addService( String16("led.service"), new BBinder );
IPCThreadState::self()->joinThreadPool();
return 0;
}