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 
17 // This namespace is for libraries within the NNAPI APEX.
18 
19 #include "linkerconfig/namespacebuilder.h"
20 
21 #include "linkerconfig/apex.h"
22 #include "linkerconfig/common.h"
23 #include "linkerconfig/environment.h"
24 #include "linkerconfig/namespace.h"
25 
26 using android::linkerconfig::modules::ApexInfo;
27 using android::linkerconfig::modules::AsanPath;
28 using android::linkerconfig::modules::Namespace;
29 
30 namespace {
31 std::vector<std::string> required_libs = {
32     "libandroidicu.so",
33     "libdexfile_external.so",
34     "libdexfiled_external.so",
35     // TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept
36     // for app compat. Uncomment those once they are marked as provided from ART
37     // APEX.
38 
39     // "libicui18n.so",
40     // "libicuuc.so",
41     "libnativebridge.so",
42     "libnativehelper.so",
43     "libnativeloader.so",
44     // TODO(b/122876336): Remove libpac.so once it's migrated to Webview
45     "libpac.so",
46     // statsd
47     "libstatspull.so",
48     "libstatssocket.so",
49     // adbd
50     "libadb_pairing_auth.so",
51     "libadb_pairing_connection.so",
52     "libadb_pairing_server.so",
53 };
54 }  // namespace
55 
56 namespace android {
57 namespace linkerconfig {
58 namespace contents {
59 Namespace BuildApexPlatformNamespace([[maybe_unused]] const Context& ctx) {
60   Namespace ns("system", /*is_isolated=*/true, /*is_visible=*/true);
61 
62   ns.AddSearchPath("/system/${LIB}", AsanPath::WITH_DATA_ASAN);
63   ns.AddPermittedPath("/apex/com.android.runtime/${LIB}/bionic",
64                       AsanPath::SAME_PATH);
65 
66   ns.AddProvides(GetSystemStubLibraries());
67   ns.AddRequires(required_libs);
68 
69   return ns;
70 }
71 }  // namespace contents
72 }  // namespace linkerconfig
73 }  // namespace android
74