Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [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 | */ |
| 16 | |
Martin Stjernholm | 7e36aea | 2019-11-11 15:51:25 +0000 | [diff] [blame^] | 17 | // This namespace is for libraries within the media APEX. |
| 18 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 19 | #include "linkerconfig/namespacebuilder.h" |
| 20 | |
| 21 | #include <string> |
| 22 | #include <vector> |
| 23 | |
| 24 | #include "linkerconfig/environment.h" |
| 25 | |
Kiyoung Kim | 405bfc9 | 2019-08-16 12:54:23 +0900 | [diff] [blame] | 26 | using android::linkerconfig::modules::AsanPath; |
Martin Stjernholm | 7f8f6a0 | 2019-10-05 18:15:35 +0100 | [diff] [blame] | 27 | using android::linkerconfig::modules::Link; |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 28 | using android::linkerconfig::modules::Namespace; |
| 29 | |
Kiyoung Kim | 96a4388 | 2019-05-13 17:19:51 +0900 | [diff] [blame] | 30 | namespace { |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 31 | const 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 Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 38 | |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 39 | const std::vector<std::string> kLibsFromDefault = {"@{LLNDK_LIBRARIES}", |
| 40 | "libbinder_ndk.so", |
| 41 | "libmediametrics.so"}; |
Kiyoung Kim | ac298bb | 2019-08-07 19:13:09 +0900 | [diff] [blame] | 42 | |
| 43 | const std::vector<std::string> kLibsFromDefaultSystem = {"libcgrouprc.so"}; |
Kiyoung Kim | 96a4388 | 2019-05-13 17:19:51 +0900 | [diff] [blame] | 44 | } // namespace |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 45 | |
| 46 | namespace android { |
| 47 | namespace linkerconfig { |
| 48 | namespace contents { |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 49 | Namespace BuildMediaNamespace([[maybe_unused]] const Context& ctx) { |
Kiyoung Kim | e655807 | 2019-09-30 16:58:39 +0900 | [diff] [blame] | 50 | bool is_legacy = ctx.IsLegacyConfig(); |
| 51 | bool is_vndklite = ctx.IsVndkliteConfig(); |
Kiyoung Kim | ac298bb | 2019-08-07 19:13:09 +0900 | [diff] [blame] | 52 | bool is_system_section = ctx.IsSystemSection(); |
| 53 | |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 54 | Namespace ns("media", /*is_isolated=*/true, /*is_visible=*/true); |
Kiyoung Kim | 405bfc9 | 2019-08-16 12:54:23 +0900 | [diff] [blame] | 55 | ns.AddSearchPath("/apex/com.android.media/${LIB}", AsanPath::SAME_PATH); |
Kiyoung Kim | e655807 | 2019-09-30 16:58:39 +0900 | [diff] [blame] | 56 | ns.AddPermittedPath( |
| 57 | "/apex/com.android.media/${LIB}/extractors", |
| 58 | (is_legacy || is_vndklite) ? AsanPath::NONE : AsanPath::SAME_PATH); |
Kiyoung Kim | ac298bb | 2019-08-07 19:13:09 +0900 | [diff] [blame] | 59 | |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 60 | Link& system_link = ns.GetLink(ctx.GetSystemNamespaceName()); |
Kiyoung Kim | ac298bb | 2019-08-07 19:13:09 +0900 | [diff] [blame] | 61 | if (is_legacy) { |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 62 | system_link.AddSharedLib(kLibsFromDefaultLegacy); |
Kiyoung Kim | ac298bb | 2019-08-07 19:13:09 +0900 | [diff] [blame] | 63 | } else { |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 64 | system_link.AddSharedLib(kLibsFromDefault); |
Kiyoung Kim | e655807 | 2019-09-30 16:58:39 +0900 | [diff] [blame] | 65 | if (is_system_section && !is_vndklite) { |
Martin Stjernholm | cb9df4f | 2019-10-02 20:47:12 +0100 | [diff] [blame] | 66 | system_link.AddSharedLib(kLibsFromDefaultSystem); |
Kiyoung Kim | ac298bb | 2019-08-07 19:13:09 +0900 | [diff] [blame] | 67 | } |
| 68 | } |
| 69 | |
Martin Stjernholm | 7f8f6a0 | 2019-10-05 18:15:35 +0100 | [diff] [blame] | 70 | ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so"); |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 71 | |
| 72 | return ns; |
| 73 | } |
| 74 | } // namespace contents |
| 75 | } // namespace linkerconfig |
Martin Stjernholm | 7f8f6a0 | 2019-10-05 18:15:35 +0100 | [diff] [blame] | 76 | } // namespace android |