当前位置:   article > 正文

Android R(11)为自定义HIDL接口添加DM&&FCM(六)_device_framework_compatibility_matrix_file

device_framework_compatibility_matrix_file

为自定义HIDL接口添加DM&&FCM(六)

1.概览

  引入HIDL的一个重要原因是Android团队想要将Android Framework和Android vendor之间的代码进行解耦,即franmework不依赖于vendor的代码,如此Android团队在开发franework的时候就可以屏蔽底层的硬件差异了。在面向对象编程中提倡基于接口编程其实也是这个思想,调用者并不直接调用实现类提供的接口,而是通过事先定义好的接口进行调用/实现。为了实现framework和vendor解耦,Android引入了VINTF object(Vendor Interface Object)。接下来要讲的DM(device manifest)和FCM(Framework Compatibility Matrixes)则属于VINTF object的一部分。
  VINTF object则是用于framework告知vendor其想要什么,以及vendor告知framework它有什么。下面看下它们的关系图。
在这里插入图片描述

VINTF object 的涉及主要涉及的功能如下:
  对于vendor
    a) Defines a schema for the static component.(the device manifest file).
    b) Adds build time support for defining the device manifest file for a given device.
    c) Defines the queryable API at runtime that retrieves the device manifest file (along with the other runtime-collectible information) and packages them into the query result.
  对于framework
    a) Defines a schema for the static component (the framework manifest file).
    b) Defines the queryable API at runtime that retrieves the framework manifest file and packages it into the query result.

2.设备清单-Manifests

   一个VINTF object数据由来自device manifest 和 framework manifest files 的所匹配的信息组成,例如DM中提供的和FCM所要求的组件成功匹配上的一例。
  Device Manifests由厂商维护,其中包含vendor Manifests 和 ODM Manifests两个部分。
Device Manifests
  The vendor manifest specifies HALs, SELinux policy versions, etc. common to an SoC. It is recommended to be placed in the Android source tree at device/VENDOR/DEVICE/manifest.xml, but multiple fragment files can be used.
ODM Manifests
  The ODM manifest lists HALs specific to the product in the ODM partition.

3.兼容矩阵-Compatibility Matrixes

  FCM 用于描述 framework 在运行时所需要的组件。FCM又分为SCM(system compatibilty matrix),PCM(product compatibility matrix)和 SECM(system_ext compatibility matrix)。 被列出在FCM的组件则静态的写入xml文件中,并且Android在编译、运行以及做VTS测试的时候都会检测设备能否满足FCM的要求。

4.ICustomHardware的 DM

4.1 在Android.bp中添加DM信息

//file:test/flagstaffTest/hardware/interfaces/custom_hardware/1.0/default/Android.bp
cc_binary {
    name: "flagstaff.hardware.custom_hardware@1.0-service",
    ...
    vintf_fragments: ["flagstaff.hardware.custom_hardware@1.0.xml"],
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

4.2 flagstaff.hardware.custom_hardware@1.0.xml

//file:test/flagstaffTest/hardware/interfaces/custom_hardware/1.0/default/flagstaff.hardware.custom_hardware@1.0.xml
<manifest version="1.0" type="device">
    <hal format="hidl">
        <name>flagstaff.hardware.custom_hardware</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>ICustomHardware</name>
            <instance>default</instance>
            <instance>custom</instance>
        </interface>
    </hal>
</manifest>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

  此处的DM信息说明,vendor侧提供了2个版本1.0接口ICustomHardware的实现,其分别是default和custom。在使用时可以使用如下方法选择获取对应实例

//获取default实例
android::sp<ICustomHardware> instance = ICustomHardware::getService();
//获取custom实例
android::sp<ICustomHardware> custom = ICustomHardware::getService("custom");
  • 1
  • 2
  • 3
  • 4

5.ICustomHardware的FCM

5.1 将FCM添加到Android编译系统

//file:test/flagstaffTest/device.mk
DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE += \
        test/flagstaffTest/compatibility_matrix/framework_compatibility_matrix.xml

  • 1
  • 2
  • 3
  • 4

5.2 framework_compatibility_matrix.xml

//file:test/flagstaffTest/compatibility_matrix/framework_compatibility_matrix.xml
<compatibility-matrix version="2.0" type="framework">
    <hal format="hidl" optional="true">
        <name>flagstaff.hardware.custom_hardware</name>
        <version>1.0</version>
        <interface>
            <name>ICustomHardware</name>
            <instance>default</instance>
            <instance>custom</instance>
        </interface>
    </hal>
</compatibility-matrix>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

  此处的FCM信息说明,framework需要版本为1.0接口ICustomHardware的两个实现,其分别是default和custom。但是此处的optional为true意味着该组件为可选,所以即使不提供对应的DM的话也不影响系统编译运行测试的。
  另外如果有问题,欢迎留言或者email(836190520@qq.com)我,技术升级在于交流~~

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/256009
推荐阅读
相关标签
  

闽ICP备14008679号