InstrumentClusterRenderingService 使用解析
InstrumentClusterRenderingService
InstrumentClusterRenderingService类为Android Car下car-lib目录下的api接口。主要是提供仪表盘渲染效果的服务。但是这个类使用的API解释得比较复杂,所以这里单独做一下解析。
首先,该类处于Car API目录下,属于直接提供给APP使用的接口,同时在Car-Service中也存在一个极为类似的类InstrumentClusterService,该类处于Car SERVICE层中,与android 原生中ANDROID SYSTEM SERVICES 同层级,并相互调用。
解析相关类
那么我们先来看google是怎么解释得。首先是InstrumentClusterRenderingService
,官方的解释文档
* A service that used for interaction between Car Service and Instrument Cluster. Car Service may
* provide internal navigation binder interface to Navigation App and all notifications will be
* eventually land in the {@link NavigationRenderer} returned by {@link #getNavigationRenderer()}.
*
* <p>To extend this class, you must declare the service in your manifest file with
* the {@code android.car.permission.BIND_INSTRUMENT_CLUSTER_RENDERER_SERVICE} permission
* <pre>
* <service android:name=".MyInstrumentClusterService"
* android:permission="android.car.permission.BIND_INSTRUMENT_CLUSTER_RENDERER_SERVICE">
* </service></pre>
* <p>Also, you will need to register this service in the following configuration file:
* {@code packages/services/Car/service/res/values/config.xml}
翻译一下意思:
InstrumentClusterRenderingService用于Car Service和汽车组合仪表之间的交互。Car Service将为导航应用提供内部导航代理接口,并且所有的通知将展示在NavigationRenderer上,并且通过getNavigationRenderer()可以返回对应的NavigationRenderer。继承该类时,需要在manifest文件下声明该service,并且需要获取android.car.permission.BIND_INSTRUMENT_CLUSTER_RENDERER_SERVICE权限,获取方式:
<service android:name=".MyInstrumentClusterService" android:permission="android.car.permission.BIND_INSTRUMENT_CLUSTER_RENDERER_SERVICE">
service>
并且,你将需要在以下目录:packages/services/Car/service/res/values/config.xml注册该服务。
可以看出该类主要用途在于实现Car service层与Car API层中仪表模块的交互,并处理仪表相关的通知功能。
其次,InstrumentClusterService类,先看官方解释
Service responsible for interaction with car's instrument cluster.
翻译过来就是:
负责与汽车仪表盘交互的服务。
也就是说此类主要是服务提供,实现Car service层相关功能。