mirror of
https://github.com/ioacademy-jikim/android_framwork
synced 2025-06-07 16:06:29 +00:00
6
This commit is contained in:
parent
2e9e084a4b
commit
ecb311055a
BIN
03_day.pptx
BIN
03_day.pptx
Binary file not shown.
7
03_day/binder_3/Android.bp
Normal file
7
03_day/binder_3/Android.bp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
cc_binary {
|
||||||
|
name: "my_server_cpp_1",
|
||||||
|
shared_libs: ["liblog", "libutils", "libbinder"],
|
||||||
|
srcs: [
|
||||||
|
"my_server.cpp",
|
||||||
|
],
|
||||||
|
}
|
54
03_day/binder_3/ProcessState.cpp
Normal file
54
03_day/binder_3/ProcessState.cpp
Normal 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
|
21
03_day/binder_3/my_server.cpp
Normal file
21
03_day/binder_3/my_server.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user