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 // This namespace is exclusively for Renderscript internal libraries. This
18 // namespace has slightly looser restriction than the vndk namespace because of
19 // the genuine characteristics of Renderscript; /data is in the permitted path
20 // to load the compiled *.so file and libmediandk.so can be used here.
21
22 #include "linkerconfig/namespacebuilder.h"
23
24 #include <android-base/strings.h>
25
26 #include "linkerconfig/environment.h"
27
28 using android::linkerconfig::modules::Namespace;
29
30 namespace android {
31 namespace linkerconfig {
32 namespace contents {
BuildRsNamespace(const Context & ctx)33 Namespace BuildRsNamespace([[maybe_unused]] const Context& ctx) {
34 Namespace ns(
35 "rs", /*is_isolated=*/!ctx.IsUnrestrictedSection(), /*is_visible=*/true);
36
37 bool vendor_vndk_enabled =
38 android::linkerconfig::modules::IsVendorVndkVersionDefined();
39
40 ns.AddSearchPath("/odm/${LIB}/vndk-sp");
41 ns.AddSearchPath("/vendor/${LIB}/vndk-sp");
42 if (vendor_vndk_enabled) {
43 ns.AddSearchPath("/apex/com.android.vndk.v" + Var("VENDOR_VNDK_VERSION") +
44 "/${LIB}");
45 }
46 ns.AddSearchPath("/odm/${LIB}");
47 ns.AddSearchPath("/vendor/${LIB}");
48
49 ns.AddPermittedPath("/odm/${LIB}");
50 ns.AddPermittedPath("/vendor/${LIB}");
51 ns.AddPermittedPath("/system/vendor/${LIB}");
52 ns.AddPermittedPath("/data");
53
54 AddLlndkLibraries(ctx, &ns, VndkUserPartition::Vendor);
55 if (vendor_vndk_enabled) {
56 // Private LLNDK libs (e.g. libft2.so) are exceptionally allowed to this
57 // namespace because RS framework libs are using them.
58 ns.GetLink(ctx.GetSystemNamespaceName())
59 .AddSharedLib(Var("PRIVATE_LLNDK_LIBRARIES_VENDOR", ""));
60 } else {
61 // libft2.so is a special library which is used by RS framework libs, while
62 // other vendor libraries not allowed to use it. Add link to libft2.so as a
63 // exceptional case only from this namespace.
64 ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib("libft2.so");
65 }
66
67 return ns;
68 }
69 } // namespace contents
70 } // namespace linkerconfig
71 } // namespace android
72