目錄
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)