###Android Automotive
Android Automotive 是Android Oreo中的一个新的特色功能,从AOSP的代码上来看,Android O中已经包含有了从Application到Framework 到HAL的整体框架,这一章节,我们简单的过以下Android Vehicle 的框架,以及重点看下 Vehicle HAL的东西。总体结构大约是以下这个样子:
上图的结构应该是Android Oreo当中比较通用的框架结构了,从Application 到Framework到HAL,跟之前的Android版本相比,之前Framework要不通过binder联系上一个Daemon,这个Daemon再去load 相关的HAL,要不就是这些Framework的service直接通过JNI去load 这些个HAL 库。而现在的Android Oreo则是Framework 与HAL之间直接采用HIDL来做联络沟通了。接下来我们从下往上的来把Android Vehicle的框架捋一下吧。首先来分析下Vehicle HAL,通过这个来复习并且实践下之前研究学习过的Android HIDL.
####Android Vehicle HAL
types.hal 定义的是一些数据结构,IVehicle.hal定义的是从Framework往HAL调用的接口,而IVehicleCallback.hal则是HAL往Framework 上报回调的接口。看起来还是挺清晰的吧。
而IVehicle.hal的接口也不是很多,
package [email protected];
import IVehicleCallback;
interface IVehicle {
/**
* Returns a list of all property configurations supported by this vehicle
* HAL.
*/
getAllPropConfigs() generates (vec<VehiclePropConfig> propConfigs);
/**
* Returns a list of property configurations for given properties.
*
* If requested VehicleProperty wasn't found it must return
* StatusCode::INVALID_ARG, otherwise a list of vehicle property
* configurations with StatusCode::OK
*/
getPropConfigs(vec<int32_t> props)
generates (StatusCode status, vec<VehiclePropConfig> propConfigs);
/**
* Get a vehicle property value.
*
* For VehiclePropertyChangeMode::STATIC properties, this method must always
* return the same value always.
* For VehiclePropertyChangeMode::ON_CHANGE properties, it must return the
* latest available value.
*
* Some properties like AUDIO_VOLUME requires to pass additional data in
* GET request in VehiclePropValue object.
*
* If there is no data available yet, which can happen during initial stage,
* this call must return immediately with an error code of
* StatusCode::TRY_AGAIN.
*/
get(VehiclePropValue requestedPropValue)
generates (StatusCode status, VehiclePropValue propValue);
/**
* Set a vehicle property value.
*
* Timestamp of data must be ignored for set operation.
*
* Setting some properties require having initial state available. If initial
* data is not available yet this call must return StatusCode::TRY_AGAIN.
* For a property with separate power control this call must return
* StatusCode::NOT_AVAILABLE error if property is not powered on.
*/
set(VehiclePropValue propValue) generates (StatusCode status);
/**
* Subscribes to property events.
*
* Clients must be able to subscribe to multiple properties at a time
* depending on data provided in options argument.
*
* @param listener This client must be called on appropriate event.
* @param options List of options to subscribe. SubscribeOption contains
* information such as property Id, area Id