目录
1. CarPropertyService 基本介绍
1.1 CarPropertyService 结构图
1.2 CarPropertyService 的定义与实现
1.3 CarPropertyManager 与 CarPropertyService
2. PropertyHalService 与 CarPropertyService
3. CarPropertyService 的重要接口介绍
3.1 CarPropertyService–registerListener接口的时序图
本文为android11 上的CarPropertyService 的基本介绍,后续版本基本相同。
1. CarPropertyService 基本介绍
1.1 CarPropertyService 结构图
1.2 CarPropertyService 的定义与实现
CarPropertyService的主要功能是支持订阅和接收属性变化。
CarPropertyService是与CarPowerManagementService同层级的服务。
50 /**
51 * This class implements the binder interface for ICarProperty.aidl to make it easier to create
52 * multiple managers that deal with Vehicle Properties. The property Ids in this class are IDs in
53 * manager level.
54 */
55 public class CarPropertyService extends ICarProperty.Stub
56 implements CarServiceBase, PropertyHalService.PropertyHalListener {
CarPropertyService实现了ICarProperty接口
主要接口为:注册和解注册属性监听,获取和设置属性值等。
1.3 CarPropertyManager 与 CarPropertyService
client使用的属性相关的API集合。
2. PropertyHalService 与 CarPropertyService
PropertyHalService 是 CarPropertyService的关键成员变量:
private final PropertyHalService mHal;
CarPropertyService与PropertyHalService的关系,可以理解为分层关系,PropertyHalService是CarPropertyService的下一层。
PropertyHalService实现了HalServiceBase:
51 /**
52 * Common interface for HAL services that send Vehicle Properties back and forth via ICarProperty.
53 * Services that communicate by passing vehicle properties back and forth via ICarProperty should
54 * extend this class.
55 */
56 public class PropertyHalService extends HalServiceBase {
它实现了基本的属性获取接口:
public
void
subscribeProperty(
int
mgrPropId,
float
rate)
它转发从底层获取来的属性变化消息:
public
void
onHalEvents(List<VehiclePropValue> values)