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 17 #include "linkerconfig/sectionbuilder.h" 18 19 #include <vector> 20 21 #include "linkerconfig/common.h" 22 #include "linkerconfig/log.h" 23 #include "linkerconfig/namespacebuilder.h" 24 #include "linkerconfig/section.h" 25 26 using android::linkerconfig::contents::SectionType; 27 using android::linkerconfig::modules::ApexInfo; 28 using android::linkerconfig::modules::Namespace; 29 using android::linkerconfig::modules::Section; 30 31 namespace android { 32 namespace linkerconfig { 33 namespace contents { 34 Section BuildApexDefaultSection(Context& ctx, const ApexInfo& apex_info) { 35 std::vector<Namespace> namespaces; 36 37 ctx.SetCurrentSection(SectionType::Other); 38 39 namespaces.emplace_back(BuildApexDefaultNamespace(ctx, apex_info)); 40 namespaces.emplace_back(BuildApexPlatformNamespace(ctx)); 41 42 // SWCodec APEX requires extra access to SPHAL (and corresponding VNDK) 43 // namespace(s) 44 if (apex_info.name == "com.android.media.swcodec") { 45 namespaces.emplace_back(BuildSphalNamespace(ctx)); 46 if (ctx.IsVndkAvailable()) { 47 namespaces.emplace_back( 48 BuildVndkNamespace(ctx, VndkUserPartition::Vendor)); 49 } 50 } 51 52 return BuildSection(ctx, apex_info.name, std::move(namespaces), {}); 53 } 54 } // namespace contents 55 } // namespace linkerconfig 56 } // namespace android 57