1 /* 2 * Copyright (C) 2020 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 <algorithm> 19 #include <map> 20 #include <string> 21 #include <vector> 22 23 #include <android-base/result.h> 24 25 namespace android { 26 namespace linkerconfig { 27 namespace modules { 28 29 struct Contribution { 30 std::string namespace_name; 31 std::vector<std::string> paths; 32 }; 33 34 struct ApexInfo { 35 std::string name; 36 std::string namespace_name; 37 std::string path; 38 std::string original_path; 39 std::vector<std::string> provide_libs; 40 std::vector<std::string> require_libs; 41 std::vector<std::string> jni_libs; 42 std::vector<std::string> permitted_paths; 43 std::vector<std::string> public_libs; 44 std::vector<Contribution> contributions; 45 bool has_bin; 46 bool has_lib; 47 bool visible; 48 bool has_shared_lib; 49 50 ApexInfo() = default; // for std::map::operator[] ApexInfoApexInfo51 ApexInfo(std::string name, std::string path, 52 std::vector<std::string> provide_libs, 53 std::vector<std::string> require_libs, 54 std::vector<std::string> jni_libs, 55 std::vector<std::string> permitted_paths, 56 std::vector<Contribution> contributions, bool has_bin, bool has_lib, 57 bool visible, bool has_shared_lib) 58 : name(std::move(name)), 59 path(std::move(path)), 60 provide_libs(std::move(provide_libs)), 61 require_libs(std::move(require_libs)), 62 jni_libs(std::move(jni_libs)), 63 permitted_paths(std::move(permitted_paths)), 64 contributions(std::move(contributions)), 65 has_bin(has_bin), 66 has_lib(has_lib), 67 visible(visible), 68 has_shared_lib(has_shared_lib) { 69 this->namespace_name = this->name; 70 std::replace( 71 this->namespace_name.begin(), this->namespace_name.end(), '.', '_'); 72 } 73 74 bool InSystem() const; 75 bool InProduct() const; 76 bool InVendor() const; 77 }; 78 79 android::base::Result<std::map<std::string, ApexInfo>> ScanActiveApexes( 80 const std::string& root); 81 } // namespace modules 82 } // namespace linkerconfig 83 } // namespace android