Android Car

一、Android Car介绍

Android Automotive是Android的一部分。 Android Automotive不是Android的分支或并行开发,它与手机,平板电脑等安卓设备上的Android具有相同的代码库,并且位于相同的存储库中。 它基于经过10多年开发的强大平台和功能集,可利用现有的安全模型,兼容性程序,开发人员工具 和基础架构,同时继续具有高度可定制性和可移植性,完全免费和开源的特点。Android Automotive扩展了Android 。在将Android打造为功能齐全的信息娱乐平台的过程中,添加了对汽车特定要求,功能和技术的支持。

Android Automotive 是在原先Android的系统架构上增加了一些与车相关的模块:

1)Car App :包括OEM和第三方开发的App

2)Car API :提供给汽车App特有的接口

3)Car Service :系统中与车相关的服务,主要基于CarProperty实现Vechile相关的策略

4)Vehicle Network Service :汽车的网络服务

5)Vehicle HAL :汽车的硬件抽象层描述,定义 OEM 可以实现的车辆属性的接口

1、CarAPI

Car API是Android系统中使用Android Automotive特性的系统接口,Car API与CarService中的服务,名称上存在对应关系,所以很好理解。例如:CarWatchdogManager对应CarWatchdogService,CarMediaManager对应CarMediaService。不过也有例外:CarInfoManager、CarSensorManager、CarHvacManager、CarCabinManager、CarVendorExtensionManager都对应CarPropertyService。但是在Android 11中这些Manager都已经过时,Google建议统一使用CarPropertyManager。

2、CarService

车载Android 系统的核心服务之一,所有应用都需要通过 CarService 来查询、控制整车的状态。例如:车辆的速度、档位、点火状态等等,CarService有许多子服务,负责具体功能。

Service端 功能 Client端

AppFocusService

应用程序焦点服务:确保一次只有一个应用程序类型的实例处于活动状态。

CarAppFocusManager

CarAudioService

汽车音频服务:负责与汽车音响系统交互的服务。

CarAudioManager

CarPowerManagerService

汽车电源管理服务:汽车电源管理服务。控制电源状态并与系统的其他部分交互以确保其自身状态。

CarPowerManager

CarPropertyService

汽车属性服务:此类实现 ICarProperty 的binder接口。有助于更容易地创建处理车辆属性的多个Manager。

CarPropertyManager

CarProjectionService

汽车投屏服务

CarProjectionManager

CarPackageManagerService

汽车包管理服务

CarPackageManager

CarDiagnosticService

汽车诊断服务

CarDiagnosticManager

CarProjecitonService

汽车投屏服务

CarProjecitonManager

CarMediaService

汽车媒体管理服务

CarMediaManager

CarConfigurationService

汽车配置服务

CarConfigurationManager

CarBluetoothService

汽车蓝牙服务

CarBluetoothManager

CarDrivingStateService

汽车驾驶状态服务:推断车辆当前驾驶状态的服务。它通过侦听 CarPropertyService 的相关属性来计算驾驶状态。

CarDrivingStateManager

CarStorageMonitoringService

汽车存储监控服务

CarStorageMonitoringManager

CarMediaService

汽车媒体服务:管理汽车应用程序的当前活动媒体源。这与 MediaSessionManager 的活动会话不同,因为同一时间内车内只能有一个活动源。

CarMediaManager

CarInputService

汽车输入服务:通过车辆HAL监控和处理输入事件。

CarInputManager

CarLocationService

汽车定位服务:此服务在车辆停放时存储 LocationManager 中最后一个已知位置,并在车辆通电时恢复该位置。

CarLocationManager

CarEvsService

汽车摄像头服务

CarEvsManager

CarTelemetryService

汽车电话服务

CarTelemetryManager

CarDevicePolicyService

汽车设备策略服务

CarDevicePolicyManager

CarActivityService

汽车活动服务

CarActivityManager

CarPerformanceService

汽车性能服务

CarPerformanceManager

CarWatchdogService

汽车看门狗服务:实现 CarWatchdogManager API的服务。 CarWatchdogService 作为汽车监控中介运行,它检查客户端的健康状况,并将结果报告给汽车监控服务器。

CarWatchdogManager

CarTestService

汽车测试服务:允许测试/模拟车辆HAL的服务。该服务直接使用车辆HAL API,因为车辆HAL模拟无论如何都需要直接访问该级别。

CarTestManager

CarUXRestrictionsService

汽车用户体验限制服务

CarUXRestrictionsManager

CarOccupantZoneService

汽车乘员区服务

CarOccupantZoneManager

CarBugreportManagerService

汽车错误报告管理器服务

CarBugreportManager

CarUserService

汽车用户服务

CarUserManager

CarUserNoticeService

向用户显示初始通知UI的服务:它仅在启用设置时启动它,并根据用户的请求通知UI自行关闭。

CarUserNoticeManager

