確認 system_other 分區

實作

搭載 Android 9 以下版本且具有 A/B 分區的 Android 裝置,可以使用非使用中的 system_other 分區 (例如,slot_a 處於啟用狀態時) 儲存預先最佳化的 VDEX/ODEX 檔案。system_b使用 system_other 時,套件管理員服務會將 ro.cp_system_other_odex 設為 1,以便為 cppreopts.rc 設定 sys.cppreopt=requested,並據此採取行動。

Android 10 推出 libfs_avb,支援 system_other 分區的獨立 AVB 驗證。這類分區的 VBMeta 結構體會附加至分區結尾,以供檔案系統中預期的公開金鑰驗證。Android 建構系統支援簽署 system_other.img,同時在 /product/etc/security/avb/system_other.avbpubkey 下加入對應的簽署金鑰。發布工具 sign_target_files_apks.py 也支援將發布版本的簽署金鑰替換為其他金鑰。

在 Android 10 推出前發布的 A/B 裝置具有實體 system_other 分割區,即使升級至 Android 10 時設定為 PRODUCT_RETROFIT_DYNAMIC_PARTITIONStrue 也是如此。

搭載 Android 10 的 A/B 裝置必須有邏輯 system_other 分割區。以下範例顯示典型的 fstab.postinstall 檔案,可在 system_other 上啟用 AVB。

#<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