Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7dabb818 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow junit-impl to see runtime-helper-src" into main

parents 7164ab54 c317d4a2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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"],
+8 −0
Original line number Diff line number Diff line
@@ -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);
    }

    /**
+2 −32
Original line number Diff line number Diff line
@@ -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?
    }

    /**