diff --git a/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java b/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java index 74df11370e50d1b64221c08e2635bd93b740c99e..c93a86bf532a70e0289a98897d7fbfa75c2a6eab 100644 --- a/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java +++ b/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java @@ -101,17 +101,21 @@ public class EthernetTetheringTest { private UiAutomation mUiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation(); + private boolean mRunTests; @Before public void setUp() throws Exception { - mHandlerThread = new HandlerThread(getClass().getSimpleName()); - mHandlerThread.start(); - mHandler = new Handler(mHandlerThread.getLooper()); - mTetheredInterfaceRequester = new TetheredInterfaceRequester(mHandler, mEm); // Needed to create a TestNetworkInterface, to call requestTetheredInterface, and to receive // tethered client callbacks. mUiAutomation.adoptShellPermissionIdentity( MANAGE_TEST_NETWORKS, NETWORK_SETTINGS, TETHER_PRIVILEGED); + mRunTests = mTm.isTetheringSupported() && mEm != null; + assumeTrue(mRunTests); + + mHandlerThread = new HandlerThread(getClass().getSimpleName()); + mHandlerThread.start(); + mHandler = new Handler(mHandlerThread.getLooper()); + mTetheredInterfaceRequester = new TetheredInterfaceRequester(mHandler, mEm); } private void cleanUp() throws Exception { @@ -135,7 +139,7 @@ public class EthernetTetheringTest { @After public void tearDown() throws Exception { try { - cleanUp(); + if (mRunTests) cleanUp(); } finally { mUiAutomation.dropShellPermissionIdentity(); }