David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 1 | /* |
| 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 Anderson | 953ea5d | 2019-10-30 13:07:33 -0700 | [diff] [blame] | 23 | #include <libboot_control/libboot_control.h> |
David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 24 | |
| 25 | #include "BootControlShared.h" |
| 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace boot { |
Tianjie | 253b46d | 2020-11-30 14:38:35 -0800 | [diff] [blame] | 30 | namespace V1_2 { |
David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 31 | namespace implementation { |
| 32 | |
David Anderson | 953ea5d | 2019-10-30 13:07:33 -0700 | [diff] [blame] | 33 | using android::bootable::GetMiscVirtualAbMergeStatus; |
| 34 | using android::bootable::InitMiscVirtualAbMessageIfNeeded; |
| 35 | using android::bootable::SetMiscVirtualAbMergeStatus; |
David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 36 | using android::hardware::boot::V1_1::MergeStatus; |
| 37 | |
David Anderson | 953ea5d | 2019-10-30 13:07:33 -0700 | [diff] [blame] | 38 | BootControlShared::BootControlShared() {} |
David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 39 | |
David Anderson | 953ea5d | 2019-10-30 13:07:33 -0700 | [diff] [blame] | 40 | bool BootControlShared::Init() { |
| 41 | return InitMiscVirtualAbMessageIfNeeded(); |
David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | Return<bool> BootControlShared::setSnapshotMergeStatus(MergeStatus status) { |
David Anderson | 953ea5d | 2019-10-30 13:07:33 -0700 | [diff] [blame] | 45 | return SetMiscVirtualAbMergeStatus(getCurrentSlot(), status); |
David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | Return<MergeStatus> BootControlShared::getSnapshotMergeStatus() { |
David Anderson | 953ea5d | 2019-10-30 13:07:33 -0700 | [diff] [blame] | 49 | MergeStatus status; |
| 50 | if (!GetMiscVirtualAbMergeStatus(getCurrentSlot(), &status)) { |
David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 51 | return MergeStatus::UNKNOWN; |
| 52 | } |
David Anderson | 953ea5d | 2019-10-30 13:07:33 -0700 | [diff] [blame] | 53 | return status; |
David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | } // namespace implementation |
Tianjie | 253b46d | 2020-11-30 14:38:35 -0800 | [diff] [blame] | 57 | } // namespace V1_2 |
David Anderson | b93d670 | 2019-09-16 17:20:03 -0700 | [diff] [blame] | 58 | } // namespace boot |
| 59 | } // namespace hardware |
| 60 | } // namespace android |