summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-10 07:24:37 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-10 07:24:37 +0000
commit80dcd5c6e6b556ad1fc0c67387223539df12dfaa (patch)
tree95f00332886fc754a822b3aff23259761aab7cc6
parentfa2d1b6724d73525a3018317e2d3826ab0549fcf (diff)
parent42b3699fcbb77287b683ad6ecd788f2d763fd4b4 (diff)
downloadbootctrl-aml_sta_331311000.tar.gz
Change-Id: Ic1d522f3d606e2c474ab4b5769662f0bb514d562
-rw-r--r--Android.bp17
-rw-r--r--METADATA3
-rw-r--r--boot_control.cpp30
3 files changed, 50 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
index 13d6821..4b2ecdc 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,6 +1,23 @@
soong_namespace {
}
+package {
+ default_applicable_licenses: ["hardware_qcom_bootctrl_license"],
+}
+
+// Added automatically by a large-scale-change
+// See: http://go/android-license-faq
+license {
+ name: "hardware_qcom_bootctrl_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "SPDX-license-identifier-BSD",
+ ],
+ license_text: [
+ "NOTICE",
+ ],
+}
+
filegroup {
name: "bootctrl_hal_src",
srcs: [
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..d97975c
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,3 @@
+third_party {
+ license_type: NOTICE
+}
diff --git a/boot_control.cpp b/boot_control.cpp
index 2452412..82daba0 100644
--- a/boot_control.cpp
+++ b/boot_control.cpp
@@ -518,6 +518,35 @@ error:
return -1;
}
+unsigned get_active_boot_slot(struct boot_control_module *module)
+{
+ if (!module) {
+ ALOGE("%s: Invalid argument", __func__);
+ // The HAL spec requires that we return a number between
+ // 0 to num_slots - 1. Since something went wrong here we
+ // are just going to return the default slot.
+ return 0;
+ }
+
+ uint32_t num_slots = get_number_slots(module);
+ if (num_slots <= 1) {
+ //Slot 0 is the only slot around.
+ return 0;
+ }
+
+ for (uint32_t i = 0; i < num_slots; i++) {
+ char bootPartition[MAX_GPT_NAME_SIZE + 1] = {0};
+ snprintf(bootPartition, sizeof(bootPartition) - 1, "boot%s",
+ slot_suffix_arr[i]);
+ if (get_partition_attribute(bootPartition, ATTR_SLOT_ACTIVE) == 1) {
+ return i;
+ }
+ }
+
+ ALOGE("%s: Failed to find the active boot slot", __func__);
+ return 0;
+}
+
int set_active_boot_slot(struct boot_control_module *module, unsigned slot)
{
map<string, vector<string>> ptn_map;
@@ -663,6 +692,7 @@ boot_control_module_t HAL_MODULE_INFO_SYM = {
.getNumberSlots = get_number_slots,
.getCurrentSlot = get_current_slot,
.markBootSuccessful = mark_boot_successful,
+ .getActiveBootSlot = get_active_boot_slot,
.setActiveBootSlot = set_active_boot_slot,
.setSlotAsUnbootable = set_slot_as_unbootable,
.isSlotBootable = is_slot_bootable,