Skip to content
Snippets Groups Projects
Commit dace79b0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix EthernetTetheringTest failure if tethering is not supported"

parents b68d3225 45fb1aae
No related branches found
No related tags found
No related merge requests found
...@@ -102,17 +102,21 @@ public class EthernetTetheringTest { ...@@ -102,17 +102,21 @@ public class EthernetTetheringTest {
private UiAutomation mUiAutomation = private UiAutomation mUiAutomation =
InstrumentationRegistry.getInstrumentation().getUiAutomation(); InstrumentationRegistry.getInstrumentation().getUiAutomation();
private boolean mRunTests;
@Before @Before
public void setUp() throws Exception { 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 // Needed to create a TestNetworkInterface, to call requestTetheredInterface, and to receive
// tethered client callbacks. // tethered client callbacks.
mUiAutomation.adoptShellPermissionIdentity( mUiAutomation.adoptShellPermissionIdentity(
MANAGE_TEST_NETWORKS, NETWORK_SETTINGS, TETHER_PRIVILEGED); 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 { private void cleanUp() throws Exception {
...@@ -136,7 +140,7 @@ public class EthernetTetheringTest { ...@@ -136,7 +140,7 @@ public class EthernetTetheringTest {
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
try { try {
cleanUp(); if (mRunTests) cleanUp();
} finally { } finally {
mUiAutomation.dropShellPermissionIdentity(); mUiAutomation.dropShellPermissionIdentity();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment