位置: IT常识 - 正文

车机系统开发——Android Automotive(安卓车机系统开发)

编辑:rootadmin
车机系统开发——Android Automotive Android Automotive介绍

推荐整理分享车机系统开发——Android Automotive(安卓车机系统开发),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:车机 开发,车机 开发,车载系统开发流程,车载系统开发,车载系统开发,车机系统原理,车机系统开发流程,车机 开发,内容如对您有帮助,希望把文章链接给更多的朋友!

Android Automotive是⼀个基本的Android平台,它运⾏预安装的(车载信息娱乐)IVI系统,Android应⽤程序以及可选的第⼆⽅和第三⽅Android应⽤程序。

Android Automotive的硬件抽象层(HAL)为Android框架提供了一致的接口(无需考虑物理传输层)。此车载HAL是开发Android Automotive实现的接口。

系统集成商可以将特定于功能的平台HAL接口(如HVAC)与特定于技术的网络接口(如 CAN 总线)连接,以实现车载 HAL 模块。典型的实现可能包括运行专有实时操作系统(RTOS)的专用微控制器单元 (MCU),该微控制器单元用于CAN总线访问或类似操作,可通过串行链路连接到运行Android Automotive的CPU。

AutoMotive整体架构

系统应用层

Android Automotive 为系统定制了一些专门适用车载系统的应用,以代替传统的手机应用模块。

系统应用层的Application都位于源码目录下:packages/apps/Car/

包含的应用如下

系统框架层

系统框架层提供了多个模块,来对Android Automotive 进行支持,最重要的有一个服务CarService (com.android.car) 。

系统框架层的模块都位于源码目录下:packages/services/Car/

CarService是一个类似Android系统中SystemSever的服务。它由一个服务启动,而里面又控制着数十个子模块服务。

CarService

CarService中CarService只作为服务的入口,具体的业务逻辑都在内部的子服务中处理,CarService的子服务如下。

CarService启动

CarService本质上是一个特殊的APP,它编译后生成CarService.apk;在系统中,它是在/system/priv-app/CarService/CarService.apk

CarService在启动启动时,由SystemServer拉起

代码:frameworks/base/services/java/com/android/server/SystemServer.java

private static final String CAR_SERVICE_HELPER_SERVICE_CLASS = "com.android.internal.car.CarServiceHelperService";private void startOtherServices() { mActivityManagerService.systemReady(() -> { if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { traceBeginAndSlog("StartCarServiceHelperService"); mSystemServiceManager.startService(CAR_SERVICE_HELPER_SERVICE_CLASS); traceEnd(); } });}

代码:frameworks/opt/car/services/src/com/android/internal/car/CarServiceHelperService.java

private static final String CAR_SERVICE_INTERFACE = "android.car.ICar";public class CarServiceHelperService extends SystemService {​ @Override public void onStart() { Intent intent = new Intent(); intent.setPackage("com.android.car"); intent.setAction(CAR_SERVICE_INTERFACE); if (!getContext().bindServiceAsUser(intent, mCarServiceConnection, Context.BIND_AUTO_CREATE, UserHandle.SYSTEM)) { Slog.wtf(TAG, "cannot start car service"); } System.loadLibrary("car-framework-service-jni"); }} SystemServer中ActivityManagerService.systemReady后会通过SystemServiceManager启动CarServiceHelperServiceCarServiceHelperService中绑定CarService 代码:packages/services/Car/service/AndroidManifest.xml<service android:name=".CarService" android:singleUser="true"> <intent-filter> <action android:name="android.car.ICar" /> </intent-filter></service>

通过在CarService的AndroidManifest的配置,CarServiceHelperService可以通过包名和action的名称实现和CarService绑定。

Car API

Car API 是Android系统为汽车应用提供的一套SDK接口(Android Automotive Library)。

源代码位于packages/services/Car/car-lib目录下

Google官方的API文档在Android Q之后,也开始支持Android Automotive库。

