From 2ed983512ca35b531a48f777025bca74c4722ba6 Mon Sep 17 00:00:00 2001 From: chiachangwang Date: Wed, 14 Dec 2022 11:04:53 +0000 Subject: [PATCH] Rename getBypassable to isBypassable Bug: 262336021 Bug: 256775913 Test: atest FrameworksNetTests Change-Id: I5ac8f4f9a2a64189fc66d3c14af6da201a35e3e2 --- framework/api/system-current.txt | 2 +- framework/src/android/net/VpnTransportInfo.java | 6 +++--- .../common/java/android/net/VpnTransportInfoTest.java | 10 +++++----- .../java/com/android/server/connectivity/VpnTest.java | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt index 0b0f2bba14..dd3404c9f8 100644 --- a/framework/api/system-current.txt +++ b/framework/api/system-current.txt @@ -515,8 +515,8 @@ package android.net { ctor public VpnTransportInfo(int, @Nullable String, boolean, boolean); method public boolean areLongLivedTcpConnectionsExpensive(); method public int describeContents(); - method public boolean getBypassable(); method public int getType(); + method public boolean isBypassable(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; } diff --git a/framework/src/android/net/VpnTransportInfo.java b/framework/src/android/net/VpnTransportInfo.java index e335c0f1e4..6bb00c83be 100644 --- a/framework/src/android/net/VpnTransportInfo.java +++ b/framework/src/android/net/VpnTransportInfo.java @@ -86,7 +86,7 @@ public final class VpnTransportInfo implements TransportInfo, Parcelable { // When the module runs on older SDKs, |bypassable| will always be false since the old Vpn // code will call this constructor. For Settings VPNs, this is always correct as they are // never bypassable. For VpnManager and VpnService types, this may be wrong since both of - // them have a choice. However, on these SDKs VpnTransportInfo#getBypassable is not + // them have a choice. However, on these SDKs VpnTransportInfo#isBypassable is not // available anyway, so this should be harmless. False is a better choice than true here // regardless because it is the default value for both VpnManager and VpnService if the app // does not do anything about it. @@ -111,7 +111,7 @@ public final class VpnTransportInfo implements TransportInfo, Parcelable { * {@code UnsupportedOperationException} if called. */ @RequiresApi(UPSIDE_DOWN_CAKE) - public boolean getBypassable() { + public boolean isBypassable() { if (!SdkLevel.isAtLeastU()) { throw new UnsupportedOperationException("Not supported before U"); } @@ -134,7 +134,7 @@ public final class VpnTransportInfo implements TransportInfo, Parcelable { * VPNs can be bypassable or not. When the VPN is not bypassable, the user has * expressed explicit intent to have no connection outside of the VPN, so even * privileged apps with permission to bypass non-bypassable VPNs should not do - * so. See {@link #getBypassable()}. + * so. See {@link #isBypassable()}. * For bypassable VPNs however, the user expects apps choose reasonable tradeoffs * about whether they use the VPN. * diff --git a/tests/common/java/android/net/VpnTransportInfoTest.java b/tests/common/java/android/net/VpnTransportInfoTest.java index f32ab8b8aa..2d01df7258 100644 --- a/tests/common/java/android/net/VpnTransportInfoTest.java +++ b/tests/common/java/android/net/VpnTransportInfoTest.java @@ -94,20 +94,20 @@ public class VpnTransportInfoTest { @DevSdkIgnoreRule.IgnoreAfter(Build.VERSION_CODES.TIRAMISU) @Test - public void testGetBypassable_beforeU() { + public void testIsBypassable_beforeU() { final VpnTransportInfo v = new VpnTransportInfo(VpnManager.TYPE_VPN_PLATFORM, "12345"); - assertThrows(UnsupportedOperationException.class, () -> v.getBypassable()); + assertThrows(UnsupportedOperationException.class, () -> v.isBypassable()); } @DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.TIRAMISU) @Test - public void testGetBypassable_afterU() { + public void testIsBypassable_afterU() { final VpnTransportInfo v = new VpnTransportInfo(VpnManager.TYPE_VPN_PLATFORM, "12345"); - assertFalse(v.getBypassable()); + assertFalse(v.isBypassable()); final VpnTransportInfo v2 = new VpnTransportInfo(VpnManager.TYPE_VPN_PLATFORM, "12345", true, false); - assertTrue(v2.getBypassable()); + assertTrue(v2.isBypassable()); } @DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.TIRAMISU) diff --git a/tests/unit/java/com/android/server/connectivity/VpnTest.java b/tests/unit/java/com/android/server/connectivity/VpnTest.java index 677e7b6cb8..3f87ffd99c 100644 --- a/tests/unit/java/com/android/server/connectivity/VpnTest.java +++ b/tests/unit/java/com/android/server/connectivity/VpnTest.java @@ -1893,7 +1893,7 @@ public class VpnTest extends VpnTestBase { // Check if allowBypass is set or not. assertTrue(nacCaptor.getValue().isBypassableVpn()); - assertTrue(((VpnTransportInfo) ncCaptor.getValue().getTransportInfo()).getBypassable()); + assertTrue(((VpnTransportInfo) ncCaptor.getValue().getTransportInfo()).isBypassable()); return new PlatformVpnSnapshot(vpn, nwCb, ikeCb, childCb); }