Allow junit-impl to see runtime-helper-src
Flag: EXEMPT host test change only
Bug: 292141694
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh
Change-Id: If540b852eaf0dec6b47e94553000444ef533b5ec
diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp
index eebe5e9f..8ff99e4 100644
--- a/ravenwood/Android.bp
+++ b/ravenwood/Android.bp
@@ -129,9 +129,9 @@
],
libs: [
"framework-minus-apex.ravenwood",
- "ravenwood-junit",
"ravenwood-helper-libcore-runtime",
],
+ sdk_version: "core_current",
visibility: ["//visibility:private"],
}
@@ -165,6 +165,8 @@
"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 92a1cb7..68472c1 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 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 @@
// 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 @@
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 3bf116d..e12ff24 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 @@
* 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?
}
/**