Skip network requests in MultinetworkApiTest for instant mode

MultinetworkApiTest would attempt to request cellular and Wi-Fi
network connections in test setup. This requires the
CHANGE_NETWORK_STATE permission, which is not granted to
the instant app. Therefore, skip the network requests if the
tests are running in instant mode.

Bug: 413261962
Test: atest android.net.cts.MultinetworkApiTest --instant
Flag: EXEMPT bug fix
Change-Id: I64366a4f2528402d3050adb54bb0aea352c53088
This commit is contained in:
Paul Hu 2025-05-06 02:39:52 +00:00
commit 37c39d0af6

View file

@ -112,8 +112,12 @@ public class MultinetworkApiTest {
final Context context = InstrumentationRegistry.getInstrumentation().getContext();
mCM = context.getSystemService(ConnectivityManager.class);
mCtsNetUtils = new CtsNetUtils(context);
mNetworkCallbackRule.requestCellIfSupported();
mNetworkCallbackRule.requestWifiIfSupported();
// In instant mode, do not request cell or Wi-Fi connection, as this requires the
// CHANGE_NETWORK_STATE permission which cannot be granted.
if (!context.getApplicationInfo().isInstantApp()) {
mNetworkCallbackRule.requestCellIfSupported();
mNetworkCallbackRule.requestWifiIfSupported();
}
}
@Test