From 405f6d6e7c2f21aca8f4dfe7bbe42a8767690aac Mon Sep 17 00:00:00 2001 From: Yang Ni Date: Thu, 14 Jan 2016 15:42:45 -0800 Subject: Avoid absolute path loading .so after M Bug: 26548955 Some apps have unpacked APKs, e.g., Google Camera. Using absolute path for shared libraries provided by the app will prevent them from loading. Fixed this by limiting usage of the absolute path to API levels older than M. Updated the bug number comment in the code so that they are clickable. Bumped the SDK level to 23 for RenderScript support lib build, so that we can use the proper API level constant defined in android.os.Build.VERSION_CODES. Change-Id: I9b6d9efed380e3e077e1efeabea324d4c01a7f0b (cherry picked from commit e214512fee6106909d3c6de59d28c307d71236c1) --- v8/renderscript/Android.mk | 2 +- .../android/support/v8/renderscript/RenderScript.java | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/v8/renderscript/Android.mk b/v8/renderscript/Android.mk index 520c8a1893..d695f72ba6 100644 --- a/v8/renderscript/Android.mk +++ b/v8/renderscript/Android.mk @@ -24,7 +24,7 @@ include $(CLEAR_VARS) LOCAL_CFLAGS += -std=c++11 LOCAL_MODULE := android-support-v8-renderscript -LOCAL_SDK_VERSION := 22 +LOCAL_SDK_VERSION := 23 LOCAL_SRC_FILES := $(call all-java-files-under, java/src) LOCAL_JAVA_LIBRARIES := android-support-annotations diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/RenderScript.java b/v8/renderscript/java/src/android/support/v8/renderscript/RenderScript.java index 34e9dd886e..9c5e150744 100644 --- a/v8/renderscript/java/src/android/support/v8/renderscript/RenderScript.java +++ b/v8/renderscript/java/src/android/support/v8/renderscript/RenderScript.java @@ -1343,9 +1343,10 @@ public class RenderScript { sUseGCHooks = false; } try { - // For API 9+, always use the absolute path of librsjni.so - // Bug: 25226912 - if (rs.mNativeLibDir != null) { + // For API 9 - 22, always use the absolute path of librsjni.so + // http://b/25226912 + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M && + rs.mNativeLibDir != null) { System.load(rs.mNativeLibDir + "/librsjni.so"); } else { System.loadLibrary("rsjni"); @@ -1376,9 +1377,10 @@ public class RenderScript { } String rssupportPath = null; - // For API 9+, always use the absolute path of libRSSupport.so - // Bug: 25226912 - if (rs.mNativeLibDir != null) { + // For API 9 - 22, always use the absolute path of libRSSupport.so + // http://b/25226912 + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M && + rs.mNativeLibDir != null) { rssupportPath = rs.mNativeLibDir + "/libRSSupport.so"; } if (!rs.nLoadSO(useNative, dispatchAPI, rssupportPath)) { @@ -1387,7 +1389,8 @@ public class RenderScript { useNative = false; } try { - if (rs.mNativeLibDir != null) { + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M && + rs.mNativeLibDir != null) { System.load(rssupportPath); } else { System.loadLibrary("RSSupport"); -- cgit v1.2.3