Merge Android Pie into master

Bug: 112104996
Change-Id: Ied0d54d4ff268d4bb4ad9f9e655bac8916c9f7b2
diff --git a/driver/rsdAllocation.cpp b/driver/rsdAllocation.cpp
index 1beccc0..475d9fc 100644
--- a/driver/rsdAllocation.cpp
+++ b/driver/rsdAllocation.cpp
@@ -765,6 +765,15 @@
             return;
         }
 
+        if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_SCRIPT) {
+            r = ANativeWindow_setUsage(nw,
+                    AHARDWAREBUFFER_USAGE_CPU_READ_RARELY | AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN);
+            if (r) {
+                rsc->setError(RS_ERROR_DRIVER, "Error setting IO output buffer usage.");
+                return;
+            }
+        }
+
         IoGetBuffer(rsc, alloc, nw);
         drv->wndSurface = nw;
     }
diff --git a/libRS.map b/libRS.map
index c31e5a6..225b2bb 100644
--- a/libRS.map
+++ b/libRS.map
@@ -105,17 +105,17 @@
     rsScriptSetVarVE;
     rsTypeCreate;
     rsTypeCreate2;
-    _Z24rsaFileA3DCreateFromFilePvPKc;
-    _Z25rsaFileA3DCreateFromAssetPvS_;
-    _Z25rsaFileA3DGetEntryByIndexPvjS_;
-    _Z25rsaFileA3DGetIndexEntriesPvP16RsFileIndexEntryjS_;
-    _Z26rsaFileA3DCreateFromMemoryPvPKvj;
-    _Z28rsaFileA3DGetNumIndexEntriesPvPiS_;
-    _Z17rsaMeshGetIndicesPvS_PS_Pjj;
-    _Z18rsaMeshGetVerticesPvS_PS_j;
-    _Z20rsaMeshGetIndexCountPvS_Pi;
-    _Z27rsaMeshGetVertexBufferCountPvS_Pi;
-    _Z17rsContextCreateGLPvjj15RsSurfaceConfigj;
+    rsaFileA3DCreateFromFile;
+    rsaFileA3DCreateFromAsset;
+    rsaFileA3DGetEntryByIndex;
+    rsaFileA3DGetIndexEntries;
+    rsaFileA3DCreateFromMemory;
+    rsaFileA3DGetNumIndexEntries;
+    rsaMeshGetIndices;
+    rsaMeshGetVertices;
+    rsaMeshGetIndexCount;
+    rsaMeshGetVertexBufferCount;
+    rsContextCreateGL;
 
   local:
     *;
diff --git a/rs.h b/rs.h
index 603085f..edf98ef 100644
--- a/rs.h
+++ b/rs.h
@@ -22,25 +22,27 @@
 
 #include "rsInternalDefines.h"
 
