blob: e5b979758202abb46fcc6788b460aea8e3f70140 [file] [log] [blame]
David Andersonb93d6702019-09-16 17:20:03 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "bootcontrolhal"
18
19#include <android-base/file.h>
20#include <android-base/logging.h>
21#include <android-base/unique_fd.h>
22#include <bootloader_message/bootloader_message.h>
David Anderson953ea5d2019-10-30 13:07:33 -070023#include <libboot_control/libboot_control.h>
David Andersonb93d6702019-09-16 17:20:03 -070024
25#include "BootControlShared.h"
26
27namespace android {
28namespace hardware {
29namespace boot {
Tianjie253b46d2020-11-30 14:38:35 -080030namespace V1_2 {
David Andersonb93d6702019-09-16 17:20:03 -070031namespace implementation {
32
David Anderson953ea5d2019-10-30 13:07:33 -070033using android::bootable::GetMiscVirtualAbMergeStatus;
34using android::bootable::InitMiscVirtualAbMessageIfNeeded;
35using android::bootable::SetMiscVirtualAbMergeStatus;
David Andersonb93d6702019-09-16 17:20:03 -070036using android::hardware::boot::V1_1::MergeStatus;
37
David Anderson953ea5d2019-10-30 13:07:33 -070038BootControlShared::BootControlShared() {}
David Andersonb93d6702019-09-16 17:20:03 -070039
David Anderson953ea5d2019-10-30 13:07:33 -070040bool BootControlShared::Init() {
41 return InitMiscVirtualAbMessageIfNeeded();
David Andersonb93d6702019-09-16 17:20:03 -070042}
43
44Return<bool> BootControlShared::setSnapshotMergeStatus(MergeStatus status) {
David Anderson953ea5d2019-10-30 13:07:33 -070045 return SetMiscVirtualAbMergeStatus(getCurrentSlot(), status);
David Andersonb93d6702019-09-16 17:20:03 -070046}
47
48Return<MergeStatus> BootControlShared::getSnapshotMergeStatus() {
David Anderson953ea5d2019-10-30 13:07:33 -070049 MergeStatus status;
50 if (!GetMiscVirtualAbMergeStatus(getCurrentSlot(), &status)) {
David Andersonb93d6702019-09-16 17:20:03 -070051 return MergeStatus::UNKNOWN;
52 }
David Anderson953ea5d2019-10-30 13:07:33 -070053 return status;
David Andersonb93d6702019-09-16 17:20:03 -070054}
55
56} // namespace implementation
Tianjie253b46d2020-11-30 14:38:35 -080057} // namespace V1_2
David Andersonb93d6702019-09-16 17:20:03 -070058} // namespace boot
59} // namespace hardware
60} // namespace android