• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2019 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <string>
18 
19 #ifdef LIBSNAPSHOT_USE_HAL
20 #include <android/hardware/boot/1.1/IBootControl.h>
21 #endif
22 #include <liblp/partition_opener.h>
23 #include <libsnapshot/snapshot.h>
24 
25 namespace android {
26 namespace snapshot {
27 
28 class DeviceInfo final : public SnapshotManager::IDeviceInfo {
29     using MergeStatus = android::hardware::boot::V1_1::MergeStatus;
30 
31   public:
32     std::string GetMetadataDir() const override;
33     std::string GetSlotSuffix() const override;
34     std::string GetOtherSlotSuffix() const override;
35     const android::fs_mgr::IPartitionOpener& GetPartitionOpener() const override;
36     std::string GetSuperDevice(uint32_t slot) const override;
37     bool IsOverlayfsSetup() const override;
38     bool SetBootControlMergeStatus(MergeStatus status) override;
39     bool SetSlotAsUnbootable(unsigned int slot) override;
40     bool IsRecovery() const override;
41     std::unique_ptr<IImageManager> OpenImageManager() const override;
42     bool IsFirstStageInit() const override;
43 
set_first_stage_init(bool value)44     void set_first_stage_init(bool value) { first_stage_init_ = value; }
45 
46   private:
47     bool EnsureBootHal();
48 
49     android::fs_mgr::PartitionOpener opener_;
50     bool first_stage_init_ = false;
51 #ifdef LIBSNAPSHOT_USE_HAL
52     android::sp<android::hardware::boot::V1_1::IBootControl> boot_control_;
53 #endif
54 };
55 
56 }  // namespace snapshot
57 }  // namespace android
58