AAOS车载开发GOOGLE官方培训文档Car Framework Core
背景同学们在做车载相关的开发时候在国内一般参考资料可能都是一些别人写的blog居多当时这种毕竟不属于一手官方知识。很多同学可能也会到google官网去看相关的一些文章说明具体网址如下https://source.android.google.cn/docs/automotive/guidelines?hlzh-cn但是说实话这个官方信息相对还是比较零散而且比较集中几个模块对于刚刚接触Car Framework开发同学来说并不是那么友好所以看官方网站内容其实并不适合新手学Car Framework进行入门。今天马哥给大家分享一个非常适合刚开始从手机framework转到car framework开发的文档该文档还是google 合作伙伴partner的官方培训文档。文档部分内容展示Car Framework的整体架构可以图中看出本质上就是在手机的架构基础上加入了额外的Car Serivce部分的服务这个服务主要主要用来处理和车相关的一些定制操作。下面列出了传统手机的安卓架构和安卓车载AAOs架构区别Difference between the Traditional Android Stackand the Car Stack:● Car-specific apps use Car APIs to access functionalityimplemented by Car Service.● Car Service communicates with the System Server viaCarServiceHelperService to access core Androidfunctionalities.● CarServiceHelperService’s main purpose is to start Carservice. However, CSHS is used when there is no specifiedAPI to communicate with System Server.● Car Service also connects to car-specific native servicessuch as CarWatchdog. These services handle Car-specifictasks before the system server and Car Service are intialized.● Car hardware is abstracted away using Vehicle HALs andcar-specific HALs.总结就是车载系统的架构不仅仅可以运行标准手机那种app也可以运行特定使用Car API开发的App同时也详细介绍了Car Service相关作用及它设计的车相关的一些HAL等服务和传统安卓系统SystemServer的连接方式等。详细介绍Car Service and Car ManagersCommunication between Apps and Car ServiceThe Car SDK contains Car.java and other public classes. Any app cancreate a Car object. A client app will use the Car object to retrievedifferent managers (ex. CarUserManager, CarPowerManager).● Internally, Car Service is an Android Service. It implements ICar.aidl inICarImpl. Any app or service that connects to Car Service will receive anICar binder object. The Car object will contain an ICar binder object tocommunicate with ICarImpl.● When the onServiceConnected callback completes for Car object it willreceive an ICar binder object.● Every Car Manager will have a binder for its corresponding component.For example, CarUserManager will connect to CarUserService usingICarUserService.aidl.● Important Note: Every service within Car Service is not a separateprocess, 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 theonServiceConnected callback completes.● The Car object communicates with Car Service via the ICarbinder object.Communication between Car Serviceand System Server● CarServiceHelperService’s main purpose isto initialize Car Service.● When the onServiceConnected callback completes,CarServiceHelperService will receive an ICar binder objectas well to communicate with the Car Service process.How the Car API WorksAccessing Car APIsWhat actually happens?Car Service 详细剖析解释● Car Service is launched by System Server via CarServiceHelperServiceduring 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 powerpolicy daemon.其他更多详细的文档内容就不一一展示了相关文档马哥会分享到vip群内大家自行阅读哈。原文地址https://mp.weixin.qq.com/s/1BaQQGp9NsCOVbat2LYv4w