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

Commit 4fe25f69 authored by Tsu Chiang Chuang's avatar Tsu Chiang Chuang
Browse files

fix NPE in race condition.

Change-Id: Ic1df67f8a5379ff1cd804fb55e143f078e369ccf
parent a8c57bf6
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import com.android.bandwidthtest.NetworkState;
import com.android.bandwidthtest.NetworkState.StateTransitionDirection;
import com.android.internal.util.AsyncChannel;

import junit.framework.Assert;

import java.io.IOException;
import java.net.UnknownHostException;
import java.util.List;
@@ -453,6 +455,11 @@ public class ConnectionUtil {
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (mNetworkInfo == null) {
                    Log.v(LOG_TAG, "Do not have networkInfo! Force fetch of network info.");
                    mNetworkInfo = mCM.getActiveNetworkInfo();
                    Assert.assertNotNull(mNetworkInfo);
                }
                if ((mNetworkInfo.getType() != networkType) ||
                        (mNetworkInfo.getState() != expectedState)) {
                    Log.v(LOG_TAG, "network state for " + mNetworkInfo.getType() +