From 8b4b220d92b4cd36d75c3c6b60051a3bcd2cb219 Mon Sep 17 00:00:00 2001 From: John Wu Date: Wed, 16 Oct 2024 18:08:56 +0000 Subject: [Ravenwood] Always provide main thread It is very difficult for test owners to know whether a main thread is actually required. Besides, the Ravenwood environment itself relies on a main thread. Flag: EXEMPT host test change only Bug: 292141694 Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh Change-Id: I88ed44f00ce6295dcb14619428a2c7a4bea0bbdb --- .../RavenwoodRuntimeEnvironmentController.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'ravenwood/junit-impl-src') 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 24950e65c174..afa7a6c51abb 100644 --- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java +++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java @@ -225,14 +225,9 @@ public class RavenwoodRuntimeEnvironmentController { ActivityManager.init$ravenwood(config.mCurrentUser); - final HandlerThread main; - if (config.mProvideMainThread) { - main = new HandlerThread(MAIN_THREAD_NAME); - main.start(); - Looper.setMainLooperForTest(main.getLooper()); - } else { - main = null; - } + final var main = new HandlerThread(MAIN_THREAD_NAME); + main.start(); + Looper.setMainLooperForTest(main.getLooper()); final boolean isSelfInstrumenting = Objects.equals(config.mTestPackageName, config.mTargetPackageName); @@ -324,10 +319,8 @@ public class RavenwoodRuntimeEnvironmentController { } sMockUiAutomation.dropShellPermissionIdentity(); - if (config.mProvideMainThread) { - Looper.getMainLooper().quit(); - Looper.clearMainLooperForTest(); - } + Looper.getMainLooper().quit(); + Looper.clearMainLooperForTest(); ActivityManager.reset$ravenwood(); -- cgit v1.2.3-59-g8ed1b