Test API behavior change in standalone test case
In previous CL, the behavior was modified in the module,
but the test was not skipped for T device with unmodified module,
which usually happens in some specific test suites, e.g. wifi MTS.
Move the assertion to another test and annotate with
@ConnectivityModuleTest to indicate that the test needs
to be executed with updated module to prevent from breaking
the test.
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.ConnectivityManagerTest# \
testRegisterNetworkCallback
on tm-qpr-dev devices
Fix: 258471863
Change-Id: Ifb3d1ac45ebde727ad719b45497ab458ad0a4b7a
diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
index 05e84b7..8d9a019 100644
--- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -1052,14 +1052,6 @@
}, NETWORK_SETTINGS);
registerBestMatchingNetworkCallback(makeDefaultRequest(), bestMatchingCallback, h);
}
- if (TestUtils.shouldTestTApis()) {
- // Verify registerSystemDefaultNetworkCallback can be accessed via
- // CONNECTIVITY_USE_RESTRICTED_NETWORKS permission.
- final TestNetworkCallback systemDefaultCallback2 = new TestNetworkCallback();
- runWithShellPermissionIdentity(() ->
- registerSystemDefaultNetworkCallback(systemDefaultCallback2, h),
- CONNECTIVITY_USE_RESTRICTED_NETWORKS);
- }
Network wifiNetwork = null;
mCtsNetUtils.ensureWifiConnected();
@@ -1089,6 +1081,18 @@
}
}
+ @ConnectivityModuleTest
+ @IgnoreUpTo(Build.VERSION_CODES.R)
+ @Test
+ public void testRegisterSystemDefaultNetworkCallbackPermission() {
+ final Handler h = new Handler(Looper.getMainLooper());
+ // Verify registerSystemDefaultNetworkCallback can be accessed via
+ // CONNECTIVITY_USE_RESTRICTED_NETWORKS permission.
+ runWithShellPermissionIdentity(() ->
+ registerSystemDefaultNetworkCallback(new TestNetworkCallback(), h),
+ CONNECTIVITY_USE_RESTRICTED_NETWORKS);
+ }
+
/**
* Tests both registerNetworkCallback and unregisterNetworkCallback similarly to
* {@link #testRegisterNetworkCallback} except that a {@code PendingIntent} is used instead