Add RequiresPermission to TestNetworkManager

All API methods in TestNetworkManager require the MANAGE_TEST_NETWORKS
permission.

Fixes: 183972672
Test: m
Change-Id: Ic5929c24ea88d7259d367a81fec8f223a2e3ecb0
This commit is contained in:
Remi NGUYEN VAN
2021-04-08 16:08:46 +09:00
parent 62967ab5d5
commit 6671f42bef
2 changed files with 10 additions and 4 deletions

View File

@@ -15,8 +15,10 @@
*/
package android.net;
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.os.IBinder;
import android.os.RemoteException;
@@ -58,6 +60,7 @@ public class TestNetworkManager {
* @param network The test network that should be torn down
* @hide
*/
@RequiresPermission(Manifest.permission.MANAGE_TEST_NETWORKS)
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public void teardownTestNetwork(@NonNull Network network) {
try {
@@ -103,6 +106,7 @@ public class TestNetworkManager {
* @param binder A binder object guarding the lifecycle of this test network.
* @hide
*/
@RequiresPermission(Manifest.permission.MANAGE_TEST_NETWORKS)
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public void setupTestNetwork(@NonNull String iface, @NonNull IBinder binder) {
setupTestNetwork(iface, null, true, new int[0], binder);
@@ -145,6 +149,7 @@ public class TestNetworkManager {
* TUN interface.
* @hide
*/
@RequiresPermission(Manifest.permission.MANAGE_TEST_NETWORKS)
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@NonNull
public TestNetworkInterface createTunInterface(@NonNull Collection<LinkAddress> linkAddrs) {
@@ -163,6 +168,7 @@ public class TestNetworkManager {
* TAP interface.
* @hide
*/
@RequiresPermission(Manifest.permission.MANAGE_TEST_NETWORKS)
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@NonNull
public TestNetworkInterface createTapInterface() {