blob: 71c1b8fffbc0360d166fc7869ccc3cfdb4ff4e52 [file] [log] [blame]
Orion Hodson9b16e342019-10-09 13:29:16 +01001/*
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 Hodson31b3ffa2019-10-14 10:27:00 +010016
17#ifndef ART_LIBNATIVELOADER_PUBLIC_LIBRARIES_H_
18#define ART_LIBNATIVELOADER_PUBLIC_LIBRARIES_H_
Orion Hodson9b16e342019-10-09 13:29:16 +010019
20#include <algorithm>
Jooyung Han538f99a2020-03-03 00:46:50 +090021#include <map>
Orion Hodson9b16e342019-10-09 13:29:16 +010022#include <string>
23
24#include <android-base/result.h>
25
26namespace android::nativeloader {
27
28using 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.
33const std::string& preloadable_public_libraries();
34const std::string& default_public_libraries();
Orion Hodson9b16e342019-10-09 13:29:16 +010035const std::string& vendor_public_libraries();
36const std::string& extended_public_libraries();
Justin Yun089c1352020-02-06 16:53:08 +090037const std::string& llndk_libraries_product();
38const std::string& llndk_libraries_vendor();
Justin Yuneb4f08c2020-02-18 11:29:07 +090039const std::string& vndksp_libraries_product();
40const std::string& vndksp_libraries_vendor();
Jooyung Han538f99a2020-03-03 00:46:50 +090041const std::string& apex_jni_libraries(const std::string& apex_name);
Orion Hodson9b16e342019-10-09 13:29:16 +010042
Jooyung Hancd616d02020-09-01 14:53:23 +090043// Returns the table of apexes and public libraries provided by the apexes.
44// For example, com_android_foo -> libfoo.so:libbar.so
45// Note that libfoo.so and libbar.so are listed in /system/etc/public.libraries.txt
46// but provided by com.android.foo APEX.
47const std::map<std::string, std::string>& apex_public_libraries();
48
Justin Yun3db26d52019-12-16 14:09:39 +090049// Returns true if libnativeloader is running on devices and the device has
Justin Yun089c1352020-02-06 16:53:08 +090050// ro.product.vndk.version property. It returns false for host.
Justin Yun3db26d52019-12-16 14:09:39 +090051bool is_product_vndk_version_defined();
52
Justin Yun089c1352020-02-06 16:53:08 +090053std::string get_vndk_version(bool is_product_vndk);
54
Orion Hodson9b16e342019-10-09 13:29:16 +010055// These are exported for testing
56namespace internal {
57
58enum Bitness { ALL = 0, ONLY_32, ONLY_64 };
59
60struct ConfigEntry {
61 std::string soname;
62 bool nopreload;
63 Bitness bitness;
64};
65
66Result<std::vector<std::string>> ParseConfig(
67 const std::string& file_content,
68 const std::function<Result<bool>(const ConfigEntry& /* entry */)>& filter_fn);
69
Jooyung Hancd616d02020-09-01 14:53:23 +090070// Parses apex.libraries.config.txt file generated by linkerconfig
71// and returns mapping of <apex namespace> to <library list> which matches <tag>.
72Result<std::map<std::string, std::string>> ParseApexLibrariesConfig(
73 const std::string& file_content, const std::string& tag);
Jooyung Han538f99a2020-03-03 00:46:50 +090074
Orion Hodson9b16e342019-10-09 13:29:16 +010075} // namespace internal
76
77} // namespace android::nativeloader
Orion Hodson31b3ffa2019-10-14 10:27:00 +010078
79#endif // ART_LIBNATIVELOADER_PUBLIC_LIBRARIES_H_