| <html devsite><head> |
| <title>VINTF 对象数据</title> |
| <meta name="project_path" value="/_project.yaml"/> |
| <meta name="book_path" value="/_book.yaml"/> |
| </head> |
| <body> |
| <!-- |
| Copyright 2017 The Android Open Source Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <p>VINTF 对象会在<a href="#runtime-data">运行时</a>汇总来自<a href="#device-manifest-file">设备清单</a>和<a href="#framework-manifest-file">框架清单</a>文件 (XML) 以及设备本身的数据。这两个清单共用一种格式,不过并非所有元素都适用于两者(有关结构的详细信息,请参见<a href="#manifest-file-schema">清单文件结构</a>)。</p> |
| |
| <h2 id="device-manifest-file">设备清单文件</h2> |
| <p>设备清单文件由设备提供。它在 Android 源代码树中位于 <code>device/${VENDOR}/${DEVICE}/manifest.xml</code>,在设备上位于 <code><a href="https://android.googlesource.com/platform/system/libhidl/+/master/vintfdata/manifest.xml" class="external">/vintfdata/manifest.xml</a></code>。 |
| </p> |
| |
| <p>设备清单示例:</p> |
| |
| <pre class="prettyprint"> |
| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- Comments, Legal notices, etc. here --> |
| <manifest version="1.0" type="device"> |
| <hal> |
| <name>android.hardware.camera</name> |
| <transport>hwbinder</transport> |
| <version>3.4</version> |
| <interface> |
| <name>ICameraProvider</name> |
| <instance>legacy/0</instance> |
| <instance>proprietary/0</instance> |
| </interface> |
| </hal> |
| <hal> |
| <name>android.hardware.nfc</name> |
| <transport>hwbinder</transport> |
| <version>1.0</version> |
| <version>2.0</version> |
| <interface> |
| <name>INfc</name> |
| <instance>nfc_nci</instance> |
| </interface> |
| </hal> |
| <hal> |
| <name>android.hardware.nfc</name> |
| <transport>hwbinder</transport> |
| <version>2.0</version> |
| <interface> |
| <name>INfc</name> |
| <instance>default</instance> |
| </interface> |
| </hal> |
| <hal format="native"> |
| <name>EGL</name> |
| <version>1.1</version> |
| </hal> |
| <hal format="native"> |
| <name>GLES</name> |
| <version>1.1</version> |
| <version>2.0</version> |
| <version>3.0</version> |
| </hal> |
| <sepolicy> |
| <version>25.0</version> |
| </sepolicy> |
| </manifest> |
| </pre> |
| |
| <h2 id="framework-manifest-file">框架清单文件</h2> |
| <p>框架清单文件由 Google 提供,是手动生成的文件。它在 Android 源代码树中位于 <code>system/libhidl/manifest.xml</code>,在设备上位于 <code>/system/manifest.xml</code>。</p> |
| |
| <p>框架清单(由 Google 提供)示例:</p> |
| |
| <pre class="prettyprint"> |
| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- Comments, Legal notices, etc. here --> |
| <manifest version="1.0" type="framework"> |
| <hal> |
| <name>android.hidl.allocator</name> |
| <transport>hwbinder</transport> |
| <version>1.0</version> |
| <interface> |
| <name>IAllocator</name> |
| <instance>ashmem</instance> |
| </interface> |
| </hal> |
| <hal> |
| <name>android.hidl.memory</name> |
| <transport arch="32+64">passthrough</transport> |
| <version>1.0</version> |
| <interface> |
| <name>IMapper</name> |
| <instance>ashmem</instance> |
| </interface> |
| </hal> |
| <hal> |
| <name>android.hidl.manager</name> |
| <transport>hwbinder</transport> |
| <version>1.0</version> |
| <interface> |
| <name>IServiceManager</name> |
| <instance>default</instance> |
| </interface> |
| </hal> |
| <hal> |
| <name>android.frameworks.sensorservice</name> |
| <transport>hwbinder</transport> |
| <version>1.0</version> |
| <interface> |
| <name>ISensorManager</name> |
| <instance>default</instance> |
| </interface> |
| </hal> |
| </manifest> |
| </pre> |
| |
| <h2 id="manifest-file-schema">清单文件结构</h2> |
| <dl> |
| <dt><code>?xml</code></dt> |
| <dd>可选。只向 XML 解析器提供信息。</dd> |
| <dt><code>manifest.version</code></dt> |
| <dd>必需。<strong>该</strong>清单的版本。描述清单中预期的元素。与 XML 版本无关。</dd> |
| <dt><code>manifest.type</code></dt> |
| <dd>必需。该清单的类型。对于设备清单文件,其值为 <code>device</code>;对于框架清单文件,其值为 <code>framework</code>。</dd> |
| <dt><code>manifest.hal</code></dt> |
| <dd>可选且可重复。单个 HAL(HIDL 或本机,如 GL),具体取决于 <code>format</code> 属性。</dd> |
| <dt><code>manifest.hal.format</code></dt> |
| <dd>可选。值可以是以下几项之一:<ul> |
| <li><code>hidl</code>:HIDL HAL。这是默认值。 |
| </li><li><code>native</code>:本机 HAL。</li> |
| </ul> |
| </dd> |
| <dt><code>manifest.hal.name</code></dt> |
| <dd>必需。HAL 的完全限定软件包名称。多个 HAL 条目可以使用相同的名称。示例:<ul> |
| <li><code>android.hardware.camera</code> (HIDL HAL)</li> |
| <li><code>GLES</code>(本机 HAL,只需要名称)</li> |
| </ul> |
| </dd> |
| <dt><code>manifest.hal.transport</code></dt> |
| <dd>在 <code>manifest.hal.format == "hidl"</code> 时是必需的。在其他情况下,则不得存在。指明从服务管理器查询来自该软件包的接口时将使用什么传输模式。值可以是以下几项之一:<ul> |
| <li><code>hwbinder</code>:绑定模式</li> |
| <li><code>passthrough</code>:直通模式</li> |
| </ul> |
| </dd> |
| <dt><code>manifest.hal.transport.arch</code></dt> |
| <dd>对于 <code>passthrough</code> 是必需的,对于 <code>hwbinder</code> 不得存在。描述正在提供的直通服务的位数。值可以是以下几项之一:<ul> |
| <li><code>32</code>:32 位模式</li> |
| <li><code>64</code>:64 位模式</li> |
| <li><code>32+64</code>:两者兼有</li> |
| </ul> |
| </dd> |
| <dt><code>manifest.hal.version</code></dt> |
| <dd>必需且可重复。清单中 <code>hal</code> 标记的版本。格式为 <code><var>MAJOR</var>.<var>MINOR</var></code>。有关示例,请参阅 <code>hardware/interfaces</code>、<code>vendor/${VENDOR}/interfaces</code>、<code>framework/hardware/interfaces</code> 或 <code> |
| system/hardware/interfaces</code>。 |
| <br /><br /> |
| HIDL 和本机 HAL 可以使用多个版本字段,前提是它们代表<strong>不同的主要版本</strong>,并且提供的每个主要版本只有一个次要版本。例如,3.1 和 3.2 不能共存,但 1.0 和 3.4 可以共存。这适用于所有同名的 <code>hal</code> 元素。</dd> |
| <dt><code>manifest.hal.interface</code></dt> |
| <dd>必需,可以在不重名的情况下进行重复使用。指明软件包中具有实例名称的接口。一个 <code><hal></code> 中可以有多个 <code><interface></code> 元素,但名称必须不同。</dd> |
| <dt><code>manifest.hal.interface.name</code></dt> |
| <dd>必需。接口的名称。</dd> |
| <dt><code>manifest.hal.interface.instance</code></dt> |
| <dd>必需且可重复。接口的实例名称。一个接口可以有多个实例,但不能有重复的 <code><instance></code> 元素。</dd> |
| <dt><code>manifest.sepolicy</code></dt> |
| <dd>必需。包含所有与 sepolicy 相关的条目。</dd> |
| <dt><code>manifest.sepolicy.version</code></dt> |
| <dd>对于设备清单是必需的。用于声明 sepolicy 版本。格式为 SDK_INT.PLAT_INT。<var></var><var></var></dd> |
| </dl> |
| |
| <h2 id="runtime-data">运行时数据</h2> |
| <p>设备清单所需的某些信息只能在运行时收集。信息通过 <code>::android::vintf::VintfObject::GetRuntimeInfo()</code> 获得,其中包含以下内容:</p> |
| |
| <ul> |
| <li>内核信息,包括:<ul> |
| <li><code>/proc/config.gz</code>:压缩的完整内核配置,该信息需要在运行时读取并转换为可查询的对象。</li> |
| <li><code>/proc/version</code>:通过 <code>uname()</code> 系统调用获得的信息。</li> |
| <li><code>/proc/cpuinfo</code>:对于 32 位和 64 位计算机,格式可能会不同。</li> |
| <li>policydb 版本 |
| <ul> |
| <li><code>/sys/fs/selinux/policyvers</code>(假设 <code>selinuxfs</code> 装载在 <code>/sys/fs/selinux</code> 处)。</li> |
| <li>来自 <code>libselinux</code> 的 <code>security_policyvers()</code> API 可提供相同的信息。</li> |
| </ul> |
| </li> |
| </ul> |
| </li><li>静态 libavb 版本,包括: |
| <ul> |
| <li>引导加载程序系统属性:<code>ro.boot.vbmeta.avb_version</code></li> |
| <li>init/fs_mgr 系统属性:<code>ro.boot.avb_version</code></li> |
| </ul> |
| </li> |
| </ul> |
| |
| <h2 id="queryable-api">可查询的 API</h2> |
| <p>当 <code>hwservicemanager</code>、OTA 更新服务、CTS <code>DeviceInfo</code> 以及其他组件需要从 VINTF 对象中获取信息时,该对象是作为系统 API 存在的。</p> |
| |
| <ul> |
| <li>C++ 可查询的 API 位于 <a href="https://android.googlesource.com/platform/system/libvintf/+/master/include/vintf/VintfObject.h" class="external"><code>android::vintf::VintfObject</code></a></li> |
| <li>Java 可查询 API 位于 <a href="https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/VintfObject.java" class="external"><code>android.os.VintfObject</code></a> |
| </li></ul> |
| |
| </body></html> |