From f0766dc9e19bf3fbce8288731847005c2cd81563 Mon Sep 17 00:00:00 2001 From: Patrick Rohr Date: Tue, 2 Apr 2024 08:32:41 -0700 Subject: [PATCH] Align APF capabilities test closer to VSR requirements This change cleans up the APF capabilities test and aligns it closer to what is written in the VSR preview: https://androidpartner.devsite.corp.google.com/gms/policies/preview/reqs#gms-vsr-apf This includes changing VSR API level checks to compare against literal values, as vendor API levels do not match SDK levels anymore starting with 202404. See docs for more information: https://g3doc.corp.google.com/wireless/android/partner/compatibility/g3doc/dev/write-a-test/index.md?cl=head#write-a-test-depending-on-api-level This test should also purely be based on the VSR API level, so the DevSdkIgnoreRule and assumption check in setUp() are being removed. Test: TH Change-Id: I1f80ee662721557ec63694302fa0f66a666ceeb1 --- .../src/android/net/cts/ApfIntegrationTest.kt | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt b/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt index 64897c09a7..b91dee859b 100644 --- a/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt +++ b/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt @@ -21,14 +21,13 @@ import android.net.ConnectivityManager import android.net.NetworkCapabilities import android.net.NetworkRequest import android.net.apf.ApfCapabilities -import android.os.Build import android.platform.test.annotations.AppModeFull import android.provider.DeviceConfig import android.provider.DeviceConfig.NAMESPACE_CONNECTIVITY import android.system.OsConstants import androidx.test.platform.app.InstrumentationRegistry +import com.android.compatibility.common.util.PropertyUtil.getVsrApiLevel import com.android.compatibility.common.util.SystemUtil.runShellCommand -import com.android.testutils.DevSdkIgnoreRule import com.android.testutils.DevSdkIgnoreRunner import com.android.testutils.NetworkStackModuleTest import com.android.testutils.RecorderCallback.CallbackEntry.LinkPropertiesChanged @@ -49,7 +48,6 @@ private const val APF_NEW_RA_FILTER_VERSION = "apf_new_ra_filter_version" @AppModeFull(reason = "CHANGE_NETWORK_STATE permission can't be granted to instant apps") @RunWith(DevSdkIgnoreRunner::class) @NetworkStackModuleTest -@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.TIRAMISU) class ApfIntegrationTest { companion object { @BeforeClass @@ -89,7 +87,6 @@ class ApfIntegrationTest { @Before fun setUp() { assume().that(pm.hasSystemFeature(FEATURE_WIFI)).isTrue() - assume().that(isVendorApiLevelNewerThan(Build.VERSION_CODES.TIRAMISU)).isTrue() networkCallback = TestableNetworkCallback() cm.requestNetwork( NetworkRequest.Builder() @@ -120,12 +117,31 @@ class ApfIntegrationTest { } @Test - fun testGetApfCapabilities() { + fun testApfCapabilities() { + // APF became mandatory in Android 14 VSR. + assume().that(getVsrApiLevel()).isAtLeast(34) + + // ApfFilter does not support anything but ARPHRD_ETHER. + assertThat(caps.apfPacketFormat).isEqualTo(OsConstants.ARPHRD_ETHER) + + // DEVICEs launching with Android 14 with CHIPSETs that set ro.board.first_api_level to 34: + // - [GMS-VSR-5.3.12-003] MUST return 4 or higher as the APF version number from calls to + // the getApfPacketFilterCapabilities HAL method. + // - [GMS-VSR-5.3.12-004] MUST indicate at least 1024 bytes of usable memory from calls to + // the getApfPacketFilterCapabilities HAL method. + // TODO: check whether above text should be changed "34 or higher" + // This should assert apfVersionSupported >= 4 as per the VSR requirements, but there are + // currently no tests for APFv6 and there cannot be a valid implementation as the + // interpreter has yet to be finalized. assertThat(caps.apfVersionSupported).isEqualTo(4) assertThat(caps.maximumApfProgramSize).isAtLeast(1024) - if (isVendorApiLevelNewerThan(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)) { + + // DEVICEs launching with Android 15 (AOSP experimental) or higher with CHIPSETs that set + // ro.board.first_api_level or ro.board.api_level to 202404 or higher: + // - [GMS-VSR-5.3.12-009] MUST indicate at least 2000 bytes of usable memory from calls to + // the getApfPacketFilterCapabilities HAL method. + if (getVsrApiLevel() >= 202404) { assertThat(caps.maximumApfProgramSize).isAtLeast(2000) } - assertThat(caps.apfPacketFormat).isEqualTo(OsConstants.ARPHRD_ETHER) } }