链接地址: https://developer.android.google.cn/reference/android/car/package-summary

车机系统开发——Android Automotive(安卓车机系统开发)

同CarService一样Car API 也提供的多个模块对应不同的功能调用。

硬件抽象层

硬件抽象层主要是提供了一个native服务android.hardware.automotive.vehicle@2.0-service,负责处理车辆相关的业务。

硬件抽象层的模块位于源码目录下hardware/interfaces/automotive/

VehicleService

VehicleService是一个native服务,代码实现在目录hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/

VehicleServices是Android Automotive在硬件抽象层的入口。它通过initrc启动。

代码:hardware/interfaces/automotive/vehicle/2.0/default/android.hardware.automotive.vehicle@2.0-service.rc

service vendor.vehicle-hal-2.0 /vendor/bin/hw/android.hardware.automotive.vehicle@2.0-service class hal user vehicle_network group system inetVehicleHalManager

VehicleHalManager是Android Automotive在硬件抽象层的API接口。代码在目录

hardware/interfaces/automotive/vehicle/2.0/default/common/。

HAL接口语言

从硬件抽象层到系统框架层,也就是从VehicleService到CarService,从Android O版本开始使用了一种新的HIDL接口。

HIDL 是用于指定 HAL 和其用户之间的接口的一种接口描述语言 (IDL)。虽然从 Android 10 开始,HIDL 已废弃,Android 将在所有位置改用 AIDL。 但是Android Automotive的HIDL架构还保留着,直到Android 13才发生变化。

HIDL使用一种以.hal为后缀文件作为接口定义,在Android Automotive中硬件抽象层到系统框架层使用IVehicle.hal(代码路径:hardware/interfaces/automotive/vehicle/2.0/IVehicle.halhardware/interfaces/automotive/vehicle/2.0/IVehicle.hal)来定义。

代码:hardware/interfaces/automotive/vehicle/2.0/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. */​ //返回这个vehicle hal支持的全部property属性 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 RADIO_PRESET 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 callback, vec<SubscribeOptions> options) generates (StatusCode status);​ /** * Unsubscribes from property events. * * If this client wasn't subscribed to the given property, this method * must return StatusCode::INVALID_ARG. */​ unsubscribe(IVehicleCallback callback, int32_t propId) generates (StatusCode status);​ /** * Print out debugging state for the vehicle hal. * * The text must be in ASCII encoding only. * * Performance requirements: * * The HAL must return from this call in less than 10ms. This call must avoid * deadlocks, as it may be called at any point of operation. Any synchronization * primitives used (such as mutex locks or semaphores) must be acquired * with a timeout. * */​ debugDump() generates (string s);};

IVehicle接口支持功能如下

update-makefiles.sh

通过update-makefiles.sh 可以创建编译HIDL文件的Android.bp。

代码路径:hardware/interfaces/update-makefiles.sh

假设创建一个helloworld模块,在hardware/interfaces 下创建helloworld/1.0/IHelloWorld.hal:

package android.hardware.helloworld@1.0;interface IHelloWorld { justTest(string name); };

通过update-makefiles.sh就可以在对应package的目录下创建Android.bp:

// This file is autogenerated by hidl-gen -Landroidbp.hidl_interface { name: "android.hardware.helloworld@1.0", root: "android.hardware", vndk: { enabled: true, }, srcs: [ "IHelloWorld.hal", ], interfaces: [ "android.hidl.base@1.0", ], gen_java: true,}

name:模块的全名

root:包根目录

interfaces:编译过程中依赖的模块

gen_java:是否编译为Java 使用的接口

当然,还有其他的参数,例如gen_java_constants设为true 的时候会生成为Java 使用的Constants类。

全文概括了车机系统开发中的;Android Automotive原理架构解析;技术参考《车机开发手册》需要可以点击查看更多车载技术知识。

文末

