Frameworks] native Binder and IMemory"/>
[Android Frameworks] native Binder and IMemory
前言:
Android 在native层(c/c++)提供了一种 IPC 机制 —— Binder,Binder的底层是通过共享内存来实现的,共享内存的 wrapper IMemory 也在 Binder 的工程里,而且是可以复用的,即如果想在 Android的 native 层使用共享内存,那么可以使用 IMemory 体系。
源码路径:\frameworks\native\libs\binder
Binder同时提供了 ndk 和 aidl ,因此同时存在 java 和 c++ 的api 。
native头文件路径:#include <binder/xxx> , \frameworks\native\libs\binder\include\binder
工程结构:
核心工程 libbinder
cc_library_shared {name: "libbinder",...srcs: ["ActivityManager.cpp","AppOpsManager.cpp","Binder.cpp","BpBinder.cpp","BufferedTextOutput.cpp","Debug.cpp","IActivityManager.cpp","IAppOpsCallback.cpp","IAppOpsService.cpp","IBatteryStats.cpp","IInterface.cpp","IMediaResourceMonitor.cpp","IMemory.cpp","IPCThreadState.cpp","IPermissionController.cpp","IProcessInfoService.cpp","IResultReceiver.cpp","IServiceManager.cpp","IShellCallback.cpp","IUidObserver.cpp","MemoryBase.cpp","MemoryDealer.cpp","MemoryHeapBase.cpp","Parcel.cpp","ParcelFileDescriptor.cpp","PermissionCache.cpp","PermissionController.cpp","PersistableBundle.cpp","ProcessInfoService.cpp","ProcessState.cpp","Static.cpp","Status.cpp","TextOutput.cpp","IpPrefix.cpp","Value.cpp",":libbinder_aidl",],...}
ndk 工程 libbinder_ndk
cc_library {name: "libbinder_ndk",
...srcs: ["ibinder.cpp","ibinder_jni.cpp","parcel.cpp","process.cpp","status.cpp","service_manager.cpp",],shared_libs: ["libandroid_runtime_lazy","libbase","libbinder","libutils",],...}ndk_library {name: "libbinder_ndk",symbol_file: "libbinder_ndk.map.txt",first_version: "29",
}
核心内容:
头文件:\frameworks\native\libs\binder\include\binder\*
源文件:\frameworks\native\libs\binder\*.cpp
更多推荐
[Android Frameworks] native Binder and IMemory
发布评论