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) } }