summaryrefslogtreecommitdiff
path: root/ravenwood/junit-impl-src/android
diff options
context:
space:
mode:
Diffstat (limited to 'ravenwood/junit-impl-src/android')
-rw-r--r--ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodConfigState.java4
-rw-r--r--ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java12
-rw-r--r--ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java5
3 files changed, 20 insertions, 1 deletions
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodConfigState.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodConfigState.java
index 3535cb2b1b79..870a10a1f57e 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodConfigState.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodConfigState.java
@@ -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;
}
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java
index 9a145cb93811..c2806daf99a1 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java
@@ -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();
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java
index 3946dd8471b0..f198a08a50e3 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java
@@ -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());