Android O 前期预研之三:Android Vehicle HAL

本文探讨了Android Oreo中的Android Automotive特性,重点关注Vehicle HAL的框架和接口。Vehicle HAL包括types.hal的数据结构定义,IVehicle.hal的调用接口,以及IVehicleCallback.hal的回调接口。在编译过程中,HAL生成名为android.hardware.automotive.vehicle@2.0.so的动态库,并在开机时启动对应的Daemon服务。Vehicle HAL在服务端和客户端的使用涉及HIDL通信和接口注册,但文章指出了一些理解上的困惑点。
摘要由CSDN通过智能技术生成

###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 android.hardware.automotive.vehicle@2.0;

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, sample rate, etc.
   */
  subscribe(IVehicleCallback 
  • 12
    点赞
  • 68
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值