summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTsu Chiang Chuang <tsu@google.com>2012-02-15 17:40:05 -0800
committerTsu Chiang Chuang <tsu@google.com>2012-02-16 14:46:02 -0800
commit4fe25f693ad311556fb232c352ed0b84d59343a5 (patch)
tree5b2d587e92117b740d3bf8549f24fdccfa554bbd
parenta8c57bf6adf3bdd477ce4d6ed8cca031c66830cd (diff)
downloadframeworks_base-4fe25f693ad311556fb232c352ed0b84d59343a5.zip
frameworks_base-4fe25f693ad311556fb232c352ed0b84d59343a5.tar.gz
frameworks_base-4fe25f693ad311556fb232c352ed0b84d59343a5.tar.bz2
fix NPE in race condition.
Change-Id: Ic1df67f8a5379ff1cd804fb55e143f078e369ccf
-rw-r--r--core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java
index 7499f68..8d778c4 100644
--- a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java
+++ b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java
@@ -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() +