diff options
author | David Anderson <dvander@google.com> | 2019-10-21 16:45:59 -0700 |
---|---|---|
committer | David Anderson <dvander@google.com> | 2019-10-31 01:11:16 +0000 |
commit | ab8f466107572cd18bad3ed79c77b35daca5f0e4 (patch) | |
tree | a368582462a24ac11fbd1aa5a2b4550f107ce739 /fastboot/device/variables.cpp | |
parent | 32e7325c4400dd9f5fbf359c5673c2aab53a0e85 (diff) |
fastboot: Implement helper commands for Virtual A/B.
This introduces two new commands to the fastboot protocol:
- getvar snapshot-update-status - Return "none", "snapshotted", or
"merging" depending on the current status set by the boot control
HAL.
- snapshot-update [cancel] - Cancel any pending snapshot-based updates
via the boot control HAL. After this, the HAL should return
MergeStatus::CANCELLED and "update-merge-status" should be "none".
If no argument is specified, the snapshot-update-status is returned
via an INFO response.
Bootloaders are expected to implement this in a manner consistent with
the boot control HAL.
Fastboot-based tooling should expect wipes of userdata to fail when
update-merge-status returns "merging". Thus, the force flag now cancel
any pending snapshots.
Bug: 139154945
Test: fastboot getvar snapshot-update-status
fastboot snapshot-update cancel
fastboot snapshot-update
Change-Id: Idc423fe7656b212e929e64eb0e6b85b453e0e8dc
Diffstat (limited to 'fastboot/device/variables.cpp')
-rw-r--r-- | fastboot/device/variables.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index 130a3cf34..6e613d647 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -23,6 +23,7 @@ #include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> +#include <android/hardware/boot/1.1/IBootControl.h> #include <ext4_utils/ext4_utils.h> #include <fs_mgr.h> #include <healthhalutils/HealthHalUtils.h> @@ -34,9 +35,11 @@ using ::android::hardware::boot::V1_0::BoolResult; using ::android::hardware::boot::V1_0::Slot; +using ::android::hardware::boot::V1_1::MergeStatus; using ::android::hardware::fastboot::V1_0::FileSystemType; using ::android::hardware::fastboot::V1_0::Result; using ::android::hardware::fastboot::V1_0::Status; +using IBootControl1_1 = ::android::hardware::boot::V1_1::IBootControl; using namespace android::fs_mgr; constexpr char kFastbootProtocolVersion[] = "0.4"; @@ -424,3 +427,34 @@ bool GetSuperPartitionName(FastbootDevice* device, const std::vector<std::string *message = fs_mgr_get_super_partition_name(slot_number); return true; } + +bool GetSnapshotUpdateStatus(FastbootDevice* device, const std::vector<std::string>& /* args */, + std::string* message) { + // Note that we use the HAL rather than mounting /metadata, since we want + // our results to match the bootloader. + auto hal = device->boot_control_hal(); + if (!hal) { + *message = "not supported"; + return false; + } + + android::sp<IBootControl1_1> hal11 = IBootControl1_1::castFrom(hal); + if (!hal11) { + *message = "not supported"; + return false; + } + + MergeStatus status = hal11->getSnapshotMergeStatus(); + switch (status) { + case MergeStatus::SNAPSHOTTED: + *message = "snapshotted"; + break; + case MergeStatus::MERGING: + *message = "merging"; + break; + default: + *message = "none"; + break; + } + return true; +} |