验证 system_other 分区

实现

搭载 Android 9 及更低版本且具有 A/B 分区的 Android 设备可以使用不活跃的 system_other 分区(例如,当 slot_a 处于活跃状态时,system_b 闲置)存储预优化的 VDEX/ODEX 文件。使用 system_other 时,ro.cp_system_other_odex 被设置为 1,以便软件包管理器服务设置 sys.cppreopt=requested,使 cppreopts.rc 能对其执行操作。

Android 10 中引入了 libfs_avb,以便支持对 system_other 分区进行独立的 AVB 验证。此类分区的 VBMeta 结构体附加在分区末尾,将由文件系统中的预期公钥验证。Android 构建系统支持对 system_other.img 签名,并将相应的签名密钥包含在 /product/etc/security/avb/system_other.avbpubkey 下。发布工具 sign_target_files_apks.py 还支持将签名密钥替换为发布版本。

如果 A/B 设备搭载的 Android 版本低于 Android 10,即便升级到 Android 10 并将 PRODUCT_RETROFIT_DYNAMIC_PARTITIONS 设置为 true,也具有一个 system_other 物理分区。

搭载 Android 10 的 A/B 设备必须具有一个 system_other 逻辑分区。以下示例显示了对 system_other 启用 AVB 的典型 fstab.postinstall 文件。

#<dev> <mnt_point> <type>  <mnt_flags options>  <fs_mgr_flags>
system /postinstall ext4 ro,nosuid,nodev,noexec
slotselect_other,logical,avb_keys=/product/etc/security/avb/system_other.avbpubkey

需要对 system_other 分区启用 AVB 的设备应将 fstab 文件放到产品分区中,并将属性 ro.postinstall.fstab.prefix 设置为 /product

# Use /product/etc/fstab.postinstall to mount system_other. PRODUCT_PRODUCT_PROPERTIES += \
ro.postinstall.fstab.prefix=/product

PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/fstab.postinstall:$(TARGET_COPY_OUT_PRODUCT)/etc/fstab.postinstall