车载HAL是汽车与车辆网络服务之间的接口定义(同时保护传入的数据):

车载HAL与Android Automotive架构:

Car API:内有包含CarSensorManager在内的API。位于/platform/packages/services/Car/car-libCarService:位于 /platform/packages/services/Car/车载 HAL:用于定义OEM可以实现的车辆属性的接口。包含属性元数据(例如,车辆属性是否为int以及允许使用哪些更改模式)。位于hardware/libhardware/include/hardware/vehicle.h。如需了解基本参考实现,请参阅 hardware/libhardware/modules/vehicle/(vehicle意思即车辆)
本文链接地址:https://www.jiuchutong.com/zhishi/281274.html 转载请保留说明!

上一篇:0x0000001e蓝屏代码意思(0x0000001e蓝屏代码的含义)

下一篇:mediapass.exe 进程有什么用 是什么进程 mediapass进程查询(system-coredump进程)

  • 微信群如何修改自己的备注名称(微信群如何修改备注)

    微信群如何修改自己的备注名称(微信群如何修改备注)

  • 怎么查询社保卡是否激活(怎么查询社保卡账号)

    怎么查询社保卡是否激活(怎么查询社保卡账号)

  • 三星手机怎么连接电脑(三星手机怎么连接蓝牙耳机)

    三星手机怎么连接电脑(三星手机怎么连接蓝牙耳机)

  • 抖音头像如何加皇冠(抖音头像如何加号码和名字)

    抖音头像如何加皇冠(抖音头像如何加号码和名字)

  • 快手极速版上买的东西怎么查订单(快手极速版+免费下载)

    快手极速版上买的东西怎么查订单(快手极速版+免费下载)

  • 为什么cad复制粘贴不了到另一个文件(为什么CAD复制粘贴之后坐标变大了)

    为什么cad复制粘贴不了到另一个文件(为什么CAD复制粘贴之后坐标变大了)

  • cad直线为什么不能指定某个点(cad直线为什么不能输入距离)

    cad直线为什么不能指定某个点(cad直线为什么不能输入距离)

  • 比心注销了还能注册吗(比心注销账号后个人信息会泄露吗)

    比心注销了还能注册吗(比心注销账号后个人信息会泄露吗)

  • 电脑平车断面线怎么调视频(电脑平车断面线怎么调)

    电脑平车断面线怎么调视频(电脑平车断面线怎么调)

  • 下载管理器怎么取消下载(下载中心安装)

    下载管理器怎么取消下载(下载中心安装)

  • vivoy5s微信视频怎么开美颜(vivoy5s微信视频聊天怎么开美颜)

    vivoy5s微信视频怎么开美颜(vivoy5s微信视频聊天怎么开美颜)

  • 探探解除配对后还能划到吗(探探解除配对后还能看到对方活跃时间吗)

    探探解除配对后还能划到吗(探探解除配对后还能看到对方活跃时间吗)

  • 平板电脑开机出现蓝屏英文要怎么处理(平板电脑开机出现一堆英文)

    平板电脑开机出现蓝屏英文要怎么处理(平板电脑开机出现一堆英文)

  • 笔记本电脑瞬间掉电(笔记本电脑瞬间黑屏关机)

    笔记本电脑瞬间掉电(笔记本电脑瞬间黑屏关机)

  • 小米会员支持几台电视(小米会员通用吗)

    小米会员支持几台电视(小米会员通用吗)

  • ipad插卡如何接收短信(ipad插卡教程)

    ipad插卡如何接收短信(ipad插卡教程)

  • 荣耀9x有没有人脸识别(荣耀9x有没有人工智能YOYO)

    荣耀9x有没有人脸识别(荣耀9x有没有人工智能YOYO)

  • 毒app花呗怎么分期(毒上面的花呗分期是什么意思)

    毒app花呗怎么分期(毒上面的花呗分期是什么意思)

  • qq资料卡在哪(QQ资料卡在哪设置)

    qq资料卡在哪(QQ资料卡在哪设置)

  • ipados支持机型(ipados适用哪些机型)

    ipados支持机型(ipados适用哪些机型)

  • 抖音视频水印在哪里关闭(抖音视频的水印)

    抖音视频水印在哪里关闭(抖音视频的水印)

  • 威尔士中部水仙花中的蓝山雀 (© Philip Jones/Alamy)(威尔士黄水仙)

    威尔士中部水仙花中的蓝山雀 (© Philip Jones/Alamy)(威尔士黄水仙)

  • 工资表怎么导入个税系统计算个税
  • 受托加工开票如何选名称
  • 收取职工工会会费收据
  • 固定资产盘点折旧怎么算
  • 足浴店装修费用多少
  • 个税负数怎么做账
  • 实收资本可以做借方吗
  • 支付境外技术服务费代扣代缴所得税账务处理
  • 固定资产后续支出可以计入哪些费用
  • 工资可以直接进管理费用吗
  • 保本销售量的计算公式用安全边际率
  • 房地产企业广告费扣除基数
  • 销售收入包括应收销货款
  • 生产车间的修理计入什么科目
  • 股权计税成本如何计算?
  • 美元转到中国账户可不可以取人民币
  • 虚开费用发票入账
  • 代订机票款发票可以作为机票报销差旅吗
  • 污水处理厂税收风险
  • 商砼税收政策
  • 发票月初抄税流程
  • 外地预缴个人所得税如何入账及申报
  • 公司购买的汽车可以一次性扣除吗
  • 研发费用研究阶段的支出计入
  • 政府减免税款如何做账
  • 录入凭证时记账的依据是
  • 高新技术企业的研发费用比例
  • mac app store一直转圈圈
  • 贷款贴息是什么政策
  • win7旗舰版分辨率调高了黑屏怎么办
  • php header refresh
  • uc浏览器缓存视频删除了还占内存
  • 在Mac OS Yosemite 系统中如何发送超大邮件附件
  • php的数组函数
  • Linux系统中怎么定位到java代码的方法级
  • 怎样识别?
  • 长期投资有哪些渠道
  • 劳务发票服务类型有哪些
  • 印花税具体包括哪几类
  • 小狐狸吧
  • 广播影视服务需要许可证吗
  • 计算机视觉需要学什么
  • 补缴房产税和土地使用税会计分录
  • Apsara Clouder云计算技能认证
  • php简单获取网站的方法
  • 残疾人就业保障金计入什么科目
  • 其他应付款贷方余额表示谁欠谁
  • 企业的职工福利费应当按照应付工资总额的14%计提
  • 小规模增值税减征额怎么算
  • 以固定资产增资流程是怎样操作
  • java方法的返回值类型有哪些
  • 电子发票可以作废吗?当月
  • 子公司再设立子公司
  • 个人所得税进一步改革方向
  • 待报解预算收入什么意思
  • 长期闲置机器设备评估方法
  • 如何加强存货管理,提高存货周转率
  • 递延所得税资产和所得税费用的关系
  • 信用减值损失6702
  • 给员工发工资发多少合适?
  • 企业列支非本单位费用
  • 空气检测费计入什么科目
  • 开办费包括哪些内容多少钱
  • 数据库中的冗余度是什么意思
  • win10系统问题怎么修复
  • ipad和iPhone的mac地址区别
  • Ubuntu软件源更新
  • centos 搜索
  • linux系统如何进入终端
  • RegSrvc.exe - RegSrvc是什么进程 有什么用
  • win7系统通知
  • -f linux命令
  • win10开始菜单怎么打开
  • Ver、Vol、Ctty命令的使用教程
  • 如何检查自己是否抑郁
  • javascript 加法
  • python 备份文件夹
  • 专项附加扣除当月填报何时生效
  • 党建服务中心属于哪个区
  • 买车险代收车船税合法吗
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设