Add GetActiveBootSlot API to boot control interface
This can be used to verify OtaStatus. If on disk pref indicates that we
switched slot and system did not reboot, check with boot control.
Test: th
Change-Id: I416d81a3d68d8c6a204a2c28df6c567ff18d0e49
diff --git a/aosp/boot_control_android.cc b/aosp/boot_control_android.cc
index c1ac0d4..88a9c17 100644
--- a/aosp/boot_control_android.cc
+++ b/aosp/boot_control_android.cc
@@ -20,6 +20,7 @@
#include <utility>
#include <vector>
+#include <android/hardware/boot/1.2/IBootControl.h>
#include <base/bind.h>
#include <base/logging.h>
#include <bootloader_message/bootloader_message.h>
@@ -177,6 +178,18 @@
return ret == BoolResult::TRUE;
}
+Slot BootControlAndroid::GetActiveBootSlot() {
+ namespace V1_2 = android::hardware::boot::V1_2;
+ using android::sp;
+ sp<V1_2::IBootControl> v1_2_module = V1_2::IBootControl::castFrom(module_);
+ if (v1_2_module != nullptr) {
+ return v1_2_module->getActiveBootSlot();
+ }
+ LOG(WARNING) << "BootControl module version is lower than 1.2, "
+ << __FUNCTION__ << " failed";
+ return kInvalidSlot;
+}
+
DynamicPartitionControlInterface*
BootControlAndroid::GetDynamicPartitionControl() {
return dynamic_control_.get();