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 Merged-In: I86eef7a93267f800dbfc8eafd307effa76a344ca (cherry picked from commit 3410fb0aa92bbd4f9d7dc031e89f6f528ff34245)
This commit is contained in:
@@ -30,6 +30,18 @@ import com.android.internal.util.Preconditions;
|
|||||||
*/
|
*/
|
||||||
@TestApi
|
@TestApi
|
||||||
public class TestNetworkManager {
|
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 static final String TAG = TestNetworkManager.class.getSimpleName();
|
||||||
|
|
||||||
@NonNull private final ITestNetworkManager mService;
|
@NonNull private final ITestNetworkManager mService;
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.server;
|
package com.android.server;
|
||||||
|
|
||||||
|
import static android.net.TestNetworkManager.TEST_TAP_PREFIX;
|
||||||
|
import static android.net.TestNetworkManager.TEST_TUN_PREFIX;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -60,8 +63,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
class TestNetworkService extends ITestNetworkManager.Stub {
|
class TestNetworkService extends ITestNetworkManager.Stub {
|
||||||
@NonNull private static final String TAG = TestNetworkService.class.getSimpleName();
|
@NonNull private static final String TAG = TestNetworkService.class.getSimpleName();
|
||||||
@NonNull private static final String TEST_NETWORK_TYPE = "TEST_NETWORK";
|
@NonNull private static final String TEST_NETWORK_TYPE = "TEST_NETWORK";
|
||||||
@NonNull private static final String TEST_TUN_PREFIX = "testtun";
|
|
||||||
@NonNull private static final String TEST_TAP_PREFIX = "testtap";
|
|
||||||
@NonNull private static final AtomicInteger sTestTunIndex = new AtomicInteger();
|
@NonNull private static final AtomicInteger sTestTunIndex = new AtomicInteger();
|
||||||
|
|
||||||
@NonNull private final Context mContext;
|
@NonNull private final Context mContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user