由平台签名的共享 UID 许可名单

由平台签名的应用是指采用相同(或兼容)签名的应用 带有平台软件包 (android) 的证书。由平台签名的应用 系统应用(位于系统映像分区中)或非系统应用。 由平台签名的共享 UID 是指符合以下条件的共享 UID (android:sharedUserId): 包含由平台签名的应用。可调试 build 是指 android.os.Build.isDebuggable() 会返回 true,例如 userdebugeng build。

过去,设备制造商几乎无法控制 非系统应用可以加入由平台签名的共享 UID。从 Android 设备开始 15,制造商可以明确允许由平台签名的 将非系统应用加入系统配置中由平台签名的共享 UID /etc/permissions 目录中的 XML 文件。如果由平台签名的非系统 应用未添加到由平台签名的共享 UID 的许可名单中,并且该应用 仍会尝试加入由平台签名的共享 UID(使用 android:sharedUserId) (位于清单中),因此该应用无法安装在不可调试的 build 上。

添加许可名单

您可以在单个或多个 XML 文件中列出应用的许可名单。 类似于 frameworks/base/data/etc/package-shareduid-allowlist.xml:

<!--
This XML defines an allowlist for packages that want to join a particular shared-uid.
If a non-system package that is signed with platform signature, is trying to join a particular
shared-uid, and not in this list, the installation will fail.

- The "package" XML attribute refers to the app's package name.
- The "shareduid" XML attribute refers to the shared uid name.
  -->

<config>
    <allow-package-shareduid package="android.test.settings" shareduid="android.uid.system" />
</config>

查找缺失的许可名单

如需查找缺失的许可名单条目,请尝试安装由平台签名的非系统 应用,并检查它是否仍可安装。否则, 可以检查设备日志中是否存在以下格式的警告消息:

Non-preload app {PACKAGE_NAME} signed with platform signature and joining shared uid: {SHARED_UID_NAME}