Rename getBypassable to isBypassable

Bug: 262336021
Bug: 256775913
Test: atest FrameworksNetTests
Change-Id: I5ac8f4f9a2a64189fc66d3c14af6da201a35e3e2
This commit is contained in:
chiachangwang
2022-12-14 11:04:53 +00:00
committed by Chiachang Wang
parent df91219a9b
commit 2ed983512c
4 changed files with 10 additions and 10 deletions

View File

@@ -515,8 +515,8 @@ package android.net {
ctor public VpnTransportInfo(int, @Nullable String, boolean, boolean); ctor public VpnTransportInfo(int, @Nullable String, boolean, boolean);
method public boolean areLongLivedTcpConnectionsExpensive(); method public boolean areLongLivedTcpConnectionsExpensive();
method public int describeContents(); method public int describeContents();
method public boolean getBypassable();
method public int getType(); method public int getType();
method public boolean isBypassable();
method public void writeToParcel(@NonNull android.os.Parcel, int); method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.VpnTransportInfo> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.net.VpnTransportInfo> CREATOR;
} }

View File

@@ -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 // 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 // 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 // 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 // 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 // regardless because it is the default value for both VpnManager and VpnService if the app
// does not do anything about it. // does not do anything about it.
@@ -111,7 +111,7 @@ public final class VpnTransportInfo implements TransportInfo, Parcelable {
* {@code UnsupportedOperationException} if called. * {@code UnsupportedOperationException} if called.
*/ */
@RequiresApi(UPSIDE_DOWN_CAKE) @RequiresApi(UPSIDE_DOWN_CAKE)
public boolean getBypassable() { public boolean isBypassable() {
if (!SdkLevel.isAtLeastU()) { if (!SdkLevel.isAtLeastU()) {
throw new UnsupportedOperationException("Not supported before U"); 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 * 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 * 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 * 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 * For bypassable VPNs however, the user expects apps choose reasonable tradeoffs
* about whether they use the VPN. * about whether they use the VPN.
* *

View File

@@ -94,20 +94,20 @@ public class VpnTransportInfoTest {
@DevSdkIgnoreRule.IgnoreAfter(Build.VERSION_CODES.TIRAMISU) @DevSdkIgnoreRule.IgnoreAfter(Build.VERSION_CODES.TIRAMISU)
@Test @Test
public void testGetBypassable_beforeU() { public void testIsBypassable_beforeU() {
final VpnTransportInfo v = new VpnTransportInfo(VpnManager.TYPE_VPN_PLATFORM, "12345"); 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) @DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.TIRAMISU)
@Test @Test
public void testGetBypassable_afterU() { public void testIsBypassable_afterU() {
final VpnTransportInfo v = new VpnTransportInfo(VpnManager.TYPE_VPN_PLATFORM, "12345"); final VpnTransportInfo v = new VpnTransportInfo(VpnManager.TYPE_VPN_PLATFORM, "12345");
assertFalse(v.getBypassable()); assertFalse(v.isBypassable());
final VpnTransportInfo v2 = final VpnTransportInfo v2 =
new VpnTransportInfo(VpnManager.TYPE_VPN_PLATFORM, "12345", true, false); new VpnTransportInfo(VpnManager.TYPE_VPN_PLATFORM, "12345", true, false);
assertTrue(v2.getBypassable()); assertTrue(v2.isBypassable());
} }
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.TIRAMISU) @DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.TIRAMISU)

View File

@@ -1893,7 +1893,7 @@ public class VpnTest extends VpnTestBase {
// Check if allowBypass is set or not. // Check if allowBypass is set or not.
assertTrue(nacCaptor.getValue().isBypassableVpn()); assertTrue(nacCaptor.getValue().isBypassableVpn());
assertTrue(((VpnTransportInfo) ncCaptor.getValue().getTransportInfo()).getBypassable()); assertTrue(((VpnTransportInfo) ncCaptor.getValue().getTransportInfo()).isBypassable());
return new PlatformVpnSnapshot(vpn, nwCb, ikeCb, childCb); return new PlatformVpnSnapshot(vpn, nwCb, ikeCb, childCb);
} }