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

Commit f118cdaa authored by Nathan Harold's avatar Nathan Harold
Browse files

Update the waitUntilReady/setReady logic to use java blocking

-Replace the while(!ready()) { checkReady() } logic to use
the java wait() and notifyAll() methods.

-Set a maximum timeout of 30s for a test to report that is
 is ready

Bug: 38512268
Test: runtest frameworks-telephony
Change-Id: I60c520d985a742c42baf7999079feeb726a27a99
parent f90dc616
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ import java.util.concurrent.TimeUnit;
public abstract class TelephonyTest {
    protected static String TAG;

    private static final int MAX_INIT_WAIT_MS = 30000; // 30 seconds

    @Mock
    protected GsmCdmaPhone mPhone;
    @Mock
@@ -224,11 +226,14 @@ public abstract class TelephonyTest {
    }

    protected void waitUntilReady() {
        while (true) {
        synchronized (mLock) {
                if (mReady) {
                    break;
            try {
                mLock.wait(MAX_INIT_WAIT_MS);
            } catch (InterruptedException ie) {
            }

            if (!mReady) {
                fail("Telephony tests failed to initialize");
            }
        }
    }
@@ -236,6 +241,7 @@ public abstract class TelephonyTest {
    protected void setReady(boolean ready) {
        synchronized (mLock) {
            mReady = ready;
            mLock.notifyAll();
        }
    }