背景:
同学们在做车载相关的开发时候,在国内一般参考资料可能都是一些别人写的blog居多,当时这种毕竟不属于一手官方知识。很多同学可能也会到google官网去看相关的一些文章说明,具体网址如下:
https://source.android.google.cn/docs/automotive/guidelines?hl=zh-cn
但是说实话这个官方信息相对还是比较零散而且比较集中几个模块,对于刚刚接触Car Framework开发同学来说并不是那么友好,所以看官方网站内容其实并不适合新手学Car Framework进行入门。
今天马哥给大家分享一个非常适合刚开始从手机framework转到car framework开发的文档,该文档还是google 合作伙伴partner的官方培训文档。
文档部分内容展示:
Car Framework的整体架构,可以图中看出本质上就是在手机的架构基础上加入了额外的Car Serivce部分的服务,这个服务主要主要用来处理和车相关的一些定制操作。下面列出了传统手机的安卓架构和安卓车载AAOs架构区别
Difference between the Traditional Android Stack
and the Car Stack:
● Car-specific apps use Car APIs to access functionality
implemented by Car Service.
● Car Service communicates with the System Server via
CarServiceHelperService to access core Android
functionalities.
● CarServiceHelperService’s main purpose is to start Car
service. However, CSHS is used when there is no specified
API to communicate with System Server.
● Car Service also connects to car-specific native services
such as CarWatchdog. These services handle Car-specific
tasks before the system server and Car Service are intialized.
● Car hardware is abstracted away using Vehicle HALs and
car-specific HALs.
总结就是车载系统的架构不仅仅可以运行标准手机那种app,也可以运行特定使用Car API开发的App,同时也详细介绍了Car Service相关作用,及它设计的车相关的一些HAL等服务,和传统安卓系统SystemServer的连接方式等。
详细介绍Car Service and Car ManagersCommunication between Apps and Car Service
The Car SDK contains Car.java and other public classes. Any app can
create a Car object. A client app will use the Car object to retrieve
different managers (ex. CarUserManager, CarPowerManager).
● Internally, Car Service is an Android Service. It implements ICar.aidl in
ICarImpl. Any app or service that connects to Car Service will receive an
ICar binder object. The Car object will contain an ICar binder object to
communicate with ICarImpl.
● When the onServiceConnected callback completes for Car object it will
receive an ICar binder object.
● Every Car Manager will have a binder for its corresponding component.
For example, CarUserManager will connect to CarUserService using
ICarUserService.aidl.
● Important Note: Every service within Car Service is not a separate
process, but a separate object within the Car Service process.Communication between Car.java and Car Service
● The Car object receives the ICar binder object after the
onServiceConnected callback completes.
● The Car object communicates with Car Service via the ICar
binder object.
Communication between Car Service
and System Server
● CarServiceHelperService’s main purpose is
to initialize Car Service.
● When the onServiceConnected callback completes,
CarServiceHelperService will receive an ICar binder object
as well to communicate with the Car Service process.
How the Car API Works
Accessing Car APIsWhat actually happens?
Car Service 详细剖析解释
● Car Service is launched by System Server via CarServiceHelperService
during the device boot phase.
● If CarService crashes, it will be restarted.
● CarXXXServices are initialized sequentially during Car Service init.
● See ‘CarService.initAllServices’ trace in logcat.
● Car Service runs as ‘com.android.car’ process and is highly privileged.
● All permission checks for Car APIs are performed in Car Service.
● The majority of Car API business logic is implemented within Car Service.
● Car Service depends on multiple HALs, e.g. audio HAL, vehicle HAL etc.
and a few native daemons, e.g. car watchdog daemon and car power
policy daemon.
其他更多详细的文档内容就不一一展示了,相关文档马哥会分享到vip群内,大家自行阅读哈。
原文地址:
https://mp.weixin.qq.com/s/1BaQQGp9NsCOVbat2LYv4w