ClusterHomeService

仪表Hoem服务

ClusterHomeManager

ClusterNavigationService

仪表导航服务

ClusterNavigationManager

OccupantAwarenessService

跨HAL边界侦听乘员感知检测系统的服务

OccupantAwarenessManager

VmsBrokerService

消息代理服务,用于在客户端之间路由车辆映射服务消息, 地图导航相关

VMS客户端实现,使用HAL特定消息编码将VmsPublisher/VmsSubscriber API调用代理到车辆HAL。

-

3、Vehicle HAL

用于处理车辆相关数据,底层通过RPC通信接收MCU数据和发送数据给MCU,作为CarPropertyService和CarPowerManagerService的底层实现电源控制与车辆属性控制功能。

二、Android汽车子系统相关类

1、CarService

CarService是车载Android系统的核心服务之一,所有应用都需要通过CarService来查询、控制整车的状态。不仅仅是车辆控制,实际上CarService几乎就是整个车载Framework最核心的组件。提供了一系列的服务与HAL层的VehicleHAL通信,进而通过车载总线(例如CAN总线)与车身进行通讯,同时它们还为应用层的APP提供接口,从而让APP能够实现对车身的控制与状态的显示。

CarService代码位于:

packages/services/Car/car-lib/src/android/car/ICar.aidl

packages/services/Car/service/src/com/android/car/ICarImpl.java

packages/services/Car/service/src/com/android/car/CarServiceBase.java

packages/services/Car/service/src/com/android/car/CarServiceUtils.java

packages/services/Car/service/src/com/android/car/CarServiceImpl.java

packages/services/Car/service-builtin/src/com/android/car/CarService.java

frameworks/opt/car/services/builtInServices/src/com/android/internal/car/CarServiceHelperService .java

CarService的定义:

interface ICar {}
public interface CarServiceBase {}
public final class CarServiceUtils {}
public class ICarImpl extends ICar.Stub {}
public class CarService extends ServiceProxy {}
public class CarServiceImpl extends ProxiedService {}
public class CarServiceHelperService extends SystemService implements Dumpable, DevicePolicySafetyChecker, CarServiceHelperInterface {}

2、SystemInterface

此类包含对CarService 和 Android OS API。

SystemInterface代码位于:packages/services/Car/service/src/com/android/car/systeminterface/SystemInterface.java

SystemInterface的定义:

public class SystemInterface implements ActivityManagerInterface,
        DisplayInterface, IOInterface, StorageMonitoringInterface,
        SystemStateInterface, TimeInterface,
        WakeLockInterface {}

三、CarService配置

需要根据OEM需要对CarService进行配置,配置文件路径为packages/services/Car/services/res/values/config.xml,配置内容如下:

audioUseDynamicRouting:Configuration to enable usage of dynamic audio routing.

audioUseCarVolumeGroupMuting:Configuration to enable muting of individual volume groups.

audioUseHalDuckingSignals:Configuration to enable IAudioControl#onDevicesToDuckChange API to inform HAL when to duck.

audioVolumeAdjustmentContextsVersion:Configuration to select version of volume adjustment context priority list.

audioPersistMasterMuteState:Configuration to persist global mute state.

audioVolumeKeyEventTimeoutMs:Configuration to indicate the timeout in milliseconds while a car volume group will be considered active for volume control changes during volume key events.

displayOffMuteLockAllAudio:Whether to block other audio while media audio is muted with display off. When set to true, other sounds cannot be played either while display is off.

useDefaultBluetoothConnectionPolicy:Configuration to enable or disable the default Bluetooth Device Connection Policy.

useDefaultBluetoothPowerPolicy:Configuration to enable or disable the default Bluetooth Power Policy.

instrumentClusterRendererService:Service responsible for displaying information on the car instrument cluster.

config_clusterHomeActivity:The name of Activity who is in charge of ClusterHome.

rotaryService:Service responsible for handling the rotary controller input.

enableActivityBlockingForSafety:Whether to enable Activity blocking for safety.

activityBlockingActivity:Activity to be presented when un-safe activity is launched.

continuousBlankActivity:

activityAllowlist:Comma separated list of activities that need to be exempted from getting blocked in a UX restricted state.

systemActivityAllowlist:Comma separated list of activities that need to be exempted from getting blocked in a UX restricted state.

activityDenylist:Comma separated list of activities that will be blocked during restricted state.

defaultHomeActivity:Default home activity

vmsHalClientMetricsProperty:The vendor-defined HAL property used to collect VMS client metrics. Disabled by default.

vmsPublisherSystemClients:The com.android.car.vms.VmsClientManager will bind to this list of clients running as system user

vmsPublisherUserClients:The com.android.car.vms.VmsClientManager will bind to this list of clients running as current user

millisecondsBeforeRebindToVmsPublisher:Number of milliseconds to wait before trying re-bind to a crashed publisher.

accept

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值