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

Commit 31b46953 authored by Alex Chau's avatar Alex Chau
Browse files

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
parent 3c229866
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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> T getOnUiThread(final Callable<T> 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);
        }