From 6e44c30f05252fda0694fdc645934fd349ac602f Mon Sep 17 00:00:00 2001 From: dimitry Date: Thu, 4 Oct 2018 15:57:14 +0200 Subject: [PATCH] Respect extractNativeLibs in natively bridged environments The extractNativeLibs property was ignored by the package installer for environments with native bridge. This is not neccessary since native bridge implementations are required to support open-directly-from-apk feature and in this respect are not different from environments without native bridge. Bug: http://b/116854266 Test: cts-tradefed run singleCommand cts --skip-preconditions -m CtsJniTestCases Change-Id: I9ea7397183d7ebe2c00e461b95d188b15b51eca2 --- .../android/internal/content/NativeLibraryHelper.java | 8 ++------ ...m_android_internal_content_NativeLibraryHelper.cpp | 11 ++++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/core/java/com/android/internal/content/NativeLibraryHelper.java b/core/java/com/android/internal/content/NativeLibraryHelper.java index c3881485d4f92..fee8345d16606 100644 --- a/core/java/com/android/internal/content/NativeLibraryHelper.java +++ b/core/java/com/android/internal/content/NativeLibraryHelper.java @@ -171,8 +171,7 @@ public class NativeLibraryHelper { boolean debuggable); private native static int nativeCopyNativeBinaries(long handle, String sharedLibraryPath, - String abiToCopy, boolean extractNativeLibs, boolean hasNativeBridge, - boolean debuggable); + String abiToCopy, boolean extractNativeLibs, boolean debuggable); private static long sumNativeBinaries(Handle handle, String abi) { long sum = 0; @@ -193,7 +192,7 @@ public class NativeLibraryHelper { public static int copyNativeBinaries(Handle handle, File sharedLibraryDir, String abi) { for (long apkHandle : handle.apkHandles) { int res = nativeCopyNativeBinaries(apkHandle, sharedLibraryDir.getPath(), abi, - handle.extractNativeLibs, HAS_NATIVE_BRIDGE, handle.debuggable); + handle.extractNativeLibs, handle.debuggable); if (res != INSTALL_SUCCEEDED) { return res; } @@ -448,9 +447,6 @@ public class NativeLibraryHelper { // We don't care about the other return values for now. private static final int BITCODE_PRESENT = 1; - private static final boolean HAS_NATIVE_BRIDGE = - !"0".equals(SystemProperties.get("ro.dalvik.vm.native.bridge", "0")); - private static native int hasRenderscriptBitcode(long apkHandle); public static boolean hasRenderscriptBitcode(Handle handle) throws IOException { diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp index dc0426987b1e3..5eefc8196d30a 100644 --- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp +++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp @@ -176,7 +176,6 @@ copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntr void** args = reinterpret_cast(arg); jstring* javaNativeLibPath = (jstring*) args[0]; jboolean extractNativeLibs = *(jboolean*) args[1]; - jboolean hasNativeBridge = *(jboolean*) args[2]; ScopedUtfChars nativeLibPath(env, *javaNativeLibPath); @@ -206,9 +205,7 @@ copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntr return INSTALL_FAILED_INVALID_APK; } - if (!hasNativeBridge) { - return INSTALL_SUCCEEDED; - } + return INSTALL_SUCCEEDED; } // Build local file path @@ -489,9 +486,9 @@ static int findSupportedAbi(JNIEnv *env, jlong apkHandle, jobjectArray supported static jint com_android_internal_content_NativeLibraryHelper_copyNativeBinaries(JNIEnv *env, jclass clazz, jlong apkHandle, jstring javaNativeLibPath, jstring javaCpuAbi, - jboolean extractNativeLibs, jboolean hasNativeBridge, jboolean debuggable) + jboolean extractNativeLibs, jboolean debuggable) { - void* args[] = { &javaNativeLibPath, &extractNativeLibs, &hasNativeBridge }; + void* args[] = { &javaNativeLibPath, &extractNativeLibs }; return (jint) iterateOverNativeFiles(env, apkHandle, javaCpuAbi, debuggable, copyFileIfChanged, reinterpret_cast(args)); } @@ -597,7 +594,7 @@ static const JNINativeMethod gMethods[] = { "(J)V", (void *)com_android_internal_content_NativeLibraryHelper_close}, {"nativeCopyNativeBinaries", - "(JLjava/lang/String;Ljava/lang/String;ZZZ)I", + "(JLjava/lang/String;Ljava/lang/String;ZZ)I", (void *)com_android_internal_content_NativeLibraryHelper_copyNativeBinaries}, {"nativeSumNativeBinaries", "(JLjava/lang/String;Z)J",