Loading Ravenwood.bp +1 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ android_ravenwood_libgroup { ], jni_libs: [ "libandroid_runtime", "libravenwood_runtime", ], } Loading ravenwood/Android.bp +25 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,31 @@ filegroup { visibility: ["//frameworks/base"], } cc_library_shared { name: "libravenwood_runtime", host_supported: true, cflags: [ "-Wall", "-Werror", "-Wno-unused-parameter", "-Wthread-safety", ], srcs: [ "runtime-helper-src/jni/*.cpp", ], shared_libs: [ "libbase", "liblog", "libnativehelper", "libutils", "libcutils", ], visibility: ["//frameworks/base"], } // For collecting the *stats.csv files in a known directory under out/host/linux-x86/testcases/. // The "test" just shows the available stats filenames. sh_test_host { Loading ravenwood/bivalenttest/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ android_ravenwood_test { jni_libs: [ "libravenwoodbivalenttest_jni", ], sdk_version: "test_current", auto_gen_config: true, } Loading ravenwood/bivalenttest/AndroidTest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -25,5 +25,8 @@ <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="com.android.ravenwood.bivalenttest" /> <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> <!-- Need to use MODULE_LIBRARIES APIs, so no hidden API check. --> <option name="hidden-api-checks" value="false" /> </test> </configuration> ravenwood/bivalenttest/jni/ravenwood_core_test_jni.cpp +59 −2 Original line number Diff line number Diff line Loading @@ -15,19 +15,70 @@ */ #include <nativehelper/JNIHelp.h> #include <atomic> #include "jni.h" #include "utils/Log.h" #include "utils/misc.h" // JNI methods for RavenwoodJniTest static jint add(JNIEnv* env, jclass clazz, jint a, jint b) { return a + b; } static const JNINativeMethod sMethods[] = static const JNINativeMethod sMethods_JniTest[] = { { "add", "(II)I", (void*)add }, }; // JNI methods for RavenwoodNativeAllocationRegistryTest std::atomic<int> numTotalAlloc = 0; class NarTestData { public: NarTestData(jint v): value(v) { numTotalAlloc++; } ~NarTestData() { value = -1; numTotalAlloc--; } volatile jint value; }; static jlong NarTestData_nMalloc(JNIEnv* env, jclass clazz, jint value) { NarTestData* p = new NarTestData(value); return reinterpret_cast<jlong>(p); } static jint NarTestData_nGet(JNIEnv* env, jclass clazz, jlong ptr) { NarTestData* p = reinterpret_cast<NarTestData*>(ptr); return p->value; } static void NarTestData_free(jlong ptr) { NarTestData* p = reinterpret_cast<NarTestData*>(ptr); delete p; } static jlong NarTestData_nGetNativeFinalizer(JNIEnv* env, jclass clazz) { return reinterpret_cast<jlong>(NarTestData_free); } static jint NarTestData_nGetTotalAlloc(JNIEnv* env, jclass clazz) { return numTotalAlloc; } static const JNINativeMethod sMethods_NarTestData[] = { { "nMalloc", "(I)J", (void*)NarTestData_nMalloc }, { "nGet", "(J)I", (void*)NarTestData_nGet }, { "nGetNativeFinalizer", "()J", (void*)NarTestData_nGetNativeFinalizer }, { "nGetTotalAlloc", "()I", (void*)NarTestData_nGetTotalAlloc }, }; extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { JNIEnv* env = NULL; Loading @@ -43,7 +94,13 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) int res = jniRegisterNativeMethods(env, "com/android/ravenwoodtest/bivalenttest/RavenwoodJniTest", sMethods, NELEM(sMethods)); sMethods_JniTest, NELEM(sMethods_JniTest)); if (res < 0) { return res; } res = jniRegisterNativeMethods(env, "com/android/ravenwoodtest/bivalenttest/RavenwoodNativeAllocationRegistryTest$Data", sMethods_NarTestData, NELEM(sMethods_NarTestData)); if (res < 0) { return res; } Loading Loading
Ravenwood.bp +1 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ android_ravenwood_libgroup { ], jni_libs: [ "libandroid_runtime", "libravenwood_runtime", ], } Loading
ravenwood/Android.bp +25 −0 Original line number Diff line number Diff line Loading @@ -155,6 +155,31 @@ filegroup { visibility: ["//frameworks/base"], } cc_library_shared { name: "libravenwood_runtime", host_supported: true, cflags: [ "-Wall", "-Werror", "-Wno-unused-parameter", "-Wthread-safety", ], srcs: [ "runtime-helper-src/jni/*.cpp", ], shared_libs: [ "libbase", "liblog", "libnativehelper", "libutils", "libcutils", ], visibility: ["//frameworks/base"], } // For collecting the *stats.csv files in a known directory under out/host/linux-x86/testcases/. // The "test" just shows the available stats filenames. sh_test_host { Loading
ravenwood/bivalenttest/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ android_ravenwood_test { jni_libs: [ "libravenwoodbivalenttest_jni", ], sdk_version: "test_current", auto_gen_config: true, } Loading
ravenwood/bivalenttest/AndroidTest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -25,5 +25,8 @@ <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="com.android.ravenwood.bivalenttest" /> <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> <!-- Need to use MODULE_LIBRARIES APIs, so no hidden API check. --> <option name="hidden-api-checks" value="false" /> </test> </configuration>
ravenwood/bivalenttest/jni/ravenwood_core_test_jni.cpp +59 −2 Original line number Diff line number Diff line Loading @@ -15,19 +15,70 @@ */ #include <nativehelper/JNIHelp.h> #include <atomic> #include "jni.h" #include "utils/Log.h" #include "utils/misc.h" // JNI methods for RavenwoodJniTest static jint add(JNIEnv* env, jclass clazz, jint a, jint b) { return a + b; } static const JNINativeMethod sMethods[] = static const JNINativeMethod sMethods_JniTest[] = { { "add", "(II)I", (void*)add }, }; // JNI methods for RavenwoodNativeAllocationRegistryTest std::atomic<int> numTotalAlloc = 0; class NarTestData { public: NarTestData(jint v): value(v) { numTotalAlloc++; } ~NarTestData() { value = -1; numTotalAlloc--; } volatile jint value; }; static jlong NarTestData_nMalloc(JNIEnv* env, jclass clazz, jint value) { NarTestData* p = new NarTestData(value); return reinterpret_cast<jlong>(p); } static jint NarTestData_nGet(JNIEnv* env, jclass clazz, jlong ptr) { NarTestData* p = reinterpret_cast<NarTestData*>(ptr); return p->value; } static void NarTestData_free(jlong ptr) { NarTestData* p = reinterpret_cast<NarTestData*>(ptr); delete p; } static jlong NarTestData_nGetNativeFinalizer(JNIEnv* env, jclass clazz) { return reinterpret_cast<jlong>(NarTestData_free); } static jint NarTestData_nGetTotalAlloc(JNIEnv* env, jclass clazz) { return numTotalAlloc; } static const JNINativeMethod sMethods_NarTestData[] = { { "nMalloc", "(I)J", (void*)NarTestData_nMalloc }, { "nGet", "(J)I", (void*)NarTestData_nGet }, { "nGetNativeFinalizer", "()J", (void*)NarTestData_nGetNativeFinalizer }, { "nGetTotalAlloc", "()I", (void*)NarTestData_nGetTotalAlloc }, }; extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) { JNIEnv* env = NULL; Loading @@ -43,7 +94,13 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) int res = jniRegisterNativeMethods(env, "com/android/ravenwoodtest/bivalenttest/RavenwoodJniTest", sMethods, NELEM(sMethods)); sMethods_JniTest, NELEM(sMethods_JniTest)); if (res < 0) { return res; } res = jniRegisterNativeMethods(env, "com/android/ravenwoodtest/bivalenttest/RavenwoodNativeAllocationRegistryTest$Data", sMethods_NarTestData, NELEM(sMethods_NarTestData)); if (res < 0) { return res; } Loading