-// Legacy graphics functions
-// Not extern C because not used from C++ API
-RsObjectBase rsaFileA3DGetEntryByIndex(RsContext, uint32_t idx, RsFile);
-RsFile rsaFileA3DCreateFromMemory(RsContext, const void *data, uint32_t len);
-RsFile rsaFileA3DCreateFromAsset(RsContext, void *asset);
-RsFile rsaFileA3DCreateFromFile(RsContext, const char *path);
-void rsaFileA3DGetNumIndexEntries(RsContext, int32_t *numEntries, RsFile);
-void rsaFileA3DGetIndexEntries(RsContext, RsFileIndexEntry *fileEntries,
-                               uint32_t numEntries, RsFile);
-// Mesh update functions
-void rsaMeshGetVertexBufferCount(RsContext, RsMesh, int32_t *vtxCount);
-void rsaMeshGetIndexCount(RsContext, RsMesh, int32_t *idxCount);
-void rsaMeshGetVertices(RsContext, RsMesh, RsAllocation *vtxData, uint32_t vtxDataCount);
-void rsaMeshGetIndices(RsContext, RsMesh, RsAllocation *va,
-                       uint32_t *primType, uint32_t idxDataCount);
-RsContext rsContextCreateGL(RsDevice dev, uint32_t version, uint32_t sdkVersion,
-                            RsSurfaceConfig sc, uint32_t dpi);
-
 extern "C" {
+    // Legacy graphics functions
+    RsObjectBase rsaFileA3DGetEntryByIndex(RsContext, uint32_t idx, RsFile);
+    RsFile rsaFileA3DCreateFromMemory(RsContext, const void *data,
+                                      uint32_t len);
+    RsFile rsaFileA3DCreateFromAsset(RsContext, void *asset);
+    RsFile rsaFileA3DCreateFromFile(RsContext, const char *path);
+    void rsaFileA3DGetNumIndexEntries(RsContext, int32_t *numEntries, RsFile);
+    void rsaFileA3DGetIndexEntries(RsContext, RsFileIndexEntry *fileEntries,
+                                   uint32_t numEntries, RsFile);
+    // Mesh update functions
+    void rsaMeshGetVertexBufferCount(RsContext, RsMesh, int32_t *vtxCount);
+    void rsaMeshGetIndexCount(RsContext, RsMesh, int32_t *idxCount);
+    void rsaMeshGetVertices(RsContext, RsMesh, RsAllocation *vtxData,
+                            uint32_t vtxDataCount);
+    void rsaMeshGetIndices(RsContext, RsMesh, RsAllocation *va,
+                           uint32_t *primType, uint32_t idxDataCount);
+    RsContext rsContextCreateGL(RsDevice dev, uint32_t version,
+                                uint32_t sdkVersion, RsSurfaceConfig sc,
+                                uint32_t dpi);
+
     void rsaGetName(RsContext, void * obj, const char **name);
     // Allocation update
     const void* rsaAllocationGetType(RsContext con, RsAllocation va);
diff --git a/rsApiStubs.cpp b/rsApiStubs.cpp
index 1737088..9b15fbf 100644
--- a/rsApiStubs.cpp
+++ b/rsApiStubs.cpp
@@ -717,8 +717,8 @@
 // Graphics
 /* The following API are deprecated. */
 
-RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
-                            RsSurfaceConfig sc, uint32_t dpi)
+extern "C" RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, uint32_t sdkVersion,
+                                       RsSurfaceConfig sc, uint32_t dpi)
 {
     if (!globalObjAlive) {
         ALOGE("rsContextCreateGL is not allowed during process teardown.");
@@ -860,52 +860,52 @@
     RS_DISPATCH(ctxWrapper, ProgramBindSampler, pf, slot, s);
 }
 
-RsObjectBase rsaFileA3DGetEntryByIndex(RsContext ctxWrapper, uint32_t index, RsFile file)
+extern "C" RsObjectBase rsaFileA3DGetEntryByIndex(RsContext ctxWrapper, uint32_t index, RsFile file)
 {
     return RS_DISPATCH(ctxWrapper, FileA3DGetEntryByIndex, index, file);
 }
 
-RsFile rsaFileA3DCreateFromMemory(RsContext ctxWrapper, const void *data, uint32_t len)
+extern "C" RsFile rsaFileA3DCreateFromMemory(RsContext ctxWrapper, const void *data, uint32_t len)
 {
     return RS_DISPATCH(ctxWrapper, FileA3DCreateFromMemory, data, len);
 }
 
-RsFile rsaFileA3DCreateFromAsset(RsContext ctxWrapper, void *_asset)
+extern "C" RsFile rsaFileA3DCreateFromAsset(RsContext ctxWrapper, void *_asset)
 {
     return RS_DISPATCH(ctxWrapper, FileA3DCreateFromAsset, _asset);
 }
 
-RsFile rsaFileA3DCreateFromFile(RsContext ctxWrapper, const char *path)
+extern "C" RsFile rsaFileA3DCreateFromFile(RsContext ctxWrapper, const char *path)
 {
     return RS_DISPATCH(ctxWrapper, FileA3DCreateFromFile, path);
 }
 
-void rsaFileA3DGetNumIndexEntries(RsContext ctxWrapper, int32_t *numEntries, RsFile file)
+extern "C"  void rsaFileA3DGetNumIndexEntries(RsContext ctxWrapper, int32_t *numEntries, RsFile file)
 {
     RS_DISPATCH(ctxWrapper, FileA3DGetNumIndexEntries, numEntries, file);
 }
 
-void rsaFileA3DGetIndexEntries(RsContext ctxWrapper, RsFileIndexEntry *fileEntries, uint32_t numEntries, RsFile file)
+extern "C" void rsaFileA3DGetIndexEntries(RsContext ctxWrapper, RsFileIndexEntry *fileEntries, uint32_t numEntries, RsFile file)
 {
     RS_DISPATCH(ctxWrapper, FileA3DGetIndexEntries, fileEntries, numEntries, file);
 }
 
-void rsaMeshGetVertexBufferCount(RsContext ctxWrapper, RsMesh mv, int32_t *numVtx)
+extern "C" void rsaMeshGetVertexBufferCount(RsContext ctxWrapper, RsMesh mv, int32_t *numVtx)
 {
     RS_DISPATCH(ctxWrapper, MeshGetVertexBufferCount, mv, numVtx);
 }
 
-void rsaMeshGetIndexCount(RsContext ctxWrapper, RsMesh mv, int32_t *numIdx)
+extern "C" void rsaMeshGetIndexCount(RsContext ctxWrapper, RsMesh mv, int32_t *numIdx)
 {
     RS_DISPATCH(ctxWrapper, MeshGetIndexCount, mv, numIdx);
 }
 
-void rsaMeshGetVertices(RsContext ctxWrapper, RsMesh mv, RsAllocation *vtxData, uint32_t vtxDataCount)
+extern "C" void rsaMeshGetVertices(RsContext ctxWrapper, RsMesh mv, RsAllocation *vtxData, uint32_t vtxDataCount)
 {
     RS_DISPATCH(ctxWrapper, MeshGetVertices, mv, vtxData, vtxDataCount);
 }
 
-void rsaMeshGetIndices(RsContext ctxWrapper, RsMesh mv, RsAllocation *va, uint32_t *primType, uint32_t idxDataCount)
+extern "C" void rsaMeshGetIndices(RsContext ctxWrapper, RsMesh mv, RsAllocation *va, uint32_t *primType, uint32_t idxDataCount)
 {
     RS_DISPATCH(ctxWrapper, MeshGetIndices, mv, va, primType, idxDataCount);
 }
diff --git a/rsApiStubs.h b/rsApiStubs.h
index 687fe55..6dd1b3f 100644
--- a/rsApiStubs.h
+++ b/rsApiStubs.h
@@ -123,7 +123,7 @@
 extern "C" void rsScriptSetVarVE (RsContext rsc, RsScript s, uint32_t slot, const void * data, size_t data_length, RsElement e, const uint32_t * dims, size_t dims_length);
 
 // Graphics
-RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsSurfaceConfig sc, uint32_t dpi);
+extern "C" RsContext rsContextCreateGL(RsDevice vdev, uint32_t version, uint32_t sdkVersion, RsSurfaceConfig sc, uint32_t dpi);
 extern "C" void rsContextSetSurface (RsContext rsc, uint32_t width, uint32_t height, RsNativeWindow sur);
 extern "C" void rsContextPause (RsContext rsc);
 extern "C" void rsContextResume (RsContext rsc);
