Merge "Disable the AppOp Restriction for IpSec Tunnels" into stage-aosp-master
This commit is contained in:
committed by
Android (Google) Code Review
commit
bda7c96038
@@ -1481,19 +1481,23 @@ public class IpSecService extends IIpSecService.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TUNNEL_OP = "STOPSHIP"; // = AppOpsManager.OP_MANAGE_IPSEC_TUNNELS;
|
||||
|
||||
private void enforceTunnelPermissions(String callingPackage) {
|
||||
checkNotNull(callingPackage, "Null calling package cannot create IpSec tunnels");
|
||||
switch (getAppOpsManager().noteOp(
|
||||
AppOpsManager.OP_MANAGE_IPSEC_TUNNELS,
|
||||
Binder.getCallingUid(), callingPackage)) {
|
||||
case AppOpsManager.MODE_DEFAULT:
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.MANAGE_IPSEC_TUNNELS, "IpSecService");
|
||||
break;
|
||||
case AppOpsManager.MODE_ALLOWED:
|
||||
return;
|
||||
default:
|
||||
throw new SecurityException("Request to ignore AppOps for non-legacy API");
|
||||
if (false) { // STOPSHIP if this line is present
|
||||
switch (getAppOpsManager().noteOp(
|
||||
TUNNEL_OP,
|
||||
Binder.getCallingUid(), callingPackage)) {
|
||||
case AppOpsManager.MODE_DEFAULT:
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.MANAGE_IPSEC_TUNNELS, "IpSecService");
|
||||
break;
|
||||
case AppOpsManager.MODE_ALLOWED:
|
||||
return;
|
||||
default:
|
||||
throw new SecurityException("Request to ignore AppOps for non-legacy API");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
@@ -592,6 +593,7 @@ public class IpSecServiceParameterizedTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testAddTunnelFailsForBadPackageName() throws Exception {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user