From 8217ced04ed9690d7f72e9ea869929928514f9e3 Mon Sep 17 00:00:00 2001 From: Luke Huang Date: Tue, 17 Dec 2019 13:10:09 +0800 Subject: [PATCH] Add Cronet namespace Bug: 139397529 Test: build Test: manual test with Cronet Change-Id: I1728747fcb6e04bf528266957695378f8d2b28fa --- contents/include/linkerconfig/namespacebuilder.h | 1 + contents/namespace/cronet.cc | 42 ++++++++++++++++++++++++ contents/section/legacy.cc | 1 + contents/section/system.cc | 1 + contents/section/unrestricted.cc | 1 + 5 files changed, 46 insertions(+) create mode 100644 contents/namespace/cronet.cc diff --git a/contents/include/linkerconfig/namespacebuilder.h b/contents/include/linkerconfig/namespacebuilder.h index 73c8699..c5be269 100644 --- a/contents/include/linkerconfig/namespacebuilder.h +++ b/contents/include/linkerconfig/namespacebuilder.h @@ -28,6 +28,7 @@ NamespaceBuilder BuildSystemDefaultNamespace; NamespaceBuilder BuildMediaNamespace; NamespaceBuilder BuildArtNamespace; NamespaceBuilder BuildConscryptNamespace; +NamespaceBuilder BuildCronetNamespace; NamespaceBuilder BuildResolvNamespace; NamespaceBuilder BuildSphalNamespace; NamespaceBuilder BuildRsNamespace; diff --git a/contents/namespace/cronet.cc b/contents/namespace/cronet.cc new file mode 100644 index 0000000..26ff47c --- /dev/null +++ b/contents/namespace/cronet.cc @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This namespace is for libraries within the NNAPI APEX. + +#include "linkerconfig/namespacebuilder.h" + +#include "linkerconfig/environment.h" +#include "linkerconfig/namespace.h" + +using android::linkerconfig::modules::AsanPath; +using android::linkerconfig::modules::Namespace; + +namespace android { +namespace linkerconfig { +namespace contents { +Namespace BuildCronetNamespace([[maybe_unused]] const Context& ctx) { + Namespace ns("cronet", /*is_isolated=*/true, /*is_visible=*/true); + ns.AddSearchPath("/apex/com.android.cronet/${LIB}", AsanPath::SAME_PATH); + ns.AddPermittedPath("/system/${LIB}"); + + ns.GetLink(ctx.GetSystemNamespaceName()) + .AddSharedLib( + "libandroid.so", "libc.so", "libdl.so", "libm.so", "liblog.so"); + return ns; +} +} // namespace contents +} // namespace linkerconfig +} // namespace android diff --git a/contents/section/legacy.cc b/contents/section/legacy.cc index c3d0940..1ae81e5 100644 --- a/contents/section/legacy.cc +++ b/contents/section/legacy.cc @@ -35,6 +35,7 @@ Section BuildLegacySection(Context& ctx) { namespaces.emplace_back(BuildArtNamespace(ctx)); namespaces.emplace_back(BuildMediaNamespace(ctx)); namespaces.emplace_back(BuildConscryptNamespace(ctx)); + namespaces.emplace_back(BuildCronetNamespace(ctx)); namespaces.emplace_back(BuildResolvNamespace(ctx)); namespaces.emplace_back(BuildNeuralNetworksNamespace(ctx)); namespaces.emplace_back(BuildRuntimeNamespace(ctx)); diff --git a/contents/section/system.cc b/contents/section/system.cc index d944f5f..162c517 100644 --- a/contents/section/system.cc +++ b/contents/section/system.cc @@ -36,6 +36,7 @@ Section BuildSystemSection(Context& ctx) { namespaces.emplace_back(BuildArtNamespace(ctx)); namespaces.emplace_back(BuildMediaNamespace(ctx)); namespaces.emplace_back(BuildConscryptNamespace(ctx)); + namespaces.emplace_back(BuildCronetNamespace(ctx)); namespaces.emplace_back(BuildResolvNamespace(ctx)); namespaces.emplace_back(BuildSphalNamespace(ctx)); namespaces.emplace_back(BuildRsNamespace(ctx)); diff --git a/contents/section/unrestricted.cc b/contents/section/unrestricted.cc index e7335fc..6ee8725 100644 --- a/contents/section/unrestricted.cc +++ b/contents/section/unrestricted.cc @@ -41,6 +41,7 @@ Section BuildUnrestrictedSection(Context& ctx) { namespaces.emplace_back(BuildArtNamespace(ctx)); namespaces.emplace_back(BuildMediaNamespace(ctx)); namespaces.emplace_back(BuildConscryptNamespace(ctx)); + namespaces.emplace_back(BuildCronetNamespace(ctx)); namespaces.emplace_back(BuildResolvNamespace(ctx)); namespaces.emplace_back(BuildNeuralNetworksNamespace(ctx)); namespaces.emplace_back(BuildRuntimeNamespace(ctx)); -- 2.11.0