@@ -145,15 +145,15 @@
 extern "C" void rsProgramBindTexture (RsContext rsc, RsProgramFragment pf, uint32_t slot, RsAllocation a);
 extern "C" void rsProgramBindSampler (RsContext rsc, RsProgramFragment pf, uint32_t slot, RsSampler s);
 
-RsObjectBase rsaFileA3DGetEntryByIndex(RsContext con, uint32_t index, RsFile file);
-RsFile rsaFileA3DCreateFromMemory(RsContext con, const void *data, uint32_t len);
-RsFile rsaFileA3DCreateFromAsset(RsContext con, void *_asset);
-RsFile rsaFileA3DCreateFromFile(RsContext con, const char *path);
-void rsaFileA3DGetNumIndexEntries(RsContext con, int32_t *numEntries, RsFile file);
-void rsaFileA3DGetIndexEntries(RsContext con, RsFileIndexEntry *fileEntries, uint32_t numEntries, RsFile file);
-void rsaMeshGetVertexBufferCount(RsContext con, RsMesh mv, int32_t *numVtx);
-void rsaMeshGetIndexCount(RsContext con, RsMesh mv, int32_t *numIdx);
-void rsaMeshGetVertices(RsContext con, RsMesh mv, RsAllocation *vtxData, uint32_t vtxDataCount);
-void rsaMeshGetIndices(RsContext con, RsMesh mv, RsAllocation *va, uint32_t *primType, uint32_t idxDataCount);
+extern "C" RsObjectBase rsaFileA3DGetEntryByIndex(RsContext con, uint32_t index, RsFile file);
+extern "C" RsFile rsaFileA3DCreateFromMemory(RsContext con, const void *data, uint32_t len);
+extern "C" RsFile rsaFileA3DCreateFromAsset(RsContext con, void *_asset);
+extern "C" RsFile rsaFileA3DCreateFromFile(RsContext con, const char *path);
+extern "C" void rsaFileA3DGetNumIndexEntries(RsContext con, int32_t *numEntries, RsFile file);
+extern "C" void rsaFileA3DGetIndexEntries(RsContext con, RsFileIndexEntry *fileEntries, uint32_t numEntries, RsFile file);
+extern "C" void rsaMeshGetVertexBufferCount(RsContext con, RsMesh mv, int32_t *numVtx);
+extern "C" void rsaMeshGetIndexCount(RsContext con, RsMesh mv, int32_t *numIdx);
+extern "C" void rsaMeshGetVertices(RsContext con, RsMesh mv, RsAllocation *vtxData, uint32_t vtxDataCount);
+extern "C" void rsaMeshGetIndices(RsContext con, RsMesh mv, RsAllocation *va, uint32_t *primType, uint32_t idxDataCount);
 
