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

  • 企业微信定位权限设置在哪里(企业微信定位权限设置在哪里苹果手机)

    企业微信定位权限设置在哪里(企业微信定位权限设置在哪里苹果手机)

  • 通话中断00接通了没(通话中断0.0)

    通话中断00接通了没(通话中断0.0)

  • 天猫精灵可以连接话筒唱歌吗(天猫精灵可以连接手机热点吗)

    天猫精灵可以连接话筒唱歌吗(天猫精灵可以连接手机热点吗)

  • 华为手机显示一半屏幕(华为手机显示一个迈速表)

    华为手机显示一半屏幕(华为手机显示一个迈速表)

  • 华为荣耀9x是多少瓦快充(华为荣耀9x是多少寸的手机)

    华为荣耀9x是多少瓦快充(华为荣耀9x是多少寸的手机)

  • 微信设置仅聊天怎么设置(微信设置仅聊天给别人点赞能看见吗)

    微信设置仅聊天怎么设置(微信设置仅聊天给别人点赞能看见吗)

  • 苹果11白色用久了会发黄吗(苹果11白色会变色吗)

    苹果11白色用久了会发黄吗(苹果11白色会变色吗)

  • 联想小新开机键在哪(联想小新开机键一闪一闪)

    联想小新开机键在哪(联想小新开机键一闪一闪)

  • qq长期不绑定手机号会怎样(qq号不绑定手机号会被系统收回吗)

    qq长期不绑定手机号会怎样(qq号不绑定手机号会被系统收回吗)

  • 华为手机无法启用相机闪退(华为手机无法启动4G怎么办)

    华为手机无法启用相机闪退(华为手机无法启动4G怎么办)

  • 对方微信变成null(对方微信变成灰色头像)

    对方微信变成null(对方微信变成灰色头像)

  • 苹果手机连上wifi老是掉线怎么回事(苹果手机连上wifi却看不到图标)

    苹果手机连上wifi老是掉线怎么回事(苹果手机连上wifi却看不到图标)

  • 无线网一会卡一会流畅(无线网一会卡一会不卡电脑正常)

    无线网一会卡一会流畅(无线网一会卡一会不卡电脑正常)

  • 华为网络正常app连不上网络(华为网络正常,唯独刷视频加载不出来)

    华为网络正常app连不上网络(华为网络正常,唯独刷视频加载不出来)

  • 小米8为什么截长屏点不了(小米为什么截长屏点不了)

    小米8为什么截长屏点不了(小米为什么截长屏点不了)

  • 连接服务器超时什么意思(apex为什么连接服务器超时)

    连接服务器超时什么意思(apex为什么连接服务器超时)

  • 朋友圈的内容如何设置让部分人看到(朋友圈的内容如何重发)

    朋友圈的内容如何设置让部分人看到(朋友圈的内容如何重发)

  • soul对话框绿点啥意思(soul聊天页面的绿点是啥意思)

    soul对话框绿点啥意思(soul聊天页面的绿点是啥意思)

  • ios13和13.1有什么区别(ios13.3.1和13.6对比)

    ios13和13.1有什么区别(ios13.3.1和13.6对比)

  • 转转如何退款(转转如何退款成功?)

    转转如何退款(转转如何退款成功?)

  • 鸿蒙系统怎么同时打开两个应用?鸿蒙同时开两个应用方法(鸿蒙系统怎么同步数据)

    鸿蒙系统怎么同时打开两个应用?鸿蒙同时开两个应用方法(鸿蒙系统怎么同步数据)

  • uniapp实现微信支付、支付宝支付(uniapph5微信支付)

    uniapp实现微信支付、支付宝支付(uniapph5微信支付)

  • 什么是反避税税率
  • 开红字发票需要收回原发票吗
  • 监控系统维护费计入什么科目
  • 定额的个体户需要汇算清缴吗
  • 普通增值税发票税号
  • 买车的报税联是什么作用
  • 技术服务费怎么开票税率
  • 支付无法取得发票的赔偿金可否税前扣除
  • 全面解析来料加工企业账务处理
  • 库存商品进项税额转出分录怎么写
  • 库存盘盈盘亏按进价还是售价
  • 农业企业土地租赁费账务处理
  • 公司还没有核税该如何进行业务汇款?
  • 携税宝可以全额抵扣吗
  • 农行转账支票填写样本存根怎么填
  • 增值税发票如何红冲
  • 国家税务总局公告2012年第57号
  • 退税勾选后怎么申报
  • 吸收合并税费
  • 上月预付款项 这月开了发票会计分录
  • 杜邦分析法的三个核心是什么
  • 增值税降税让利给谁
  • 公益性捐赠包括向脱贫地区捐赠吗
  • 印花税纳税申报表填写范本
  • mac怎么转到苹果系统
  • 如何在Excel中计算平均值
  • 财务里计提是什么意思
  • 来料加工报废产品合同
  • 应税货物销售额怎么填
  • 以旧换新的概念
  • 蝴蝶兰的养殖方法和注意事项视频
  • framework4.0怎么打开
  • 向境外企业支付技术咨询指导费
  • 增值税专用发票查询系统官方网站
  • 设备维修的会计分录怎么做
  • 残保金解决方案
  • 公司没有车,加柴油票可以抵扣增值税吗
  • 尚未进行抄报税无法申报是什么意思
  • 帝国cms标题生成图片
  • 帝国cms适合个人用吗
  • 领取定额备用金的会计分录
  • 金税盘离线开票时间超限怎么办
  • 企业哪些增值税免征
  • 财务会计的主要目标和工作内容包括
  • 合伙企业分配利润法律依据
  • 生产成品出库的会计分录
  • 跨月开票的业务怎么做
  • 跨年发票分录
  • 收到的现金货款转到公户备注往来款可以吗
  • 内账的表格怎么做
  • 收到商业汇票计什么科目
  • 企业多结转的成本跨年怎么冲回?
  • 国内旅客运输票据可以抵扣进项税吗
  • 租房开的发票收的税如何做账?
  • 施工图审查费计入什么会计科目
  • sql server数据库跟踪
  • mysql数据库分区查询
  • Slave memory leak and trigger oom-killer
  • mysql改表名语句
  • mysql优化表命令
  • centos7创建swap分区
  • win7 如何截屏
  • win8.1系统升级
  • win10桌面上怎么分成几个区域
  • win7怎么调图片大小
  • WIN10更新失败
  • jquery的validate前端表单验证
  • jquery设计模式
  • unity3d官方教程
  • jQuery使用$.ajax提交表单完整实例
  • unity3d最新api
  • htc windows
  • 对jquery的ajax进行二次封装以及ajax缓存代理组件:AjaxCache详解
  • Android自定义动画
  • 城乡医保怎么看有没有钱
  • 税务催告期限多久
  • 陕西社保费管理客户端初始密码
  • 港澳台资企业
  • 新疆电子税务局下载app
  • 南宁地方税务局网站
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设