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

Commit efcd9ad5 authored by fionaxu's avatar fionaxu Committed by android-build-merger
Browse files

Merge "fix TelephonyNetworkFactory unit test failure"

am: 4b08927a

Change-Id: Ib08f9c747537c41f1a75a7ca0299a77073050ef6
parents 654f7ec6 4b08927a
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.net.StringNetworkSpecifier;
import android.os.Binder;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
@@ -65,18 +64,29 @@ public class TelephonyNetworkFactoryTest extends AndroidTestCase {
        final Looper looper;
        DcTrackerMock dcTrackerMock;
        final Context contextMock;
        private Object mLock = new Object();
        private static final int MAX_INIT_WAIT_MS = 30000; // 30 seconds

        TestSetup(int numPhones) {
            handlerThread = new HandlerThread("TelephonyNetworkFactoryTest");
            handlerThread.start();
            looper = handlerThread.getLooper();

            Handler myHandler = new Handler(looper) {
                public void handleMessage(Message msg) {
            handlerThread = new HandlerThread("TelephonyNetworkFactoryTest") {
                @Override
                public void onLooperPrepared() {
                    synchronized (mLock) {
                        if (dcTrackerMock == null) dcTrackerMock = new DcTrackerMock();
                        mLock.notifyAll();
                    }
                }
            };
            myHandler.obtainMessage(0).sendToTarget();
            handlerThread.start();
            // wait until dct created
            synchronized (mLock) {
                try {
                    mLock.wait(MAX_INIT_WAIT_MS);
                } catch (InterruptedException ie) {
                }
                if (dcTrackerMock == null) fail("failed to initialize dct");
            }
            looper = handlerThread.getLooper();

            final ContextFixture contextFixture = new ContextFixture();
            String[] networkConfigString = getContext().getResources().getStringArray(