Merge changes I98573a5c,Ic7394f24

* changes:
  Enable checks for MANAGE_TEST_NETWORKS in TestNetworkService
  Cleanup of Test Network service
This commit is contained in:
Benedict Wong
2019-04-10 17:06:17 +00:00
committed by Gerrit Code Review
3 changed files with 5 additions and 14 deletions

View File

@@ -27,8 +27,6 @@ import android.os.Parcelable;
*/
@TestApi
public final class TestNetworkInterface implements Parcelable {
private static final String TAG = "TestNetworkInterface";
private final ParcelFileDescriptor mFileDescriptor;
private final String mInterfaceName;

View File

@@ -17,7 +17,6 @@ package android.net;
import android.annotation.NonNull;
import android.annotation.TestApi;
import android.content.Context;
import android.os.IBinder;
import android.os.RemoteException;
@@ -33,11 +32,9 @@ public class TestNetworkManager {
@NonNull private static final String TAG = TestNetworkManager.class.getSimpleName();
@NonNull private final ITestNetworkManager mService;
@NonNull private final Context mContext;
/** @hide */
public TestNetworkManager(@NonNull Context context, @NonNull ITestNetworkManager service) {
mContext = Preconditions.checkNotNull(context, "missing Context");
public TestNetworkManager(@NonNull ITestNetworkManager service) {
mService = Preconditions.checkNotNull(service, "missing ITestNetworkManager");
}

View File

@@ -310,7 +310,7 @@ class TestNetworkService extends ITestNetworkManager.Stub {
public void teardownTestNetwork(int netId) {
enforceTestNetworkPermissions(mContext);
TestNetworkAgent agent;
final TestNetworkAgent agent;
synchronized (mTestNetworkTracker) {
agent = mTestNetworkTracker.get(netId);
}
@@ -325,14 +325,10 @@ class TestNetworkService extends ITestNetworkManager.Stub {
agent.teardown();
}
// STOPSHIP: Change this back to android.Manifest.permission.MANAGE_TEST_NETWORKS
private static final String PERMISSION_NAME = "dummy";
private static final String PERMISSION_NAME =
android.Manifest.permission.MANAGE_TEST_NETWORKS;
public static void enforceTestNetworkPermissions(@NonNull Context context) {
// STOPSHIP: Re-enable these checks. Disabled until adoptShellPermissionIdentity() can be
// called from CTS test code.
if (false) {
context.enforceCallingOrSelfPermission(PERMISSION_NAME, "TestNetworkService");
}
context.enforceCallingOrSelfPermission(PERMISSION_NAME, "TestNetworkService");
}
}