From 34748be15064212ca5d0065d8003d37fa3b96f38 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Thu, 13 May 2021 17:20:10 +0900 Subject: [PATCH] Make VcnTransportInfoTest pass on AOSP. AOSP contains the core networking redaction changes, but not the wifi redaction changes, so the tests that depend on wifi S behaviour will not pass on AOSP. Fix testApplicableRedactions by checking that the applicable redactions are the same ones as returned by the underlying WifiInfo object. Fix testMakeCopyRedactForAccessFineLocation by testing the wifi redaction code iff Build.VERSION.SDK_INT is S or later. This is different from SdkLevel.isAtLeastS, because the latter returns true in AOSP. Bug: 183938194 Test: atest VcnTransportInfoTest Change-Id: Ia5bc896c92be19f570638f8051492e0f2d7342f9 --- .../android/net/vcn/VcnTransportInfoTest.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/vcn/java/android/net/vcn/VcnTransportInfoTest.java b/tests/vcn/java/android/net/vcn/VcnTransportInfoTest.java index 00a0bffa15c57..abae81cf17429 100644 --- a/tests/vcn/java/android/net/vcn/VcnTransportInfoTest.java +++ b/tests/vcn/java/android/net/vcn/VcnTransportInfoTest.java @@ -17,8 +17,6 @@ package android.net.vcn; import static android.net.NetworkCapabilities.REDACT_FOR_ACCESS_FINE_LOCATION; -import static android.net.NetworkCapabilities.REDACT_FOR_LOCAL_MAC_ADDRESS; -import static android.net.NetworkCapabilities.REDACT_FOR_NETWORK_SETTINGS; import static android.net.NetworkCapabilities.REDACT_NONE; import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; @@ -28,6 +26,7 @@ import static org.junit.Assert.assertNull; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; +import android.os.Build; import android.os.Parcel; import org.junit.Test; @@ -61,10 +60,14 @@ public class VcnTransportInfoTest { SUB_ID, ((VcnTransportInfo) CELL_UNDERLYING_INFO.makeCopy(REDACT_FOR_ACCESS_FINE_LOCATION)) .getSubId()); - assertEquals( - WifiConfiguration.INVALID_NETWORK_ID, - ((VcnTransportInfo) WIFI_UNDERLYING_INFO.makeCopy(REDACT_FOR_ACCESS_FINE_LOCATION)) - .getWifiInfo().getNetworkId()); + + // TODO: remove the if statement when S pushes to AOSP. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + assertEquals( + WifiConfiguration.INVALID_NETWORK_ID, + ((VcnTransportInfo) WIFI_UNDERLYING_INFO.makeCopy( + REDACT_FOR_ACCESS_FINE_LOCATION)).getWifiInfo().getNetworkId()); + } } @Test @@ -77,9 +80,9 @@ public class VcnTransportInfoTest { @Test public void testApplicableRedactions() { assertEquals(REDACT_NONE, CELL_UNDERLYING_INFO.getApplicableRedactions()); - assertEquals(REDACT_FOR_ACCESS_FINE_LOCATION | REDACT_FOR_LOCAL_MAC_ADDRESS - | REDACT_FOR_NETWORK_SETTINGS, - WIFI_UNDERLYING_INFO.getApplicableRedactions()); + + final long wifiRedactions = WIFI_INFO.getApplicableRedactions(); + assertEquals(wifiRedactions, WIFI_UNDERLYING_INFO.getApplicableRedactions()); } @Test