Merge "Stop skipping VPN tests when running ADB over TCP."

This commit is contained in:
Treehugger Robot
2021-11-26 03:30:45 +00:00
committed by Gerrit Code Review

View File

@@ -727,11 +727,15 @@ public class VpnTest {
@Test @Test
public void testDefault() throws Exception { public void testDefault() throws Exception {
if (!supportedHardware()) return; if (!supportedHardware()) return;
// If adb TCP port opened, this test may running by adb over network. if (!SdkLevel.isAtLeastS() && (
// All of socket would be destroyed in this test. So this test don't SystemProperties.getInt("persist.adb.tcp.port", -1) > -1
// support adb over network, see b/119382723. || SystemProperties.getInt("service.adb.tcp.port", -1) > -1)) {
if (SystemProperties.getInt("persist.adb.tcp.port", -1) > -1 // If adb TCP port opened, this test may running by adb over network.
|| SystemProperties.getInt("service.adb.tcp.port", -1) > -1) { // All of socket would be destroyed in this test. So this test don't
// support adb over network, see b/119382723.
// This is fixed in S, but still affects previous Android versions,
// and this test must be backwards compatible.
// TODO: Delete this code entirely when R is no longer supported.
Log.i(TAG, "adb is running over the network, so skip this test"); Log.i(TAG, "adb is running over the network, so skip this test");
return; return;
} }
@@ -842,11 +846,16 @@ public class VpnTest {
FileDescriptor remoteFd = openSocketFdInOtherApp(TEST_HOST, 80, TIMEOUT_MS); FileDescriptor remoteFd = openSocketFdInOtherApp(TEST_HOST, 80, TIMEOUT_MS);
String disallowedApps = mRemoteSocketFactoryClient.getPackageName() + "," + mPackageName; String disallowedApps = mRemoteSocketFactoryClient.getPackageName() + "," + mPackageName;
// If adb TCP port opened, this test may running by adb over TCP. if (!SdkLevel.isAtLeastS()) {
// Add com.android.shell appllication into blacklist to exclude adb socket for VPN test, // If adb TCP port opened, this test may running by adb over TCP.
// see b/119382723. // Add com.android.shell application into disallowedApps to exclude adb socket for VPN
// Note: The test don't support running adb over network for root device // test, see b/119382723 (the test doesn't support adb over TCP when adb runs as root).
disallowedApps = disallowedApps + ",com.android.shell"; //
// This is fixed in S, but still affects previous Android versions,
// and this test must be backwards compatible.
// TODO: Delete this code entirely when R is no longer supported.
disallowedApps = disallowedApps + ",com.android.shell";
}
Log.i(TAG, "Append shell app to disallowedApps: " + disallowedApps); Log.i(TAG, "Append shell app to disallowedApps: " + disallowedApps);
startVpn(new String[] {"192.0.2.2/32", "2001:db8:1:2::ffe/128"}, startVpn(new String[] {"192.0.2.2/32", "2001:db8:1:2::ffe/128"},
new String[] {"192.0.2.0/24", "2001:db8::/32"}, new String[] {"192.0.2.0/24", "2001:db8::/32"},
@@ -930,11 +939,17 @@ public class VpnTest {
if (!supportedHardware()) return; if (!supportedHardware()) return;
ProxyInfo initialProxy = mCM.getDefaultProxy(); ProxyInfo initialProxy = mCM.getDefaultProxy();
// If adb TCP port opened, this test may running by adb over TCP. String disallowedApps = mPackageName;
// Add com.android.shell appllication into blacklist to exclude adb socket for VPN test, if (!SdkLevel.isAtLeastS()) {
// see b/119382723. // If adb TCP port opened, this test may running by adb over TCP.
// Note: The test don't support running adb over network for root device // Add com.android.shell application into disallowedApps to exclude adb socket for VPN
String disallowedApps = mPackageName + ",com.android.shell"; // test, see b/119382723 (the test doesn't support adb over TCP when adb runs as root).
//
// This is fixed in S, but still affects previous Android versions,
// and this test must be backwards compatible.
// TODO: Delete this code entirely when R is no longer supported.
disallowedApps += ",com.android.shell";
}
ProxyInfo testProxyInfo = ProxyInfo.buildDirectProxy("10.0.0.1", 8888); ProxyInfo testProxyInfo = ProxyInfo.buildDirectProxy("10.0.0.1", 8888);
startVpn(new String[] {"192.0.2.2/32", "2001:db8:1:2::ffe/128"}, startVpn(new String[] {"192.0.2.2/32", "2001:db8:1:2::ffe/128"},
new String[] {"0.0.0.0/0", "::/0"}, "", disallowedApps, new String[] {"0.0.0.0/0", "::/0"}, "", disallowedApps,