diff options
author | 2019-01-22 16:06:25 +0000 | |
---|---|---|
committer | 2019-01-22 16:06:25 +0000 | |
commit | 74d488494187395d9d305159f54fc679e8219e5d (patch) | |
tree | f0f4d8b94d8daf055a918c13a5c3c7117e025777 | |
parent | fbfba6a7d4b8892a2ce2de006ff3a767163ed05b (diff) |
Fix 674-hiddenapi run-test on AOSP host
The test would call VMRuntime.setHiddenApiExemptions() to test
whitelisting, but this API is now blacklisted. Add a small native helper
which achieves the same goal to fix the test.
Bug: 123150330
Test: art/test.py -b --host -r -t 674-hiddenapi
Change-Id: I03d6941507c273b53a25d70630807490a608fb59
-rw-r--r-- | test/674-hiddenapi/hiddenapi.cc | 8 | ||||
-rw-r--r-- | test/674-hiddenapi/src-art/Main.java | 8 |
2 files changed, 11 insertions, 5 deletions
diff --git a/test/674-hiddenapi/hiddenapi.cc b/test/674-hiddenapi/hiddenapi.cc index 8dfb402395..3dc27892aa 100644 --- a/test/674-hiddenapi/hiddenapi.cc +++ b/test/674-hiddenapi/hiddenapi.cc @@ -82,6 +82,14 @@ extern "C" JNIEXPORT jint JNICALL Java_Main_appendToBootClassLoader( return int_index; } +extern "C" JNIEXPORT void JNICALL Java_Main_setWhitelistAll(JNIEnv*, jclass, jboolean value) { + std::vector<std::string> exemptions; + if (value != JNI_FALSE) { + exemptions.push_back("L"); + } + Runtime::Current()->SetHiddenApiExemptions(exemptions); +} + static jobject NewInstance(JNIEnv* env, jclass klass) { jmethodID constructor = env->GetMethodID(klass, "<init>", "()V"); if (constructor == nullptr) { diff --git a/test/674-hiddenapi/src-art/Main.java b/test/674-hiddenapi/src-art/Main.java index 190f4ace65..d6a8c6dbd8 100644 --- a/test/674-hiddenapi/src-art/Main.java +++ b/test/674-hiddenapi/src-art/Main.java @@ -119,9 +119,8 @@ public class Main { // loaded by their parent class loader. String nativeLibCopy = createNativeLibCopy(parentDomain, childDomain, whitelistAllApis); - if (whitelistAllApis) { - VMRuntime.getRuntime().setHiddenApiExemptions(new String[]{"L"}); - } + // Set exemptions to "L" (matches all classes) if we are testing whitelisting. + setWhitelistAll(whitelistAllApis); // Invoke ChildClass.runTest Class<?> childClass = Class.forName("ChildClass", true, childLoader); @@ -129,8 +128,6 @@ public class Main { "runTest", String.class, Integer.TYPE, Integer.TYPE, Boolean.TYPE); runTestMethod.invoke(null, nativeLibCopy, parentDomain.ordinal(), childDomain.ordinal(), whitelistAllApis); - - VMRuntime.getRuntime().setHiddenApiExemptions(new String[0]); } // Routine which tries to figure out the absolute path of our native library. @@ -203,4 +200,5 @@ public class Main { private static native int appendToBootClassLoader(String dexPath, boolean isCorePlatform); private static native void setDexDomain(int index, boolean isCorePlatform); private static native void init(); + private static native void setWhitelistAll(boolean value); } |