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 <BootControlClient.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 = ::aidl::android::hardware::boot::MergeStatus; 30 31 public: 32 DeviceInfo(); 33 std::string GetMetadataDir() const override; 34 std::string GetSlotSuffix() const override; 35 std::string GetOtherSlotSuffix() const override; 36 const android::fs_mgr::IPartitionOpener& GetPartitionOpener() const override; 37 std::string GetSuperDevice(uint32_t slot) const override; 38 bool IsOverlayfsSetup() const override; 39 bool SetBootControlMergeStatus(MergeStatus status) override; 40 bool SetActiveBootSlot(unsigned int slot) override; 41 bool SetSlotAsUnbootable(unsigned int slot) override; 42 bool IsRecovery() const override; 43 std::unique_ptr<IImageManager> OpenImageManager() const override; 44 bool IsFirstStageInit() const override; 45 android::dm::IDeviceMapper& GetDeviceMapper() override; 46 void SetMetadataDir(const std::string& value); set_first_stage_init(bool value)47 void set_first_stage_init(bool value) { first_stage_init_ = value; } IsTempMetadata()48 bool IsTempMetadata() const override { return temp_metadata_; } SetTempMetadata()49 void SetTempMetadata() { temp_metadata_ = true; } 50 51 private: 52 bool EnsureBootHal(); 53 54 android::fs_mgr::PartitionOpener opener_; 55 bool first_stage_init_ = false; 56 // Default value 57 std::string metadata_dir_ = "/metadata/ota"; 58 bool temp_metadata_ = false; 59 #ifdef LIBSNAPSHOT_USE_HAL 60 std::unique_ptr<::android::hal::BootControlClient> boot_control_; 61 #endif 62 }; 63 64 } // namespace snapshot 65 } // namespace android 66