1.需求
解决系统升级困难的问题(模块化)
a.以前用.h头文件的形式,各自Vendor有各自的so去实现硬件功能。
现在改成.hal文件的形式(Binder化),类似.aidl.
Thegoal of HIDL is that the framework can be replaced without having torebuild HALs. HALs will be built by vendors or SOC makers and put ina /vendor partitionon the device, enabling the framework, in its own partition, to bereplaced with an OTA without recompiling the HALs.
b.以前的输出打包进system里的一个个so
现在整个Vendor的东西应该是单独的一个啥?是一个vendor.img(里头有so),那么系统升级的时候,system.img就可以单拿出来。不用找各个硬件供应商,就可以用升级过的system.img去做替换升级
如图所示(图画的比较丑,抱歉)
屁话少说,放码过来。
「Talk is cheap. Show me the code」
RadioDemo中
CarAudioManger的初始化
//从CarService中取出Audio的
mCarAudioManager = (CarAudioManager) mCarApi.getCarManager(android.car.Car.AUDIO_SERVICE);
请求AudioFocus
mCarAudioManager.requestAudioFocus(this, mRadioAudioAttributes,AudioManager.AUDIOFOCUS_GAIN, 0);
//requestAudioFocus@CarAudioManger
mAudioManager.requestAudioFocus
好吧,和普通手机的一样,本集终!
看看最常用的setStreamVolume吧
mCarAudioManager.setStreamVolume(mStreamType, progress, AudioManager.FLAG_PLAY_SOUND);
//setStreamVolume@CarAudioService.java
//检查Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME权限
enforceAudioVolumePermission();
mVolumeService.setStreamVolume(streamType, index, flags);
//setStreamVolume@CarVolumeService
getController().setStreamVolume(streamType, index, flags);
//工厂
mCarVolumeController = CarVolumeControllerFactory.createCarVolumeController(mContext,mAudioService, mAudioHal, mInputService);
CarVolumeController是CarVolumeSer