blob: 2b41d37316ef5c062f315c51acec33f8edca085a [file] [log] [blame]
Kiyoung Kimff9cbf72019-03-14 18:26:24 +09001/*
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
Martin Stjernholm7e36aea2019-11-11 15:51:25 +000017// This namespace is for libraries within the media APEX.
18
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090019#include "linkerconfig/namespacebuilder.h"
20
21#include <string>
22#include <vector>
23
24#include "linkerconfig/environment.h"
25
Kiyoung Kim405bfc92019-08-16 12:54:23 +090026using android::linkerconfig::modules::AsanPath;
Martin Stjernholm7f8f6a02019-10-05 18:15:35 +010027using android::linkerconfig::modules::Link;
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090028using android::linkerconfig::modules::Namespace;
29
Kiyoung Kim96a43882019-05-13 17:19:51 +090030namespace {
Martin Stjernholmcb9df4f2019-10-02 20:47:12 +010031const std::vector<std::string> kLibsFromDefaultLegacy = {"libandroid.so",
32 "libbinder_ndk.so",
33 "libcgrouprc.so",
34 "liblog.so",
35 "libmediametrics.so",
36 "libmediandk.so",
37 "libvndksupport.so"};
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090038
Martin Stjernholmcb9df4f2019-10-02 20:47:12 +010039const std::vector<std::string> kLibsFromDefault = {"@{LLNDK_LIBRARIES}",
40 "libbinder_ndk.so",
41 "libmediametrics.so"};
Kiyoung Kimac298bb2019-08-07 19:13:09 +090042
43const std::vector<std::string> kLibsFromDefaultSystem = {"libcgrouprc.so"};
Kiyoung Kim96a43882019-05-13 17:19:51 +090044} // namespace
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090045
46namespace android {
47namespace linkerconfig {
48namespace contents {
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090049Namespace BuildMediaNamespace([[maybe_unused]] const Context& ctx) {
Kiyoung Kime6558072019-09-30 16:58:39 +090050 bool is_legacy = ctx.IsLegacyConfig();
51 bool is_vndklite = ctx.IsVndkliteConfig();
Kiyoung Kimac298bb2019-08-07 19:13:09 +090052 bool is_system_section = ctx.IsSystemSection();
53
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090054 Namespace ns("media", /*is_isolated=*/true, /*is_visible=*/true);
Kiyoung Kim405bfc92019-08-16 12:54:23 +090055 ns.AddSearchPath("/apex/com.android.media/${LIB}", AsanPath::SAME_PATH);
Kiyoung Kime6558072019-09-30 16:58:39 +090056 ns.AddPermittedPath(
57 "/apex/com.android.media/${LIB}/extractors",
58 (is_legacy || is_vndklite) ? AsanPath::NONE : AsanPath::SAME_PATH);
Kiyoung Kimac298bb2019-08-07 19:13:09 +090059
Martin Stjernholmcb9df4f2019-10-02 20:47:12 +010060 Link& system_link = ns.GetLink(ctx.GetSystemNamespaceName());
Kiyoung Kimac298bb2019-08-07 19:13:09 +090061 if (is_legacy) {
Martin Stjernholmcb9df4f2019-10-02 20:47:12 +010062 system_link.AddSharedLib(kLibsFromDefaultLegacy);
Kiyoung Kimac298bb2019-08-07 19:13:09 +090063 } else {
Martin Stjernholmcb9df4f2019-10-02 20:47:12 +010064 system_link.AddSharedLib(kLibsFromDefault);
Kiyoung Kime6558072019-09-30 16:58:39 +090065 if (is_system_section && !is_vndklite) {
Martin Stjernholmcb9df4f2019-10-02 20:47:12 +010066 system_link.AddSharedLib(kLibsFromDefaultSystem);
Kiyoung Kimac298bb2019-08-07 19:13:09 +090067 }
68 }
69
Martin Stjernholm7f8f6a02019-10-05 18:15:35 +010070 ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090071
72 return ns;
73}
74} // namespace contents
75} // namespace linkerconfig
Martin Stjernholm7f8f6a02019-10-05 18:15:35 +010076} // namespace android