Loading ravenwood/Android.bp +4 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,9 @@ java_library_host { srcs: [ "runtime-helper-src/libcore-fake/**/*.java", ], libs: [ "app-compat-annotations", ], static_libs: [ "ravenwood-runtime-common", ], Loading @@ -121,6 +124,7 @@ java_library { ], static_libs: [ "ravenwood-runtime-common", "androidx.annotation_annotation", ], libs: [ "framework-minus-apex.ravenwood", Loading ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodConfigState.java +4 −0 Original line number Diff line number Diff line Loading @@ -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; } Loading ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java +12 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); Loading Loading @@ -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(); Loading ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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()); Loading ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ public final class RavenwoodConfig { String mTargetPackageName; int mMinSdkLevel; int mTargetSdkLevel; boolean mProvideMainThread = false; Loading Loading @@ -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 Loading
ravenwood/Android.bp +4 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,9 @@ java_library_host { srcs: [ "runtime-helper-src/libcore-fake/**/*.java", ], libs: [ "app-compat-annotations", ], static_libs: [ "ravenwood-runtime-common", ], Loading @@ -121,6 +124,7 @@ java_library { ], static_libs: [ "ravenwood-runtime-common", "androidx.annotation_annotation", ], libs: [ "framework-minus-apex.ravenwood", Loading
ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodConfigState.java +4 −0 Original line number Diff line number Diff line Loading @@ -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; } Loading
ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java +12 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); Loading Loading @@ -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(); Loading
ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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()); Loading
ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ public final class RavenwoodConfig { String mTargetPackageName; int mMinSdkLevel; int mTargetSdkLevel; boolean mProvideMainThread = false; Loading Loading @@ -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