Orion Hodson | 9b16e34 | 2019-10-09 13:29:16 +0100 | [diff] [blame] | 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 | */ |
Orion Hodson | 31b3ffa | 2019-10-14 10:27:00 +0100 | [diff] [blame] | 16 | |
| 17 | #ifndef ART_LIBNATIVELOADER_PUBLIC_LIBRARIES_H_ |
| 18 | #define ART_LIBNATIVELOADER_PUBLIC_LIBRARIES_H_ |
Orion Hodson | 9b16e34 | 2019-10-09 13:29:16 +0100 | [diff] [blame] | 19 | |
| 20 | #include <algorithm> |
Jooyung Han | 538f99a | 2020-03-03 00:46:50 +0900 | [diff] [blame] | 21 | #include <map> |
Orion Hodson | 9b16e34 | 2019-10-09 13:29:16 +0100 | [diff] [blame] | 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(); |
Orion Hodson | 9b16e34 | 2019-10-09 13:29:16 +0100 | [diff] [blame] | 35 | const std::string& vendor_public_libraries(); |
Justin Yun | a21b584 | 2021-08-10 14:05:49 +0900 | [diff] [blame] | 36 | const std::string& product_public_libraries(); |
Orion Hodson | 9b16e34 | 2019-10-09 13:29:16 +0100 | [diff] [blame] | 37 | const std::string& extended_public_libraries(); |
Justin Yun | 089c135 | 2020-02-06 16:53:08 +0900 | [diff] [blame] | 38 | const std::string& llndk_libraries_product(); |
| 39 | const std::string& llndk_libraries_vendor(); |
Justin Yun | eb4f08c | 2020-02-18 11:29:07 +0900 | [diff] [blame] | 40 | const std::string& vndksp_libraries_product(); |
| 41 | const std::string& vndksp_libraries_vendor(); |
Jooyung Han | 538f99a | 2020-03-03 00:46:50 +0900 | [diff] [blame] | 42 | const std::string& apex_jni_libraries(const std::string& apex_name); |
Orion Hodson | 9b16e34 | 2019-10-09 13:29:16 +0100 | [diff] [blame] | 43 | |
Jooyung Han | cd616d0 | 2020-09-01 14:53:23 +0900 | [diff] [blame] | 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 | |
Justin Yun | 3db26d5 | 2019-12-16 14:09:39 +0900 | [diff] [blame] | 50 | // Returns true if libnativeloader is running on devices and the device has |
Justin Yun | 089c135 | 2020-02-06 16:53:08 +0900 | [diff] [blame] | 51 | // ro.product.vndk.version property. It returns false for host. |
Justin Yun | 3db26d5 | 2019-12-16 14:09:39 +0900 | [diff] [blame] | 52 | bool is_product_vndk_version_defined(); |
| 53 | |
Justin Yun | 089c135 | 2020-02-06 16:53:08 +0900 | [diff] [blame] | 54 | std::string get_vndk_version(bool is_product_vndk); |
| 55 | |
Orion Hodson | 9b16e34 | 2019-10-09 13:29:16 +0100 | [diff] [blame] | 56 | // These are exported for testing |
| 57 | namespace internal { |
| 58 | |
| 59 | enum Bitness { ALL = 0, ONLY_32, ONLY_64 }; |
| 60 | |
| 61 | struct ConfigEntry { |
| 62 | std::string soname; |
| 63 | bool nopreload; |
| 64 | Bitness bitness; |
| 65 | }; |
| 66 | |
| 67 | Result<std::vector<std::string>> ParseConfig( |
| 68 | const std::string& file_content, |
| 69 | const std::function<Result<bool>(const ConfigEntry& /* entry */)>& filter_fn); |
| 70 | |
Jooyung Han | cd616d0 | 2020-09-01 14:53:23 +0900 | [diff] [blame] | 71 | // Parses apex.libraries.config.txt file generated by linkerconfig |
| 72 | // and returns mapping of <apex namespace> to <library list> which matches <tag>. |
| 73 | Result<std::map<std::string, std::string>> ParseApexLibrariesConfig( |
| 74 | const std::string& file_content, const std::string& tag); |
Jooyung Han | 538f99a | 2020-03-03 00:46:50 +0900 | [diff] [blame] | 75 | |
Orion Hodson | 9b16e34 | 2019-10-09 13:29:16 +0100 | [diff] [blame] | 76 | } // namespace internal |
| 77 | |
| 78 | } // namespace android::nativeloader |
Orion Hodson | 31b3ffa | 2019-10-14 10:27:00 +0100 | [diff] [blame] | 79 | |
| 80 | #endif // ART_LIBNATIVELOADER_PUBLIC_LIBRARIES_H_ |