Give EthernetTetheringTest the restricted networks permission.

This test fails on devices where physical Ethernet interfaces are
available but marked restricted, like cuttlefish.

Bug: 197462993
Bug: 197910181
Test: test-only change

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1807157

Change-Id: I04ccf491be12236dffb5ba4972fac35946fc6896
Merged-In: I04ccf491be12236dffb5ba4972fac35946fc6896
Merged-In: I15c991b2e43e2d5e823dcdcfbd74adfd9b2f6f08
This commit is contained in:
Lorenzo Colitti
2021-08-24 09:45:33 +00:00
committed by Mark Chien
parent 28c8a63f3a
commit eca2ef2d5e

View File

@@ -17,6 +17,7 @@
package android.net;
import static android.Manifest.permission.ACCESS_NETWORK_STATE;
import static android.Manifest.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS;
import static android.Manifest.permission.MANAGE_TEST_NETWORKS;
import static android.Manifest.permission.NETWORK_SETTINGS;
import static android.Manifest.permission.TETHER_PRIVILEGED;
@@ -121,9 +122,12 @@ public class EthernetTetheringTest {
@Before
public void setUp() throws Exception {
// Needed to create a TestNetworkInterface, to call requestTetheredInterface, and to receive
// tethered client callbacks.
// tethered client callbacks. The restricted networks permission is needed to ensure that
// EthernetManager#isAvailable will correctly return true on devices where Ethernet is
// marked restricted, like cuttlefish.
mUiAutomation.adoptShellPermissionIdentity(
MANAGE_TEST_NETWORKS, NETWORK_SETTINGS, TETHER_PRIVILEGED, ACCESS_NETWORK_STATE);
MANAGE_TEST_NETWORKS, NETWORK_SETTINGS, TETHER_PRIVILEGED, ACCESS_NETWORK_STATE,
CONNECTIVITY_USE_RESTRICTED_NETWORKS);
mRunTests = mTm.isTetheringSupported() && mEm != null;
assumeTrue(mRunTests);