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 #ifndef ART_LIBNATIVELOADER_PUBLIC_LIBRARIES_H_ 18 #define ART_LIBNATIVELOADER_PUBLIC_LIBRARIES_H_ 19 20 #include <algorithm> 21 #include <map> 22 #include <string> 23 24 #include <android-base/result.h> 25 26 namespace android::nativeloader { 27 28 using android::base::Result; 29 30 // These provide the list of libraries that are available to the namespace for apps. 31 // Not all of the libraries are available to apps. Depending on the context, 32 // e.g., if it is a vendor app or not, different set of libraries are made available. 33 const std::string& preloadable_public_libraries(); 34 const std::string& default_public_libraries(); 35 const std::string& vendor_public_libraries(); 36 const std::string& product_public_libraries(); 37 const std::string& extended_public_libraries(); 38 const std::string& llndk_libraries_product(); 39 const std::string& llndk_libraries_vendor(); 40 const std::string& vndksp_libraries_product(); 41 const std::string& vndksp_libraries_vendor(); 42 const std::string& apex_jni_libraries(const std::string& apex_name); 43 44 // Returns the table of apexes and public libraries provided by the apexes. 45 // For example, com_android_foo -> libfoo.so:libbar.so 46 // Note that libfoo.so and libbar.so are listed in /system/etc/public.libraries.txt 47 // but provided by com.android.foo APEX. 48 const std::map<std::string, std::string>& apex_public_libraries(); 49 50 std::string get_vndk_version(bool is_product_vndk); 51 52 // Returnes true if libnativeloader is running on devices and the device has 53 // treblelized product partition. It returns false for host. 54 // TODO: Remove this function and assume it is always true once when Mainline does not support any 55 // devices launched with Q or below. 56 bool is_product_treblelized(); 57 58 // These are exported for testing 59 namespace internal { 60 61 enum Bitness { ALL = 0, ONLY_32, ONLY_64 }; 62 63 struct ConfigEntry { 64 std::string soname; 65 bool nopreload; 66 Bitness bitness; 67 }; 68 69 Result<std::vector<std::string>> ParseConfig( 70 const std::string& file_content, 71 const std::function<Result<bool>(const ConfigEntry& /* entry */)>& filter_fn); 72 73 // Parses apex.libraries.config.txt file generated by linkerconfig 74 // and returns mapping of <apex namespace> to <library list> which matches <tag>. 75 Result<std::map<std::string, std::string>> ParseApexLibrariesConfig( 76 const std::string& file_content, const std::string& tag); 77 78 } // namespace internal 79 80 } // namespace android::nativeloader 81 82 #endif // ART_LIBNATIVELOADER_PUBLIC_LIBRARIES_H_ 83