diff options
author | 2024-02-13 14:58:56 -0800 | |
---|---|---|
committer | 2024-02-16 12:19:38 -0800 | |
commit | 50276f07f90865f96d4c9fd9cb6a5982b939acbc (patch) | |
tree | 27116309a94dd8be593e2f339a96e34cb1018fcf /ravenwood/runtime-helper-src | |
parent | 01b38aa8986dadd026cb82cf06c1251794d07f6f (diff) |
Start loading libandroid_runtime.so
Enable android.util.Log's native code
Test: ./ravenwood/run-ravenwood-tests.sh
Bug: 318393625
Change-Id: I0ec607586d71b1cc34b71db67249e110edc304df
Diffstat (limited to 'ravenwood/runtime-helper-src')
2 files changed, 15 insertions, 16 deletions
diff --git a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/Log_host.java b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/Log_host.java index 5930a14cdec8..f301b9c46b0e 100644 --- a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/Log_host.java +++ b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/nativesubstitution/Log_host.java @@ -22,6 +22,13 @@ import com.android.internal.os.RuntimeInit; import java.io.PrintStream; +/** + * Ravenwood "native substitution" class for {@link android.util.Log}. + * + * {@link android.util.Log} already uses the actual native code and doesn't use this class. + * In order to switch to this Java implementation, uncomment the @RavenwoodNativeSubstitutionClass + * annotation on {@link android.util.Log}. + */ public class Log_host { public static boolean isLoggable(String tag, @Level int level) { diff --git a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java index 1e120305fa2d..cc94090d9ec7 100644 --- a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java +++ b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java @@ -15,8 +15,9 @@ */ package com.android.platform.test.ravenwood.runtimehelper; +import android.platform.test.ravenwood.RavenwoodUtils; + import java.io.File; -import java.io.PrintStream; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -27,8 +28,6 @@ import java.util.ArrayList; * load other JNI or do other set up here. */ public class ClassLoadHook { - private static PrintStream sOut = System.out; - /** * If true, we won't load `libandroid_runtime` * @@ -36,7 +35,7 @@ public class ClassLoadHook { * so we need a way to remove the dependency. */ private static final boolean SKIP_LOADING_LIBANDROID = "1".equals(System.getenv( - "HOSTTEST_SKIP_LOADING_LIBANDROID")); + "RAVENWOOD_SKIP_LOADING_LIBANDROID")); public static final String CORE_NATIVE_CLASSES = "core_native_classes"; public static final String ICU_DATA_PATH = "icu.data.path"; @@ -44,7 +43,7 @@ public class ClassLoadHook { public static final String GRAPHICS_NATIVE_CLASSES = "graphics_native_classes"; public static final String VALUE_N_A = "**n/a**"; - public static final String LIBANDROID_RUNTIME_NAME = "libandroid_runtime"; + public static final String LIBANDROID_RUNTIME_NAME = "android_runtime"; private static String sInitialDir = new File("").getAbsolutePath(); @@ -68,7 +67,7 @@ public class ClassLoadHook { } private static void log(String message) { - sOut.println("ClassLoadHook: " + message); + System.out.println("ClassLoadHook: " + message); } private static void log(String fmt, Object... args) { @@ -92,13 +91,6 @@ public class ClassLoadHook { } } - private static void loadJniLibrary(String name) { - final String path = sInitialDir + "/lib64/" + name + ".so"; - System.out.println("Loading " + path + " ..."); - System.load(path); - System.out.println("Done loading " + path); - } - private static boolean sLoadFrameworkNativeCodeCalled = false; /** @@ -115,7 +107,7 @@ public class ClassLoadHook { // libandroid_runtime uses Java's system properties to decide what JNI methods to set up. // Set up these properties for host-side tests. - if ("1".equals(System.getenv("HOSTTEST_DUMP_PROPERTIES"))) { + if ("1".equals(System.getenv("RAVENWOOD_DUMP_PROPERTIES"))) { log("Java system properties:"); dumpSystemProperties(); } @@ -141,7 +133,7 @@ public class ClassLoadHook { setProperty(ICU_DATA_PATH, VALUE_N_A); setProperty(KEYBOARD_PATHS, VALUE_N_A); - loadJniLibrary(LIBANDROID_RUNTIME_NAME); + RavenwoodUtils.loadJniLibrary(LIBANDROID_RUNTIME_NAME); } /** @@ -156,7 +148,7 @@ public class ClassLoadHook { }; /** - * @return if a given method is a native method or not. + * @return if a given class has any native method or not. */ private static boolean hasNativeMethod(Class<?> clazz) { for (var method : clazz.getDeclaredMethods()) { |