Merge "Snap for 6405781 from d3f80c78b02bcf0a4d81017f089c7078bc89d14b to sdk-release" into sdk-release
diff --git a/cpp/Android.bp b/cpp/Android.bp
index 9d9041c..28ed223 100644
--- a/cpp/Android.bp
+++ b/cpp/Android.bp
@@ -58,8 +58,14 @@
 
     // We need to export not just rs/cpp but also rs.  This is because
     // RenderScript.h includes rsCppStructs.h, which includes rs/rsDefines.h.
-    header_libs: ["rs-headers"],
-    export_header_lib_headers: ["rs-headers"],
+    header_libs: [
+        "jni_headers",
+        "rs-headers"
+    ],
+    export_header_lib_headers: [
+        "jni_headers",
+        "rs-headers"
+    ],
     export_include_dirs: ["."],
 
     shared_libs: [
diff --git a/cpu_ref/rsCpuExecutable.cpp b/cpu_ref/rsCpuExecutable.cpp
index 63008ba..cc7f7a5 100644
--- a/cpu_ref/rsCpuExecutable.cpp
+++ b/cpu_ref/rsCpuExecutable.cpp
@@ -1,6 +1,7 @@
 #include "rsCpuExecutable.h"
 #include "rsCppUtils.h"
 
+#include <fcntl.h>
 #include <fstream>
 #include <set>
 #include <memory>
@@ -103,7 +104,7 @@
         Dl_info info;
         if (dladdr(reinterpret_cast<const void*>(&isRunningInVndkNamespace), &info) != 0) {
             std::string filename = std::string(info.dli_fname);
-            return filename.find("/vndk-sp") != std::string::npos;
+            return filename.find("/apex/com.android.vndk") != std::string::npos;
         } else {
             ALOGW("Can't determine whether this lib is running in vndk namespace or not. Assuming it is in vndk namespace.");
         }
diff --git a/cpu_ref/rsCpuScript.h b/cpu_ref/rsCpuScript.h
index a8f0db6..e9feb1c 100644
--- a/cpu_ref/rsCpuScript.h
+++ b/cpu_ref/rsCpuScript.h
@@ -157,17 +157,14 @@
 
 #ifdef __LP64__
 #define SYSLIBPATH "/system/lib64"
-#define SYSLIBPATH_VNDK "/system/lib64/vndk-sp"
 #define SYSLIBPATH_BC "/system/lib64"
 #define SYSLIBPATH_VENDOR "/system/vendor/lib64"
 #elif defined(BUILD_ARM_FOR_X86) && defined(__arm__)
 #define SYSLIBPATH "/system/lib/arm"
-#define SYSLIBPATH_VNDK "/system/lib/arm/vndk-sp"
 #define SYSLIBPATH_BC "/system/lib"
 #define SYSLIBPATH_VENDOR "/system/vendor/lib/arm"
 #else
 #define SYSLIBPATH "/system/lib"
-#define SYSLIBPATH_VNDK "/system/lib/vndk-sp"
 #define SYSLIBPATH_BC "/system/lib"
 #define SYSLIBPATH_VENDOR "/system/vendor/lib"
 #endif
@@ -197,11 +194,11 @@
 inline std::string getVndkSysLibPath() {
   char buf[PROP_VALUE_MAX];
   android::renderscript::property_get("ro.vndk.version", buf, "");
-  std::string versionStr = buf;
-  if (versionStr != "" && versionStr != "current") {
-    return SYSLIBPATH_VNDK "-" + versionStr;
-  }
-  return SYSLIBPATH_VNDK;
+  std::string vndk_path = "/apex/com.android.vndk.v" + std::string(buf) + "/lib";
+  #ifdef __LP64__
+  vndk_path += "64";
+  #endif
+  return vndk_path;
 }
 
 }  // anonymous namespace
diff --git a/support.bp b/support.bp
index 0b1c5e1..1a4bd59 100644
--- a/support.bp
+++ b/support.bp
@@ -185,4 +185,10 @@
         // Allow implicit fallthrough in rsContext.cpp:414 until it is fixed.
         "-Wno-error=implicit-fallthrough",
     ],
+
+    target: {
+        platform: {
+            shared_libs: ["libnativewindow"],
+        },
+    },
 }
diff --git a/support/jni/Android.bp b/support/jni/Android.bp
index 4f4fef8..331ea01 100644
--- a/support/jni/Android.bp
+++ b/support/jni/Android.bp
@@ -23,6 +23,8 @@
         "-DRS_COMPATIBILITY_LIB",
     ],
 
+    header_libs: ["jni_headers"],
+
     shared_libs: [
         "libandroid",
         "libdl",
@@ -43,6 +45,9 @@
 
     srcs: ["android_renderscript_RenderScript.cpp"],
 
+    header_libs: ["jni_headers"],
+    export_header_lib_headers: ["jni_headers"],
+
     shared_libs: [
         "libdl",
         "libjnigraphics",