Downgrade Log message level from WTF to WARN for null BSSID case.
Rarely ScanResultInfo might be null when starting provisioning,
for example, switch between different APs frequently. So when L2
roaming happens the current tracked bssid is null, which throws
WTF log message. Downgrade the Log level to WARN in R before WiFi
framework fixes the null BSSID issue temporarily.
Bug: 160217503
Test: atest NetworkStackTests NetworkStackIntegrationTests
Original change: https://android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/1385757
Merged-In: Iaa48f6ac357c22c7cbcba734bdaa787f133d1858
(cherry picked from commit ecfabade888a3a1a8af0a6038f42a355d7cfd13e)
Change-Id: I8fb261203450239a16511d0b055c9c5bf2379f3f
diff --git a/apishim/common/com/android/networkstack/apishim/common/ShimUtils.java b/apishim/common/com/android/networkstack/apishim/common/ShimUtils.java
index d78cd0c..648751b 100644
--- a/apishim/common/com/android/networkstack/apishim/common/ShimUtils.java
+++ b/apishim/common/com/android/networkstack/apishim/common/ShimUtils.java
@@ -49,4 +49,11 @@
public static boolean isAtLeastR() {
return isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q);
}
+
+ /**
+ * Check whether the device supports in-development or final S networking APIs.
+ */
+ public static boolean isAtLeastS() {
+ return isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.R);
+ }
}
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java
index c4f46ae..6711ef2 100644
--- a/src/android/net/ip/IpClient.java
+++ b/src/android/net/ip/IpClient.java
@@ -1601,8 +1601,16 @@
mL2Key = info.l2Key;
mCluster = info.cluster;
+ // Sometimes the wifi code passes in a null BSSID. Don't use Log.wtf in R because
+ // it's a known bug that will not be fixed in R.
if (info.bssid == null || mCurrentBssid == null) {
- Log.wtf(mTag, "bssid in the parcelable or current tracked bssid should be non-null");
+ final String msg = "bssid in the parcelable: " + info.bssid + " or "
+ + "current tracked bssid: " + mCurrentBssid + " is null";
+ if (ShimUtils.isAtLeastS()) {
+ Log.wtf(mTag, msg);
+ } else {
+ Log.w(mTag, msg);
+ }
return;
}
diff --git a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java
index 38eb84e..668686c 100644
--- a/tests/integration/src/android/net/ip/IpClientIntegrationTest.java
+++ b/tests/integration/src/android/net/ip/IpClientIntegrationTest.java
@@ -2097,7 +2097,8 @@
private void doDhcpRoamingTest(final boolean hasMismatchedIpAddress, final String displayName,
final String ssid, final String bssid, final boolean expectRoaming) throws Exception {
long currentTime = System.currentTimeMillis();
- final ScanResultInfo scanResultInfo = makeScanResultInfo(ssid, bssid);
+ final ScanResultInfo scanResultInfo = (ssid == null || bssid == null)
+ ? null : makeScanResultInfo(ssid, bssid);
doAnswer(invocation -> {
// we don't rely on the Init-Reboot state to renew previous cached IP lease.
@@ -2172,6 +2173,12 @@
}
@Test
+ public void testDhcpRoaming_nullScanResultInfo() throws Exception {
+ doDhcpRoamingTest(false /* hasMismatchedIpAddress */, "\"0001docomo\"" /* display name */,
+ null /* SSID */, null /* BSSID */, false /* expectRoaming */);
+ }
+
+ @Test
public void testDhcpRoaming_invalidSsid() throws Exception {
doDhcpRoamingTest(false /* hasMismatchedIpAddress */, "\"0001docomo\"" /* display name */,
TEST_DEFAULT_SSID, TEST_DEFAULT_BSSID, false /* expectRoaming */);