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)
diff --git a/v8/renderscript/Android.mk b/v8/renderscript/Android.mk
index 520c8a1..d695f72 100644
--- a/v8/renderscript/Android.mk
+++ b/v8/renderscript/Android.mk
@@ -24,7 +24,7 @@
 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 34e9dd8..9c5e150 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 @@
                     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 @@
         }
 
         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 @@
                 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");