-#endif // ANDROID_RS_API_STUBS_H
\ No newline at end of file
+#endif // ANDROID_RS_API_STUBS_H
diff --git a/rsov/driver/rsovScript.cpp b/rsov/driver/rsovScript.cpp
index a579065..d1a6298 100644
--- a/rsov/driver/rsovScript.cpp
+++ b/rsov/driver/rsovScript.cpp
@@ -725,7 +725,7 @@
     for (std::string::size_type pos = 0; pos < s.size(); pos++) {
       std::string::size_type begin = pos;
 
-      while (s[pos] != D && pos <= s.size()) pos++;
+      while (pos <= s.size() && s[pos] != D) pos++;
       std::string found = s.substr(begin, pos - begin);
       if (each) each(found);
       if (all) result.push_back(found);
diff --git a/tests/java_api/ImageProcessing/Android.mk b/tests/java_api/ImageProcessing/Android.mk
index 4e81d39..2fcb8a4 100644
--- a/tests/java_api/ImageProcessing/Android.mk
+++ b/tests/java_api/ImageProcessing/Android.mk
@@ -19,9 +19,9 @@
 
 LOCAL_MODULE_TAGS := tests
 
-LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs android.test.base.stubs
 
-LOCAL_STATIC_JAVA_LIBRARIES := legacy-android-test junit
+LOCAL_STATIC_JAVA_LIBRARIES := junit
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
                    $(call all-renderscript-files-under, src)
diff --git a/tests/java_api/ImageProcessing_jb/Android.mk b/tests/java_api/ImageProcessing_jb/Android.mk
index 3ca65c7..700906d 100644
--- a/tests/java_api/ImageProcessing_jb/Android.mk
+++ b/tests/java_api/ImageProcessing_jb/Android.mk
@@ -18,9 +18,10 @@
 include $(CLEAR_VARS)
 
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs android.test.base.stubs
 
 LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE += device-tests
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
                    $(call all-renderscript-files-under, src)
diff --git a/tests/java_api/ImageProcessing_jb/AndroidTest.xml b/tests/java_api/ImageProcessing_jb/AndroidTest.xml
new file mode 100644
index 0000000..5914556
--- /dev/null
+++ b/tests/java_api/ImageProcessing_jb/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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.
+-->
+<configuration description="Runs ImageProcessingJB metric instrumentation.">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-metric-instrumentation" />
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="ImageProcessingJB.apk" />
+    </target_preparer>
+
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="com.android.rs.imagejb" />
+    </test>
+</configuration>
diff --git a/tests/java_api/RSTest_CompatLibLegacy/Android.mk b/tests/java_api/RSTest_CompatLibLegacy/Android.mk
index d1fe0db..ff841e7 100644
--- a/tests/java_api/RSTest_CompatLibLegacy/Android.mk
+++ b/tests/java_api/RSTest_CompatLibLegacy/Android.mk
@@ -29,8 +29,7 @@
 LOCAL_PACKAGE_NAME := RSTest_CompatLegacy
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    android-support-v8-renderscript \
-    legacy-android-test
+    android-support-v8-renderscript
 
 LOCAL_SDK_VERSION := 8
 LOCAL_RENDERSCRIPT_TARGET_API := 18
diff --git a/tests/java_api/RSTest_CompatLibLegacy/AndroidManifest.xml b/tests/java_api/RSTest_CompatLibLegacy/AndroidManifest.xml
index cd386c2..e36b7a8 100644
--- a/tests/java_api/RSTest_CompatLibLegacy/AndroidManifest.xml
+++ b/tests/java_api/RSTest_CompatLibLegacy/AndroidManifest.xml
@@ -6,6 +6,8 @@
     <application
         android:label="_RS_Test_CompatLegacy"
         android:icon="@drawable/test_pattern">
+        <uses-library android:name="android.test.runner" />
+
         <activity android:name="RSTestCompatLegacy"
                   android:screenOrientation="portrait">
             <intent-filter>
diff --git a/tests/java_api/RsBLAS_Benchmark/Android.mk b/tests/java_api/RsBLAS_Benchmark/Android.mk
index 895e50f..f8b1130 100644
--- a/tests/java_api/RsBLAS_Benchmark/Android.mk
+++ b/tests/java_api/RsBLAS_Benchmark/Android.mk
@@ -18,9 +18,10 @@
 include $(CLEAR_VARS)
 
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs android.test.base.stubs
 
 LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE += device-tests
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
 		   $(call all-renderscript-files-under, src)
diff --git a/tests/java_api/RsBLAS_Benchmark/AndroidTest.xml b/tests/java_api/RsBLAS_Benchmark/AndroidTest.xml
new file mode 100644
index 0000000..50b4ffe
--- /dev/null
+++ b/tests/java_api/RsBLAS_Benchmark/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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.
+-->
+<configuration description="Runs RsBlasBenchmark metric instrumentation.">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-metric-instrumentation" />
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="RsBlasBenchmark.apk" />
+    </target_preparer>
+
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="com.example.android.rs.blasbenchmark" />
+    </test>
+</configuration>
diff --git a/tests/java_api/RsTest/AndroidTest.xml b/tests/java_api/RsTest/AndroidTest.xml
index 0a27608..e4bdb1f 100644
--- a/tests/java_api/RsTest/AndroidTest.xml
+++ b/tests/java_api/RsTest/AndroidTest.xml
@@ -23,5 +23,6 @@
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="package" value="com.android.rs.test" />
         <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
+        <option name="hidden-api-checks" value="false"/>
     </test>
 </configuration>
diff --git a/tests/java_api/RsTest_11/Android.mk b/tests/java_api/RsTest_11/Android.mk
index a042504..13c8065 100644
--- a/tests/java_api/RsTest_11/Android.mk
+++ b/tests/java_api/RsTest_11/Android.mk
@@ -21,8 +21,6 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := legacy-android-test
-
 LOCAL_PACKAGE_NAME := RSTest_v11
 LOCAL_SDK_VERSION := 11
 
diff --git a/tests/java_api/RsTest_11/AndroidManifest.xml b/tests/java_api/RsTest_11/AndroidManifest.xml
index f4aeda2..79356c3 100644
--- a/tests/java_api/RsTest_11/AndroidManifest.xml
+++ b/tests/java_api/RsTest_11/AndroidManifest.xml
@@ -5,6 +5,8 @@
     <application 
         android:label="_RS_Test_v11"
         android:icon="@drawable/test_pattern">
+        <uses-library android:name="android.test.runner" />
+
         <activity android:name="RSTest_v11"
                   android:screenOrientation="portrait">
             <intent-filter>
diff --git a/tests/java_api/RsTest_14/Android.mk b/tests/java_api/RsTest_14/Android.mk
index b565454..a4386a4 100644
--- a/tests/java_api/RsTest_14/Android.mk
+++ b/tests/java_api/RsTest_14/Android.mk
@@ -21,8 +21,6 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := legacy-android-test
-
 LOCAL_PACKAGE_NAME := RSTest_v14
 LOCAL_SDK_VERSION := 14
 
diff --git a/tests/java_api/RsTest_14/AndroidManifest.xml b/tests/java_api/RsTest_14/AndroidManifest.xml
index 1cd9bbd..6f61c4e 100644
--- a/tests/java_api/RsTest_14/AndroidManifest.xml
+++ b/tests/java_api/RsTest_14/AndroidManifest.xml
@@ -5,6 +5,8 @@
     <application 
         android:label="_RS_Test_v14"
         android:icon="@drawable/test_pattern">
+        <uses-library android:name="android.test.runner" />
+
         <activity android:name="RSTest_v14"
                   android:screenOrientation="portrait">
             <intent-filter>
diff --git a/tests/java_api/RsTest_16/Android.mk b/tests/java_api/RsTest_16/Android.mk
index 0cbaf1b..f53c1ab 100644
--- a/tests/java_api/RsTest_16/Android.mk
+++ b/tests/java_api/RsTest_16/Android.mk
@@ -21,8 +21,6 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := legacy-android-test
-
 LOCAL_PACKAGE_NAME := RSTest_v16
 LOCAL_SDK_VERSION := 16
 
diff --git a/tests/java_api/RsTest_16/AndroidManifest.xml b/tests/java_api/RsTest_16/AndroidManifest.xml
index c3113e4..0d3c23d 100644
--- a/tests/java_api/RsTest_16/AndroidManifest.xml
+++ b/tests/java_api/RsTest_16/AndroidManifest.xml
@@ -5,6 +5,8 @@
     <application
         android:label="_RS_Test_v16"
         android:icon="@drawable/test_pattern">
+        <uses-library android:name="android.test.runner" />
+
         <activity android:name="RSTest_v16"
                   android:screenOrientation="portrait">
             <intent-filter>