diff options
author | 2024-09-10 22:11:50 +0000 | |
---|---|---|
committer | 2024-09-10 22:11:50 +0000 | |
commit | 7dabb818c8710a3be553086841a575f16ca3b61e (patch) | |
tree | 6ebb76dfe550d84e925f20c294476597790ca92b | |
parent | 7164ab54d1290cc19e8573ae5e48441aec32402c (diff) | |
parent | c317d4a270f9d0cd50f9fd307f31a3f8d92fe26a (diff) |
Merge "Allow junit-impl to see runtime-helper-src" into main
3 files changed, 13 insertions, 33 deletions
diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp index eebe5e9fc054..8ff99e4af30d 100644 --- a/ravenwood/Android.bp +++ b/ravenwood/Android.bp @@ -129,9 +129,9 @@ java_library { ], libs: [ "framework-minus-apex.ravenwood", - "ravenwood-junit", "ravenwood-helper-libcore-runtime", ], + sdk_version: "core_current", visibility: ["//visibility:private"], } @@ -165,6 +165,8 @@ java_library { "services.core.ravenwood", "junit", "framework-annotations-lib", + "ravenwood-helper-framework-runtime", + "ravenwood-helper-libcore-runtime", ], sdk_version: "core_current", visibility: ["//frameworks/base"], diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java index 92a1cb7fc3bf..68472c12a568 100644 --- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java +++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java @@ -28,6 +28,7 @@ import android.util.Log; import androidx.test.platform.app.InstrumentationRegistry; import com.android.internal.os.RuntimeInit; +import com.android.platform.test.ravenwood.runtimehelper.ClassLoadHook; import com.android.ravenwood.common.RavenwoodCommonUtils; import org.junit.runner.Description; @@ -75,6 +76,9 @@ public class RavenwoodAwareTestRunnerHook { // We haven't initialized liblog yet, so directly write to System.out here. RavenwoodCommonUtils.log(TAG, "initOnce()"); + // Make sure libandroid_runtime is loaded. + ClassLoadHook.onClassLoaded(Log.class); + // Redirect stdout/stdin to liblog. RuntimeInit.redirectLogStreams(); @@ -82,6 +86,10 @@ public class RavenwoodAwareTestRunnerHook { System.setProperty("android.junit.runner", "androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner"); System.setProperty(RAVENWOOD_VERSION_JAVA_SYSPROP, "1"); + + // Do the basic set up for the android sysprops. + RavenwoodRuntimeEnvironmentController.setSystemProperties( + RavenwoodSystemProperties.DEFAULT_VALUES); } /** diff --git a/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java b/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java index 3bf116da19b8..e12ff240c4d9 100644 --- a/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java +++ b/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java @@ -15,21 +15,10 @@ */ package com.android.internal.ravenwood; -import android.os.SystemProperties_host; -import android.platform.test.ravenwood.RavenwoodSystemProperties; -import android.util.Log; - import com.android.ravenwood.common.JvmWorkaround; import com.android.ravenwood.common.RavenwoodCommonUtils; public class RavenwoodEnvironment_host { - private static final String TAG = RavenwoodEnvironment.TAG; - - private static final Object sInitializeLock = new Object(); - - // @GuardedBy("sInitializeLock") - private static boolean sInitialized; - private RavenwoodEnvironment_host() { } @@ -37,27 +26,8 @@ public class RavenwoodEnvironment_host { * Called from {@link RavenwoodEnvironment#ensureRavenwoodInitialized()}. */ public static void ensureRavenwoodInitialized() { - - // TODO Unify it with the initialization code in RavenwoodAwareTestRunnerHook. - - synchronized (sInitializeLock) { - if (sInitialized) { - return; - } - Log.i(TAG, "Initializing Ravenwood environment"); - - // Set the default values. - var sysProps = RavenwoodSystemProperties.DEFAULT_VALUES; - - // We have a method that does it in RavenwoodRuleImpl, but we can't use that class - // here, So just inline it. - SystemProperties_host.initializeIfNeeded( - sysProps.getValues(), - sysProps.getKeyReadablePredicate(), - sysProps.getKeyWritablePredicate()); - - sInitialized = true; - } + // Initialization is now done by RavenwoodAwareTestRunner. + // Should we remove it? } /** |