[Android Frameworks] native Binder and IMemory

编程入门 行业动态 更新时间:2024-10-19 22:29:41

[Android <a href=https://www.elefans.com/category/jswz/34/1720701.html style=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

本文发布于:2023-12-03 23:36:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1659019.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Frameworks   Android   native   IMemory   Binder

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!