summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2019-05-03 16:34:56 +0900
committerJiyong Park <jiyong@google.com>2019-05-08 13:49:49 +0900
commitf8802e5f0a74caf51897b7dd51412ae7d04d0fe8 (patch)
tree9f6f0df185d2c1424cfe7158393229a1f64e66da
parent40a6077244e22b5f3ab96358210b636618d4121a (diff)
downloadcore-f8802e5f0a74caf51897b7dd51412ae7d04d0fe8.tar.gz
Introduce utils.h
Introduce utils.h to have common routines. Bug: 130388701 Test: build & pass presubmit tests Change-Id: Ic40da64fefc1f2216bdea9ea93a15e5abb8f23a4
-rw-r--r--libnativeloader/library_namespaces.cpp11
-rw-r--r--libnativeloader/library_namespaces.h1
-rw-r--r--libnativeloader/native_loader_namespace.h1
-rw-r--r--libnativeloader/public_libraries.cpp8
-rw-r--r--libnativeloader/utils.h26
5 files changed, 33 insertions, 14 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp
index b80e9a1b6..0441bbbb9 100644
--- a/libnativeloader/library_namespaces.cpp
+++ b/libnativeloader/library_namespaces.cpp
@@ -30,6 +30,7 @@
#include "nativehelper/ScopedUtfChars.h"
#include "nativeloader/dlext_namespaces.h"
#include "public_libraries.h"
+#include "utils.h"
namespace android::nativeloader {
@@ -61,14 +62,8 @@ constexpr const char* kVendorClassloaderNamespaceName = "vendor-classloader-name
// This list includes all directories app is allowed to access this way.
constexpr const char* kWhitelistedDirectories = "/data:/mnt/expand";
-// TODO(b/130388701) use macro LIB to eliminate the conditional
-#if defined(__LP64__)
-constexpr const char* kVendorLibPath = "/vendor/lib64";
-constexpr const char* kProductLibPath = "/product/lib64:/system/product/lib64";
-#else
-constexpr const char* kVendorLibPath = "/vendor/lib";
-constexpr const char* kProductLibPath = "/product/lib:/system/product/lib";
-#endif
+constexpr const char* kVendorLibPath = "/vendor/" LIB;
+constexpr const char* kProductLibPath = "/product/" LIB ":/system/product/" LIB;
const std::regex kVendorDexPathRegex("(^|:)/vendor/");
const std::regex kProductDexPathRegex("(^|:)(/system)?/product/");
diff --git a/libnativeloader/library_namespaces.h b/libnativeloader/library_namespaces.h
index ff8fda983..103cfacbc 100644
--- a/libnativeloader/library_namespaces.h
+++ b/libnativeloader/library_namespaces.h
@@ -26,6 +26,7 @@
#include <string>
#include "jni.h"
+#include "utils.h"
namespace android::nativeloader {
diff --git a/libnativeloader/native_loader_namespace.h b/libnativeloader/native_loader_namespace.h
index 71b60d833..b983a2ddb 100644
--- a/libnativeloader/native_loader_namespace.h
+++ b/libnativeloader/native_loader_namespace.h
@@ -22,6 +22,7 @@
#include "android/dlext.h"
#include "log/log.h"
#include "nativebridge/native_bridge.h"
+#include "utils.h"
namespace android {
diff --git a/libnativeloader/public_libraries.cpp b/libnativeloader/public_libraries.cpp
index 8e3f9e811..e6f8448e5 100644
--- a/libnativeloader/public_libraries.cpp
+++ b/libnativeloader/public_libraries.cpp
@@ -27,6 +27,7 @@
#include "android-base/properties.h"
#include "android-base/strings.h"
#include "log/log.h"
+#include "utils.h"
namespace android::nativeloader {
@@ -50,12 +51,7 @@ const std::vector<const std::string> kRuntimePublicLibraries = {
"libicui18n.so",
};
-// TODO(b/130388701) use macro LIB to eliminate the conditional
-#if defined(__LP64__)
-constexpr const char* kRuntimeApexLibPath = "/apex/com.android.runtime/lib64";
-#else
-constexpr const char* kRuntimeApexLibPath = "/apex/com.android.runtime/lib";
-#endif
+constexpr const char* kRuntimeApexLibPath = "/apex/com.android.runtime/" LIB;
std::string root_dir() {
static const char* android_root_env = getenv("ANDROID_ROOT");
diff --git a/libnativeloader/utils.h b/libnativeloader/utils.h
new file mode 100644
index 000000000..a1c2be547
--- /dev/null
+++ b/libnativeloader/utils.h
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+#pragma once
+
+namespace android::nativeloader {
+
+#if defined(__LP64__)
+#define LIB "lib64"
+#else
+#define LIB "lib"
+#endif
+
+} // namespace android::nativeloader