位置: 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进程)

  • 成都武侯区新公司注册流程是什么(成都武侯区公安局领导)

    成都武侯区新公司注册流程是什么(成都武侯区公安局领导)

  • 微信支付分怎么用

    微信支付分怎么用

  • 荣耀手机声音小怎么处理声音变大(荣耀手机声音小了怎么恢复大声)

    荣耀手机声音小怎么处理声音变大(荣耀手机声音小了怎么恢复大声)

  • 小红书退货运费自付吗(小红书退货运费在哪里付款)

    小红书退货运费自付吗(小红书退货运费在哪里付款)

  • se2怎么截屏(se2截屏在哪设置)

    se2怎么截屏(se2截屏在哪设置)

  • 中文切换英文按什么键(中英文切换按什么)

    中文切换英文按什么键(中英文切换按什么)

  • qq4g在线和wifi在线有什么区别(qq的4g在线和wifi在线)

    qq4g在线和wifi在线有什么区别(qq的4g在线和wifi在线)

  • 联想笔记本有麦克风吗(联想笔记本麦克风说话对方听不到)

    联想笔记本有麦克风吗(联想笔记本麦克风说话对方听不到)

  • 计算机网络系统是什么的结合(计算机网络系统的基本组成)

    计算机网络系统是什么的结合(计算机网络系统的基本组成)

  • 华为mate30可以投影到墙上吗(华为mate30可以投屏到车上吗)

    华为mate30可以投影到墙上吗(华为mate30可以投屏到车上吗)

  • 手机显示有网络但是上不了网(手机显示有网络信号,但是无法连接)

    手机显示有网络但是上不了网(手机显示有网络信号,但是无法连接)

  • 拼多多商品属性怎么填(拼多多商品属性中商品证号怎么填)

    拼多多商品属性怎么填(拼多多商品属性中商品证号怎么填)

  • pr如何清理缓存文件(pr怎样清理缓存)

    pr如何清理缓存文件(pr怎样清理缓存)

  • 拼多多怎么运营(拼多多怎么运营才有流量)

    拼多多怎么运营(拼多多怎么运营才有流量)

  • iphone3d touch是什么(iphone 3d touch有什么用)

    iphone3d touch是什么(iphone 3d touch有什么用)

  • realmex屏占比(realmex2屏占比)

    realmex屏占比(realmex2屏占比)

  • 小米九耳机口在哪里(小米九耳机插孔)

    小米九耳机口在哪里(小米九耳机插孔)

  • 关闭小米画报(关闭小米画报负一屏)

    关闭小米画报(关闭小米画报负一屏)

  • 微信不可见分组怎么删除(微信不可见分组单独进入朋友圈能看见吗)

    微信不可见分组怎么删除(微信不可见分组单独进入朋友圈能看见吗)

  • vivox23电池多大毫安(vivox23的电池容量多大)

    vivox23电池多大毫安(vivox23的电池容量多大)

  • 在WIN7,为什么连不上wifi?(win7为什么现在不能用了)

    在WIN7,为什么连不上wifi?(win7为什么现在不能用了)

  • Windows7旗舰版系统解决此网站的安全证书有问题的(系统win7旗舰版)

    Windows7旗舰版系统解决此网站的安全证书有问题的(系统win7旗舰版)

  • vue-print 实现打印功能(vue实现打印)

    vue-print 实现打印功能(vue实现打印)

  • VUE项目运行失败原因以及解决办法(以vscode为例)(vue项目运行报错)

    VUE项目运行失败原因以及解决办法(以vscode为例)(vue项目运行报错)

  • vue-router路由懒加载(vue router-view路由详解)

    vue-router路由懒加载(vue router-view路由详解)

  • 土地出让价款
  • 测试费用
  • 签订合同后付款
  • 有进项发票还用交税
  • 公司出售固定资产
  • 创立一个公司,公司的运营理念
  • 利用个独企业避税犯法吗
  • 即征即退免所得税吗
  • 销售蔬菜的个体工商怎么开具发票
  • 电子设备税费
  • 即期外汇交易有幅度限制吗
  • 以前年度损益调整属于哪类科目
  • 企业破产清算怎么做账务处理实务工作
  • 出口当月开票当月申报吗
  • 固定资产丢失收入怎么办
  • 个人所得税是次月申报上月的吗怎么填
  • 电子普通发票需要盖章吗
  • 红字发票怎么申报?
  • 17税率改16税率的时间
  • 绩效奖金是否属于工资判决书
  • 咨询费属于什么大类
  • 报销业务招待费属于什么现金流量项目
  • 税前扣除是好事吗
  • 企业贷款的利息都是固定的吗
  • 如何编制处置固定资产
  • 工业增加值计算公式是什么
  • 局域网的工作模式及特点
  • 鸿蒙系统怎么快速充电
  • 个人销售自己使用过的物品免征增值税
  • 如何检查文档
  • PHP中register_shutdown_function函数的基础介绍与用法详解
  • 苹果15手机价格和图片颜色
  • 委托境外研发费用加计扣除比例
  • 固定资产未计提完毕怎么报废
  • 优先股转化
  • php获取文件内容的函数
  • pytorch基础
  • ajax调用php接口
  • 用友财务软件使用视频教程
  • 资产月报是会计报还是出纳报
  • 无形资产入股后如何处理
  • 外埠存款通过哪个会计账户核算?
  • 勘察设计费是否含税
  • 单位购日用品计提折旧吗
  • 购买公司支付的钱怎么做账
  • 纳税人填写纳税申报表
  • 发票内容类型怎么填
  • 税务文书送达期限是多少天
  • mysql 扩展
  • 社保怎么缴费方式
  • 流动资产比例大说明什么
  • 收到国家电网信息但号码不是的
  • 研发人员工资是实发还是应发
  • 子公司提的盈余公积合并时如何抵消
  • 理财中的资产是什么意思
  • 企业合并中或有对价的会计处理
  • 收到多收的款会计处理
  • 怎么开公司的微信公众号
  • 为什么预付账款是资产
  • 先收发票后付款怎么做分录
  • 结转销售成本怎么操作
  • xp系统弹出广告怎么处理
  • ubuntu如何安装
  • macbook怎么开hdr
  • windows7显示桌面的操作方法
  • xp系统超级终端机在哪
  • linux socket 常用函数小结
  • win10极限模式
  • win7升级win8.1
  • js中sort排序
  • linux怎么添加新用户
  • JavaScript驾驭网页-CSS与DOM
  • 新版unity
  • Node.js Mongodb 密码特殊字符 @的解决方法
  • javascript要学到什么程度
  • [置顶]游戏名 TentacleLocker
  • 税务总局副局长饶
  • 增值税归国家还是地方
  • 水费不用交吗
  • 建筑公司材料发票
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设