Mark most VpnServiceTest methods as @AppModeFull.

In S, instant apps can no longer access the system service that
backs the VPN APIs, so these tests started to fail in instant
mode.

Regardless of that change in S, though, instant apps cannot
create VPNs because they cannot access the package manager.

Previously, the tests were only passing because they did not
check that the VPN would actually work, they only checked that
the VPN API calls failed.

Fix: 181575083
Test: atest --instant CtsNetTestCases:VpnServiceTest
Change-Id: Idd35051bd1c908a8b85c02e8d0c54d3dea2dde38
This commit is contained in:
Lorenzo Colitti
2021-03-22 21:11:35 +09:00
parent bf0c19e52f
commit 60b26ee453

View File

@@ -47,6 +47,7 @@ public class VpnServiceTest extends AndroidTestCase {
assertEquals(1, count);
}
@AppModeFull(reason = "establish() requires prepare(), which requires PackageManager access")
public void testEstablish() throws Exception {
ParcelFileDescriptor descriptor = null;
try {
@@ -62,7 +63,7 @@ public class VpnServiceTest extends AndroidTestCase {
}
}
@AppModeFull(reason = "Socket cannot bind in instant app mode")
@AppModeFull(reason = "Protecting sockets requires prepare(), which requires PackageManager")
public void testProtect_DatagramSocket() throws Exception {
DatagramSocket socket = new DatagramSocket();
try {
@@ -77,6 +78,7 @@ public class VpnServiceTest extends AndroidTestCase {
}
}
@AppModeFull(reason = "Protecting sockets requires prepare(), which requires PackageManager")
public void testProtect_Socket() throws Exception {
Socket socket = new Socket();
try {
@@ -91,7 +93,7 @@ public class VpnServiceTest extends AndroidTestCase {
}
}
@AppModeFull(reason = "Socket cannot bind in instant app mode")
@AppModeFull(reason = "Protecting sockets requires prepare(), which requires PackageManager")
public void testProtect_int() throws Exception {
DatagramSocket socket = new DatagramSocket();
ParcelFileDescriptor descriptor = ParcelFileDescriptor.fromDatagramSocket(socket);