1 /* 2 * Copyright (C) 2021 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 #pragma once 18 19 #if defined(__ANDROID__) && !defined(__ANDROID_RECOVERY__) 20 #error VintfObjectRecovery is only supported in recovery and host. 21 #endif 22 23 #include <vintf/VintfObject.h> 24 25 namespace android::vintf { 26 27 /** 28 * A special variant of VintfObject for the recovery ramdisk. 29 * 30 * In recovery ramdisk, there is no Treble split. All VINTF data is stored in /system/etc/vintf. 31 * 32 * All getDevice* / getFramework* functions return nullptr. Instead, getRecovery* should be 33 * used instead. 34 */ 35 class VintfObjectRecovery : public VintfObject { 36 public: 37 /* 38 * Get global instance. Results are cached. 39 */ 40 static std::shared_ptr<VintfObjectRecovery> GetInstance(); 41 42 /* 43 * Return the API that access the HAL manifests built from component pieces on the 44 * recovery partition. 45 * 46 * Returned manifest has SchemaType::DEVICE. 47 * 48 * No SKU manifest support. 49 */ 50 std::shared_ptr<const HalManifest> getRecoveryHalManifest(); 51 52 // Not supported. Call getRecoveryHalManifest instead. getDeviceHalManifest()53 std::shared_ptr<const HalManifest> getDeviceHalManifest() override { return nullptr; } getFrameworkHalManifest()54 std::shared_ptr<const HalManifest> getFrameworkHalManifest() override { return nullptr; } 55 56 // Not supported. No compatibility check in recovery because there is no Treble split. getDeviceCompatibilityMatrix()57 std::shared_ptr<const CompatibilityMatrix> getDeviceCompatibilityMatrix() override { 58 return nullptr; 59 } getFrameworkCompatibilityMatrix()60 std::shared_ptr<const CompatibilityMatrix> getFrameworkCompatibilityMatrix() override { 61 return nullptr; 62 } 63 64 /** Builder of VintfObjectRecovery. See VintfObjectBuilder for details. */ 65 class Builder : public details::VintfObjectBuilder { 66 public: 67 Builder(); 68 }; 69 70 private: 71 VintfObjectRecovery() = default; 72 status_t fetchRecoveryHalManifest(HalManifest* out, std::string* error); 73 details::LockedSharedPtr<HalManifest> mRecoveryManifest; 74 }; 75 76 } // namespace android::vintf 77