diff --git a/interfaces/boot/1.2/BootControl.cpp b/interfaces/boot/1.2/BootControl.cpp index a28be05a..6c480bb6 100644 --- a/interfaces/boot/1.2/BootControl.cpp +++ b/interfaces/boot/1.2/BootControl.cpp @@ -49,6 +49,8 @@ namespace { #define BOOT_B_PATH "/dev/block/by-name/boot_b" #define DEVINFO_PATH "/dev/block/by-name/devinfo" +#define BLOW_AR_PATH "/sys/kernel/boot_control/blow_ar" + // slot flags #define AB_ATTR_PRIORITY_SHIFT 52 #define AB_ATTR_PRIORITY_MASK (3UL << AB_ATTR_PRIORITY_SHIFT) @@ -174,6 +176,11 @@ static void DevInfoInitSlot(devinfo_ab_slot_data_t &slot_data) { slot_data.fastboot_ok = 0; } +static bool blowAR() { + android::base::unique_fd fd(open(BLOW_AR_PATH, O_WRONLY | O_DSYNC)); + return android::base::WriteStringToFd("1", fd); +} + } // namespace // Methods from ::android::hardware::boot::V1_0::IBootControl follow. @@ -211,7 +218,17 @@ Return BootControl::markBootSuccessful(markBootSuccessful_cb _hidl_cb) { ret = setSlotFlag(getCurrentSlot(), AB_ATTR_SUCCESSFUL); } - !ret ? _hidl_cb({false, "Failed to set successful flag"}) : _hidl_cb({true, ""}); + if (!ret) { + _hidl_cb({false, "Failed to set successful flag"}); + return Void(); + } + + if (!blowAR()) { + ALOGE("Failed to blow anti-rollback counter"); + // Ignore the error, since ABL will re-trigger it on reboot + } + + _hidl_cb({true, ""}); return Void(); }