Add generic createTestInterface to AutoCloseTestInterfaceRule
Test: TH Change-Id: Ib0519f99417c94f3ae77ab1d56a81fe1fd167c0c
This commit is contained in:
parent
4b2ed85ddb
commit
bd9376982e
1 changed files with 9 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ import android.Manifest.permission.MANAGE_TEST_NETWORKS
|
|||
import android.content.Context
|
||||
import android.net.TestNetworkInterface
|
||||
import android.net.TestNetworkManager
|
||||
import android.net.TestNetworkManager.TestInterfaceRequest
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
|
|
@ -40,6 +41,14 @@ class AutoCloseTestInterfaceRule(
|
|||
}
|
||||
}
|
||||
|
||||
fun createTestInterface(req: TestInterfaceRequest): TestNetworkInterface {
|
||||
return runAsShell(MANAGE_TEST_NETWORKS) {
|
||||
tnm.createTestInterface(req)
|
||||
}.also {
|
||||
ifaces.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun closeAllInterfaces() {
|
||||
// TODO: wait on RTM_DELLINK before proceeding.
|
||||
for (iface in ifaces) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue