From 5b8e2e9935490378dc31bc6f759c9ddbd2aee6aa Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Mon, 16 Aug 2021 18:03:37 +0900 Subject: [PATCH] Fix NetworkCapabilities MTS on S, CTS on S+module restrictCapabilitiesForTestNetwork was renamed after S release to be included in a mainline release, but this causes the MTS test to fail on S if the Connectivity module is not updated, and CTS to fail if the connectivity module is updated. Mark the test as @ConnectivityModuleTest so it can be skipped on non-connectivity module MTS tests (such as NetworkStack tests), and add back the previous method name to keep CTS passing. Bug: 196755836 Test: atest NetworkCapabilitiesTest Change-Id: Ibd6c2e62e5949ec6d93e9f6e4fc05129c29b94f8 --- framework/src/android/net/NetworkCapabilities.java | 13 +++++++++++++ .../java/android/net/NetworkCapabilitiesTest.java | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/framework/src/android/net/NetworkCapabilities.java b/framework/src/android/net/NetworkCapabilities.java index 5bd0af894c..447f626163 100644 --- a/framework/src/android/net/NetworkCapabilities.java +++ b/framework/src/android/net/NetworkCapabilities.java @@ -813,6 +813,19 @@ public final class NetworkCapabilities implements Parcelable { } } + /** + * @see #restrictCapabilitiesForTestNetwork(int) + * @deprecated Use {@link #restrictCapabilitiesForTestNetwork(int)} (without the typo) instead. + * @hide + */ + @Deprecated + public void restrictCapabilitesForTestNetwork(int creatorUid) { + // Do not remove without careful consideration: this method has a typo in its name but is + // called by the first S CTS releases, therefore it cannot be removed from the connectivity + // module as long as such CTS releases are valid for testing S devices. + restrictCapabilitiesForTestNetwork(creatorUid); + } + /** * Test networks have strong restrictions on what capabilities they can have. Enforce these * restrictions. diff --git a/tests/common/java/android/net/NetworkCapabilitiesTest.java b/tests/common/java/android/net/NetworkCapabilitiesTest.java index 3d0cb92e78..382fa1f299 100644 --- a/tests/common/java/android/net/NetworkCapabilitiesTest.java +++ b/tests/common/java/android/net/NetworkCapabilitiesTest.java @@ -75,6 +75,7 @@ import android.util.Range; import androidx.test.runner.AndroidJUnit4; import com.android.testutils.CompatUtil; +import com.android.testutils.ConnectivityModuleTest; import com.android.testutils.DevSdkIgnoreRule; import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo; @@ -1168,7 +1169,7 @@ public class NetworkCapabilitiesTest { assertEquals(0, nc.getCapabilities().length); } - @Test @IgnoreUpTo(Build.VERSION_CODES.R) + @Test @IgnoreUpTo(Build.VERSION_CODES.R) @ConnectivityModuleTest public void testRestrictCapabilitiesForTestNetwork() { final int ownerUid = 1234; final int[] administratorUids = {1001, ownerUid};