From cf8427af89f47075953dad10d6ea9b848736527f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 4 Nov 2019 14:08:11 -0800 Subject: bootloader_message: Add helpers for handling IBootControl MergeStatus. Move merge_status from bootloader_control_ab, which is in vendor space, to a new generic AOSP struct in system space. This will allow more devices to share the same HAL implementation. This patch also changes libboot_control to compensate for merge_status moving out of vendor space. The reference HAL library now also provides separate helper functions for managing the merge status, so devices using a custom boot control HAL can still take advantage of the new misc implementation. Bug: 139156011 Test: manual test Change-Id: I5cd824e25f9d07aad1476301def5cdc3f506b029 --- .../include/libboot_control/libboot_control.h | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'boot_control/include/libboot_control/libboot_control.h') diff --git a/boot_control/include/libboot_control/libboot_control.h b/boot_control/include/libboot_control/libboot_control.h index 34a9affe1..546865887 100644 --- a/boot_control/include/libboot_control/libboot_control.h +++ b/boot_control/include/libboot_control/libboot_control.h @@ -62,5 +62,28 @@ class BootControl { unsigned int current_slot_ = 0; }; +// Helper functions to write the Virtual A/B merge status message. These are +// separate because BootControl uses bootloader_control_ab in vendor space, +// whereas the Virtual A/B merge status is in system space. A HAL might not +// use bootloader_control_ab, but may want to use the AOSP method of maintaining +// the merge status. + +// If the Virtual A/B message has not yet been initialized, then initialize it. +// This should be called when the BootControl HAL first loads. +// +// If the Virtual A/B message in misc was already initialized, true is returned. +// If initialization was attempted, but failed, false is returned, and the HAL +// should fail to load. +bool InitMiscVirtualAbMessageIfNeeded(); + +// Save the current merge status as well as the current slot. +bool SetMiscVirtualAbMergeStatus(unsigned int current_slot, + android::hardware::boot::V1_1::MergeStatus status); + +// Return the current merge status. If the saved status is SNAPSHOTTED but the +// slot hasn't changed, the status returned will be NONE. +bool GetMiscVirtualAbMergeStatus(unsigned int current_slot, + android::hardware::boot::V1_1::MergeStatus* status); + } // namespace bootable } // namespace android -- cgit v1.2.3