Make Ethernet interfaces more testable.
This CL adds a setIncludeTestInterfaces method to EthernetManager that, when called, causes the Ethernet service to recognize and manage test interfaces created by TestNetworkManager. Bug: 150644681 Test: Tested by EthernetTetheringTest in same topic Change-Id: I86eef7a93267f800dbfc8eafd307effa76a344ca
This commit is contained in:
@@ -199,6 +199,21 @@ public class EthernetManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to treat interfaces created by {@link TestNetworkManager#createTapInterface}
|
||||
* as Ethernet interfaces. The effects of this method apply to any test interfaces that are
|
||||
* already present on the system.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public void setIncludeTestInterfaces(boolean include) {
|
||||
try {
|
||||
mService.setIncludeTestInterfaces(include);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A request for a tethered interface.
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,7 @@ interface IEthernetManager
|
||||
boolean isAvailable(String iface);
|
||||
void addListener(in IEthernetServiceListener listener);
|
||||
void removeListener(in IEthernetServiceListener listener);
|
||||
void setIncludeTestInterfaces(boolean include);
|
||||
void requestTetheredInterface(in ITetheredInterfaceCallback callback);
|
||||
void releaseTetheredInterface(in ITetheredInterfaceCallback callback);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,18 @@ import com.android.internal.util.Preconditions;
|
||||
*/
|
||||
@TestApi
|
||||
public class TestNetworkManager {
|
||||
/**
|
||||
* Prefix for tun interfaces created by this class.
|
||||
* @hide
|
||||
*/
|
||||
public static final String TEST_TUN_PREFIX = "testtun";
|
||||
|
||||
/**
|
||||
* Prefix for tap interfaces created by this class.
|
||||
* @hide
|
||||
*/
|
||||
public static final String TEST_TAP_PREFIX = "testtap";
|
||||
|
||||
@NonNull private static final String TAG = TestNetworkManager.class.getSimpleName();
|
||||
|
||||
@NonNull private final ITestNetworkManager mService;
|
||||
|
||||
Reference in New Issue
Block a user