Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8802e5f authored by Jiyong Park's avatar Jiyong Park
Browse files

Introduce utils.h

Introduce utils.h to have common routines.

Bug: 130388701
Test: build & pass presubmit tests
Change-Id: Ic40da64fefc1f2216bdea9ea93a15e5abb8f23a4
parent 40a60772
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -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/");
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <string>

#include "jni.h"
#include "utils.h"

namespace android::nativeloader {

+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "android/dlext.h"
#include "log/log.h"
#include "nativebridge/native_bridge.h"
#include "utils.h"

namespace android {

+2 −6
Original line number Diff line number Diff line
@@ -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");
+26 −0
Original line number Diff line number Diff line
/*
 * 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