基于android 8 分析
以BatteryService里调用IBatteryPropertiesRegistrar为例
IBinder b = ServiceManager.getService("batteryproperties");
final IBatteryPropertiesRegistrar batteryPropertiesRegistrar =
IBatteryPropertiesRegistrar.Stub.asInterface(b);
batteryPropertiesRegistrar.registerListener(new BatteryListener());
1.BatteryService.java位于
android\frameworks\base\services\core\java\com\android\server
2. IBatteryPropertiesRegistrar 的定义
android\frameworks\native\services\batteryservice
实现在
android\system\core\healthd\BatteryPropertiesRegistrar.cpp
3. java和cpp层的定义需要对应
java层编译
frameworks/base/Android.mk:254: core/java/android/os/IBatteryPropertiesRegistrar.aidl
java 传递的参数如 BatteryProperty和 BatteryProperties 实现Parcelable接口
PS:Camera2的接口也是java调用cpp层的binder,实现在
\LA.UM.6.6\LINUX\android\frameworks\base\core\java\android\hardware\camera2\CameraManager.java