自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
ModuleMetadata
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
ModuleMetadata 模块包含指定设备上模块列表的元数据。系统会在系统服务器启动后立即解析并缓存这类元数据。
ModuleMetadata APK 包含 ModuleInfoProvider
,后者用于实现 PackageManager API 中的 getModuleInfo
和 getInstalledModules
方法。这些方法由从模块元数据提供程序软件包解析的 XML 元数据提供支持。模块元数据软件包的软件包名称存储在 config_defaultModuleMetadataProvider
配置值中。
模块元数据提供程序必须包含其 <application>
标记的 <metadata>
条目。元数据条目必须包含单个键 (android.content.pm.MODULE_METADATA
),该键的值是对 XML 资源的引用,后者包含指定设备上模块列表的元数据。
ModuleMetadata 模块 (com.android.modulemetadata
) 以 APK 文件的形式提供。
XML 文档必须由具有一个或多个子项的单个顶级 <module-metadata>
元素组成。每个子项都是一个 <module>
元素,包含以下属性:
name
是对用户可见的软件包名称的资源引用,映射到 ModuleInfo#getName
。
packageName
是模块的软件包名称,映射到 ModuleInfo#getPackageName
。
isHidden
表示模块是否已隐藏,映射到 ModuleInfo#isHidden</code>.
。
示例:
<module-metadata>
<module name="@string/resource" packageName="package_name" isHidden="false|true">
<module .... >
</module-metadata>
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# ModuleMetadata\n\nThe ModuleMetadata module contains metadata about the list of modules on a\ngiven device. The metadata is parsed and cached as soon as the system server\nstarts.\n\nChanges in Android 10\n---------------------\n\nThe ModuleMetadata APK contains `ModuleInfoProvider`, which\nimplements the `getModuleInfo` and `getInstalledModules`\nmethods from the PackageManager's API. These methods are backed\nby XML metadata parsed from a module metadata provider package. The package\nname for the module metadata package is stored in the\n`config_defaultModuleMetadataProvider` config value.\n\nThe module metadata provider must contain a `\u003cmetadata\u003e`\nentry for its `\u003capplication\u003e` tag. The metadata entry must\ncontain a single key (`android.content.pm.MODULE_METADATA`) whose\nvalue is a reference to an XML resource that contains metadata about the list\nof modules on a given device.\n\nPackage format\n--------------\n\nThe ModuleMetadata module (`com.android.modulemetadata`) is delivered\nas an APK file.\n\nMetadata elements\n-----------------\n\nThe XML document must consist of a single top level `\u003cmodule-metadata\u003e`\nelement with one or more children. Each child is a `\u003cmodule\u003e`\nelement that contains the following attributes:\n\n- `name` is a resource reference to a user-visible package name. Maps to `ModuleInfo#getName`.\n- `packageName` is the package name of the module. Maps to `ModuleInfo#getPackageName`.\n- `isHidden` indicates whether the module is hidden. Maps to `ModuleInfo#isHidden\u003c/code\u003e.`\n\nExample: \n\n \u003cmodule-metadata\u003e\n \u003cmodule name=\"@string/resource\" packageName=\"package_name\" isHidden=\"false|true\"\u003e\n \u003cmodule .... \u003e\n \u003c/module-metadata\u003e"]]