Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31210fe8 authored by Tianjie Xu's avatar Tianjie Xu Committed by Automerger Merge Worker
Browse files

Merge "Extend the bootcontrol HAL to get the active slot" am: 59196163 am: f880de9a

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1513020

Change-Id: I8f7fc7fc2cd49b0aa2123d9fc6fce0bfc08dec05
parents 85531568 f880de9a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class BootControl {
  unsigned int GetNumberSlots();
  unsigned int GetCurrentSlot();
  bool MarkBootSuccessful();
  unsigned int GetActiveBootSlot();
  bool SetActiveBootSlot(unsigned int slot);
  bool SetSlotAsUnbootable(unsigned int slot);
  bool SetSlotBootable(unsigned int slot);
+18 −0
Original line number Diff line number Diff line
@@ -261,6 +261,24 @@ bool BootControl::MarkBootSuccessful() {
  return UpdateAndSaveBootloaderControl(misc_device_, &bootctrl);
}

unsigned int BootControl::GetActiveBootSlot() {
  bootloader_control bootctrl;
  if (!LoadBootloaderControl(misc_device_, &bootctrl)) return false;

  // Use the current slot by default.
  unsigned int active_boot_slot = current_slot_;
  unsigned int max_priority = bootctrl.slot_info[current_slot_].priority;
  // Find the slot with the highest priority.
  for (unsigned int i = 0; i < num_slots_; ++i) {
    if (bootctrl.slot_info[i].priority > max_priority) {
      max_priority = bootctrl.slot_info[i].priority;
      active_boot_slot = i;
    }
  }

  return active_boot_slot;
}

bool BootControl::SetActiveBootSlot(unsigned int slot) {
  if (slot >= kMaxNumSlots || slot >= num_slots_) {
    // Invalid slot number.

boot/1.2/Android.bp

0 → 100644
+15 −0
Original line number Diff line number Diff line
// This file is autogenerated by hidl-gen -Landroidbp.

hidl_interface {
    name: "android.hardware.boot@1.2",
    root: "android.hardware",
    srcs: [
        "IBootControl.hal",
    ],
    interfaces: [
        "android.hardware.boot@1.0",
        "android.hardware.boot@1.1",
        "android.hidl.base@1.0",
    ],
    gen_java: true,
}
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.boot@1.2;

import @1.0::IBootControl;
import @1.0::Slot;
import @1.1::IBootControl;

interface IBootControl extends @1.1::IBootControl {

  /**
   * Returns the active slot to boot into on the next boot. If
   * setActiveBootSlot() has been called, the getter function should return the
   * same slot as the one provided in the last setActiveBootSlot() call.
   * The returned value is always guaranteed to be strictly less than the
   * value returned by getNumberSlots. Slots start at 0 and finish at
   * getNumberSlots() - 1. For instance, a system with A/B must return 0 or 1.
   */
   getActiveBootSlot() generates (Slot slot);
};
+50 −0
Original line number Diff line number Diff line
cc_library_shared {
    name: "android.hardware.boot@1.2-impl",
    stem: "android.hardware.boot@1.0-impl-1.2",
    defaults: [
        "hidl_defaults",
        "libboot_control_defaults",
    ],
    relative_install_path: "hw",
    vendor: true,
    recovery_available: true,
    srcs: ["BootControl.cpp"],

    shared_libs: [
        "liblog",
        "libhidlbase",
        "libhardware",
        "libutils",
        "android.hardware.boot@1.0",
        "android.hardware.boot@1.1",
        "android.hardware.boot@1.2",
    ],
    static_libs: [
        "libboot_control",
        "libfstab",
    ],
}

cc_binary {
    name: "android.hardware.boot@1.2-service",
    defaults: ["hidl_defaults"],
    relative_install_path: "hw",
    vendor: true,
    init_rc: ["android.hardware.boot@1.2-service.rc"],
    srcs: ["service.cpp"],

    vintf_fragments: [
        "android.hardware.boot@1.2.xml",
    ],

    shared_libs: [
        "liblog",
        "libhardware",
        "libhidlbase",
        "libutils",
        "android.hardware.boot@1.0",
        "android.hardware.boot@1.1",
        "android.hardware.boot@1.2",
    ],

}
Loading