Merge "Revert "Add onSupportedTetheringType callback""

This commit is contained in:
Mark Chien
2022-07-12 07:30:50 +00:00
committed by Gerrit Code Review
6 changed files with 50 additions and 200 deletions

View File

@@ -192,13 +192,12 @@ public class EthernetTetheringTest {
mUiAutomation.adoptShellPermissionIdentity(
MANAGE_TEST_NETWORKS, NETWORK_SETTINGS, TETHER_PRIVILEGED, ACCESS_NETWORK_STATE,
CONNECTIVITY_USE_RESTRICTED_NETWORKS, DUMP);
mRunTests = mTm.isTetheringSupported() && mEm != null;
assumeTrue(mRunTests);
mHandlerThread = new HandlerThread(getClass().getSimpleName());
mHandlerThread.start();
mHandler = new Handler(mHandlerThread.getLooper());
mRunTests = isEthernetTetheringSupported();
assumeTrue(mRunTests);
mTetheredInterfaceRequester = new TetheredInterfaceRequester(mHandler, mEm);
}
@@ -226,6 +225,7 @@ public class EthernetTetheringTest {
mHandler.post(() -> reader.stop());
mDownstreamReader = null;
}
mHandlerThread.quitSafely();
mTetheredInterfaceRequester.release();
mEm.setIncludeTestInterfaces(false);
maybeDeleteTestInterface();
@@ -236,7 +236,6 @@ public class EthernetTetheringTest {
try {
if (mRunTests) cleanUp();
} finally {
mHandlerThread.quitSafely();
mUiAutomation.dropShellPermissionIdentity();
}
}
@@ -411,23 +410,6 @@ public class EthernetTetheringTest {
// client, which is not possible in this test.
}
private boolean isEthernetTetheringSupported() throws Exception {
final CompletableFuture<Boolean> future = new CompletableFuture<>();
final TetheringEventCallback callback = new TetheringEventCallback() {
@Override
public void onSupportedTetheringTypes(Set<Integer> supportedTypes) {
future.complete(supportedTypes.contains(TETHERING_ETHERNET));
}
};
try {
mTm.registerTetheringEventCallback(mHandler::post, callback);
return future.get(TIMEOUT_MS, TimeUnit.MILLISECONDS);
} finally {
mTm.unregisterTetheringEventCallback(callback);
}
}
private static final class MyTetheringEventCallback implements TetheringEventCallback {
private final TetheringManager mTm;
private final CountDownLatch mTetheringStartedLatch = new CountDownLatch(1);