Loading fastboot/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,7 @@ cc_binary { shared_libs: [ "android.hardware.boot@1.0", "android.hardware.boot@1.1", "android.hardware.fastboot@1.0", "android.hardware.health@2.0", "libadbd", Loading fastboot/constants.h +2 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #define FB_CMD_UPDATE_SUPER "update-super" #define FB_CMD_OEM "oem" #define FB_CMD_GSI "gsi" #define FB_CMD_SNAPSHOT_UPDATE "snapshot-update" #define RESPONSE_OKAY "OKAY" #define RESPONSE_FAIL "FAIL" Loading Loading @@ -66,3 +67,4 @@ #define FB_VAR_BATTERY_VOLTAGE "battery-voltage" #define FB_VAR_BATTERY_SOC_OK "battery-soc-ok" #define FB_VAR_SUPER_PARTITION_NAME "super-partition-name" #define FB_VAR_SNAPSHOT_UPDATE_STATUS "snapshot-update-status" fastboot/device/commands.cpp +42 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <android/hardware/boot/1.1/IBootControl.h> #include <cutils/android_reboot.h> #include <ext4_utils/wipe.h> #include <fs_mgr.h> Loading @@ -44,8 +45,10 @@ using ::android::hardware::hidl_string; using ::android::hardware::boot::V1_0::BoolResult; using ::android::hardware::boot::V1_0::CommandResult; using ::android::hardware::boot::V1_0::Slot; using ::android::hardware::boot::V1_1::MergeStatus; using ::android::hardware::fastboot::V1_0::Result; using ::android::hardware::fastboot::V1_0::Status; using IBootControl1_1 = ::android::hardware::boot::V1_1::IBootControl; struct VariableHandlers { // Callback to retrieve the value of a single variable. Loading Loading @@ -101,7 +104,8 @@ bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args) {FB_VAR_BATTERY_VOLTAGE, {GetBatteryVoltage, nullptr}}, {FB_VAR_BATTERY_SOC_OK, {GetBatterySoCOk, nullptr}}, {FB_VAR_HW_REVISION, {GetHardwareRevision, nullptr}}, {FB_VAR_SUPER_PARTITION_NAME, {GetSuperPartitionName, nullptr}}}; {FB_VAR_SUPER_PARTITION_NAME, {GetSuperPartitionName, nullptr}}, {FB_VAR_SNAPSHOT_UPDATE_STATUS, {GetSnapshotUpdateStatus, nullptr}}}; if (args.size() < 2) { return device->WriteFail("Missing argument"); Loading Loading @@ -547,3 +551,40 @@ bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args) { } return device->WriteStatus(FastbootResult::OKAY, "Success"); } bool SnapshotUpdateHandler(FastbootDevice* device, const std::vector<std::string>& args) { // 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) return device->WriteFail("Not supported"); android::sp<IBootControl1_1> hal11 = IBootControl1_1::castFrom(hal); if (!hal11) return device->WriteFail("Not supported"); // If no arguments, return the same thing as a getvar. Note that we get the // HAL first so we can return "not supported" before we return the less // specific error message below. if (args.size() < 2 || args[1].empty()) { std::string message; if (!GetSnapshotUpdateStatus(device, {}, &message)) { return device->WriteFail("Could not determine update status"); } device->WriteInfo(message); return device->WriteOkay(""); } if (args.size() != 2 || args[1] != "cancel") { return device->WriteFail("Invalid arguments"); } MergeStatus status = hal11->getSnapshotMergeStatus(); switch (status) { case MergeStatus::SNAPSHOTTED: case MergeStatus::MERGING: hal11->setSnapshotMergeStatus(MergeStatus::CANCELLED); break; default: break; } return device->WriteStatus(FastbootResult::OKAY, "Success"); } fastboot/device/commands.h +1 −0 Original line number Diff line number Diff line Loading @@ -49,3 +49,4 @@ bool ResizePartitionHandler(FastbootDevice* device, const std::vector<std::strin bool UpdateSuperHandler(FastbootDevice* device, const std::vector<std::string>& args); bool OemCmdHandler(FastbootDevice* device, const std::vector<std::string>& args); bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args); bool SnapshotUpdateHandler(FastbootDevice* device, const std::vector<std::string>& args); fastboot/device/fastboot_device.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ FastbootDevice::FastbootDevice() {FB_CMD_UPDATE_SUPER, UpdateSuperHandler}, {FB_CMD_OEM, OemCmdHandler}, {FB_CMD_GSI, GsiHandler}, {FB_CMD_SNAPSHOT_UPDATE, SnapshotUpdateHandler}, }), transport_(std::make_unique<ClientUsbTransport>()), boot_control_hal_(IBootControl::getService()), Loading Loading
fastboot/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,7 @@ cc_binary { shared_libs: [ "android.hardware.boot@1.0", "android.hardware.boot@1.1", "android.hardware.fastboot@1.0", "android.hardware.health@2.0", "libadbd", Loading
fastboot/constants.h +2 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #define FB_CMD_UPDATE_SUPER "update-super" #define FB_CMD_OEM "oem" #define FB_CMD_GSI "gsi" #define FB_CMD_SNAPSHOT_UPDATE "snapshot-update" #define RESPONSE_OKAY "OKAY" #define RESPONSE_FAIL "FAIL" Loading Loading @@ -66,3 +67,4 @@ #define FB_VAR_BATTERY_VOLTAGE "battery-voltage" #define FB_VAR_BATTERY_SOC_OK "battery-soc-ok" #define FB_VAR_SUPER_PARTITION_NAME "super-partition-name" #define FB_VAR_SNAPSHOT_UPDATE_STATUS "snapshot-update-status"
fastboot/device/commands.cpp +42 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <android/hardware/boot/1.1/IBootControl.h> #include <cutils/android_reboot.h> #include <ext4_utils/wipe.h> #include <fs_mgr.h> Loading @@ -44,8 +45,10 @@ using ::android::hardware::hidl_string; using ::android::hardware::boot::V1_0::BoolResult; using ::android::hardware::boot::V1_0::CommandResult; using ::android::hardware::boot::V1_0::Slot; using ::android::hardware::boot::V1_1::MergeStatus; using ::android::hardware::fastboot::V1_0::Result; using ::android::hardware::fastboot::V1_0::Status; using IBootControl1_1 = ::android::hardware::boot::V1_1::IBootControl; struct VariableHandlers { // Callback to retrieve the value of a single variable. Loading Loading @@ -101,7 +104,8 @@ bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args) {FB_VAR_BATTERY_VOLTAGE, {GetBatteryVoltage, nullptr}}, {FB_VAR_BATTERY_SOC_OK, {GetBatterySoCOk, nullptr}}, {FB_VAR_HW_REVISION, {GetHardwareRevision, nullptr}}, {FB_VAR_SUPER_PARTITION_NAME, {GetSuperPartitionName, nullptr}}}; {FB_VAR_SUPER_PARTITION_NAME, {GetSuperPartitionName, nullptr}}, {FB_VAR_SNAPSHOT_UPDATE_STATUS, {GetSnapshotUpdateStatus, nullptr}}}; if (args.size() < 2) { return device->WriteFail("Missing argument"); Loading Loading @@ -547,3 +551,40 @@ bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args) { } return device->WriteStatus(FastbootResult::OKAY, "Success"); } bool SnapshotUpdateHandler(FastbootDevice* device, const std::vector<std::string>& args) { // 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) return device->WriteFail("Not supported"); android::sp<IBootControl1_1> hal11 = IBootControl1_1::castFrom(hal); if (!hal11) return device->WriteFail("Not supported"); // If no arguments, return the same thing as a getvar. Note that we get the // HAL first so we can return "not supported" before we return the less // specific error message below. if (args.size() < 2 || args[1].empty()) { std::string message; if (!GetSnapshotUpdateStatus(device, {}, &message)) { return device->WriteFail("Could not determine update status"); } device->WriteInfo(message); return device->WriteOkay(""); } if (args.size() != 2 || args[1] != "cancel") { return device->WriteFail("Invalid arguments"); } MergeStatus status = hal11->getSnapshotMergeStatus(); switch (status) { case MergeStatus::SNAPSHOTTED: case MergeStatus::MERGING: hal11->setSnapshotMergeStatus(MergeStatus::CANCELLED); break; default: break; } return device->WriteStatus(FastbootResult::OKAY, "Success"); }
fastboot/device/commands.h +1 −0 Original line number Diff line number Diff line Loading @@ -49,3 +49,4 @@ bool ResizePartitionHandler(FastbootDevice* device, const std::vector<std::strin bool UpdateSuperHandler(FastbootDevice* device, const std::vector<std::string>& args); bool OemCmdHandler(FastbootDevice* device, const std::vector<std::string>& args); bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args); bool SnapshotUpdateHandler(FastbootDevice* device, const std::vector<std::string>& args);
fastboot/device/fastboot_device.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ FastbootDevice::FastbootDevice() {FB_CMD_UPDATE_SUPER, UpdateSuperHandler}, {FB_CMD_OEM, OemCmdHandler}, {FB_CMD_GSI, GsiHandler}, {FB_CMD_SNAPSHOT_UPDATE, SnapshotUpdateHandler}, }), transport_(std::make_unique<ClientUsbTransport>()), boot_control_hal_(IBootControl::getService()), Loading