Commit | Line | Data |
---|---|---|
298c504e PK |
1 | /* |
2 | * Copyright (C) 2020 The LineageOS 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 | #ifndef ANDROID_HARDWARE_BOOT_V1_0_BOOTCONTROL_H | |
18 | #define ANDROID_HARDWARE_BOOT_V1_0_BOOTCONTROL_H | |
19 | ||
20 | #include <android-base/properties.h> | |
21 | #include <android/hardware/boot/1.0/IBootControl.h> | |
22 | ||
23 | #include "bctl_metadata.h" | |
24 | ||
25 | namespace android { | |
26 | namespace hardware { | |
27 | namespace boot { | |
28 | namespace V1_0 { | |
29 | namespace implementation { | |
30 | ||
31 | using ::android::base::GetProperty; | |
32 | using ::android::hardware::Return; | |
33 | using ::android::hardware::Void; | |
34 | using ::android::hardware::boot::V1_0::BoolResult; | |
35 | using ::android::hardware::boot::V1_0::CommandResult; | |
36 | ||
37 | class BootControl : public IBootControl { | |
38 | public: | |
39 | // Methods from ::android::hardware::boot::V1_0::IBootControl follow. | |
40 | Return<uint32_t> getNumberSlots() override; | |
41 | Return<uint32_t> getCurrentSlot() override; | |
42 | Return<void> markBootSuccessful(markBootSuccessful_cb _hidl_cb) override; | |
43 | Return<void> setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) override; | |
44 | Return<void> setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) override; | |
45 | Return<BoolResult> isSlotBootable(uint32_t slot) override; | |
46 | Return<BoolResult> isSlotMarkedSuccessful(uint32_t slot) override; | |
47 | Return<void> getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) override; | |
48 | ||
49 | private: | |
50 | std::string mBlkDevice = BCTL_METADATA_PARTITION; | |
51 | ||
52 | bool readMetadata(bctl_metadata_t& data); | |
53 | bool writeMetadata(bctl_metadata_t& data); | |
54 | bool validateMetadata(bctl_metadata_t& data); | |
55 | bctl_metadata_t resetMetadata(); | |
56 | }; | |
57 | ||
58 | extern "C" IBootControl* HIDL_FETCH_IBootControl(const char* name); | |
59 | ||
60 | } // namespace implementation | |
61 | } // namespace V1_0 | |
62 | } // namespace boot | |
63 | } // namespace hardware | |
64 | } // namespace android | |
65 | ||
66 | #endif // ANDROID_HARDWARE_BOOT_V1_0_BOOTCONTROL_H |