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 #pragma once 17 18 #include <string> 19 20 #include "linkerconfig/basecontext.h" 21 22 namespace android { 23 namespace linkerconfig { 24 namespace contents { 25 26 enum class SectionType { 27 System, 28 Vendor, 29 Product, 30 Unrestricted, 31 Other, 32 }; 33 34 enum class LinkerConfigType { 35 Default, 36 Legacy, 37 Recovery, 38 ApexBinary, 39 }; 40 41 class Context : public modules::BaseContext { 42 public: Context()43 Context() 44 : current_section_(SectionType::System), 45 current_linkerconfig_type_(LinkerConfigType::Default), 46 current_apex_(nullptr) { 47 } 48 bool IsSystemSection() const; 49 bool IsVendorSection() const; 50 bool IsProductSection() const; 51 bool IsUnrestrictedSection() const; 52 const modules::ApexInfo& GetCurrentApex() const; 53 54 bool IsDefaultConfig() const; 55 bool IsLegacyConfig() const; 56 bool IsRecoveryConfig() const; 57 bool IsApexBinaryConfig() const; 58 59 void SetCurrentSection(SectionType value); 60 void SetCurrentLinkerConfigType(LinkerConfigType value); 61 void SetCurrentApex(const modules::ApexInfo* apex); 62 63 // Returns true if vndk apex is available 64 bool IsVndkAvailable() const; 65 66 // Returns the namespace that covers /system/${LIB}. 67 std::string GetSystemNamespaceName() const; 68 69 bool IsSectionVndkEnabled() const; 70 71 private: 72 SectionType current_section_; 73 LinkerConfigType current_linkerconfig_type_; 74 const modules::ApexInfo* current_apex_; 75 }; 76 77 std::string Var(const std::string& name); 78 79 std::string Var(const std::string& name, const std::string& default_value); 80 81 } // namespace contents 82 } // namespace linkerconfig 83 } // namespace android 84