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

Commit 93611796 authored by Makoto Onuki's avatar Makoto Onuki Committed by Gerrit Code Review
Browse files

Merge "Prepare for compat-framework support" into main

parents 6dbe4c01 172f2a03
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -100,6 +100,9 @@ java_library_host {
    srcs: [
        "runtime-helper-src/libcore-fake/**/*.java",
    ],
    libs: [
        "app-compat-annotations",
    ],
    static_libs: [
        "ravenwood-runtime-common",
    ],
@@ -121,6 +124,7 @@ java_library {
    ],
    static_libs: [
        "ravenwood-runtime-common",
        "androidx.annotation_annotation",
    ],
    libs: [
        "framework-minus-apex.ravenwood",
+4 −0
Original line number Diff line number Diff line
@@ -42,6 +42,10 @@ public class RavenwoodConfigState {

    private final RavenwoodConfig mConfig;

    // TODO: Move the other contexts from RavenwoodConfig to here too? They're used by
    // RavenwoodRule too, but RavenwoodRule can probably use InstrumentationRegistry?
    RavenwoodContext mSystemServerContext;

    public RavenwoodConfigState(RavenwoodConfig config) {
        mConfig = config;
    }
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.platform.test.ravenwood;

import static android.platform.test.ravenwood.RavenwoodSystemServer.ANDROID_PACKAGE_NAME;

import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_INST_RESOURCE_APK;
import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_RESOURCE_APK;
import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING;
@@ -267,6 +269,13 @@ public class RavenwoodRuntimeEnvironmentController {
        config.mInstContext = instContext;
        config.mTargetContext = targetContext;

        final Supplier<Resources> systemResourcesLoader = () -> {
            return config.mState.loadResources(null);
        };

        config.mState.mSystemServerContext =
                new RavenwoodContext(ANDROID_PACKAGE_NAME, main, systemResourcesLoader);

        // Prepare other fields.
        config.mInstrumentation = new Instrumentation();
        config.mInstrumentation.basicInit(instContext, targetContext, createMockUiAutomation());
@@ -314,6 +323,9 @@ public class RavenwoodRuntimeEnvironmentController {
            ((RavenwoodContext) config.mTargetContext).cleanUp();
            config.mTargetContext = null;
        }
        if (config.mState.mSystemServerContext != null) {
            config.mState.mSystemServerContext.cleanUp();
        }

        Looper.getMainLooper().quit();
        Looper.clearMainLooperForTest();
+4 −1
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@ import java.util.List;
import java.util.Set;

public class RavenwoodSystemServer {

    static final String ANDROID_PACKAGE_NAME = "android";

    /**
     * Set of services that we know how to provide under Ravenwood. We keep this set distinct
     * from {@code com.android.server.SystemServer} to give us the ability to choose either
@@ -67,7 +70,7 @@ public class RavenwoodSystemServer {

        sStartedServices = new ArraySet<>();
        sTimings = new TimingsTraceAndSlog();
        sServiceManager = new SystemServiceManager(config.mInstContext);
        sServiceManager = new SystemServiceManager(config.mState.mSystemServerContext);
        sServiceManager.setStartInfo(false,
                SystemClock.elapsedRealtime(),
                SystemClock.uptimeMillis());
+9 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public final class RavenwoodConfig {
    String mTargetPackageName;

    int mMinSdkLevel;
    int mTargetSdkLevel;

    boolean mProvideMainThread = false;

@@ -149,6 +150,14 @@ public final class RavenwoodConfig {
            return this;
        }

        /**
         * Configure the target SDK level of the test.
         */
        public Builder setTargetSdkLevel(int sdkLevel) {
            mConfig.mTargetSdkLevel = sdkLevel;
            return this;
        }

        /**
         * Configure a "main" thread to be available for the duration of the test, as defined
         * by {@code Looper.getMainLooper()}. Has no effect on non-Ravenwood environments.
Loading