From 31b46953cb3205d0da971bd9950c18ca4305afa0 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Mon, 22 Nov 2021 12:25:51 +0000 Subject: [PATCH] Add timeout to AbstractLauncherUiTest.getOnUiThread - Send signal 6 to Launcher process when this happens to get a thread dump Bug: 203416429 Test: labtest Change-Id: If22b58418be33131e7f585e718a2197cda2e7365 --- .../com/android/launcher3/ui/AbstractLauncherUiTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java index 44f2719a02..19dca45794 100644 --- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java +++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java @@ -38,6 +38,7 @@ import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserManager; +import android.system.OsConstants; import android.util.Log; import androidx.test.InstrumentationRegistry; @@ -83,6 +84,7 @@ import java.lang.annotation.Target; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -327,7 +329,12 @@ public abstract class AbstractLauncherUiTest { */ protected T getOnUiThread(final Callable callback) { try { - return mMainThreadExecutor.submit(callback).get(); + return mMainThreadExecutor.submit(callback).get(DEFAULT_UI_TIMEOUT, + TimeUnit.MILLISECONDS); + } catch (TimeoutException e) { + Log.e(TAG, "Timeout in getOnUiThread, sending SIGABRT", e); + Process.sendSignal(Process.myPid(), OsConstants.SIGABRT); + throw new RuntimeException(e); } catch (Throwable e) { throw new RuntimeException(e); }