From 8c1372ed1deaec8e013055dfd1f5211679564840 Mon Sep 17 00:00:00 2001 From: Chiachang Wang Date: Mon, 28 Sep 2020 10:31:49 +0800 Subject: Update to positive logic to better match the method naming The method checkInterfacePresent seems that should return if the interface is present or not, but it actually return an opposite result. It may confuse the caller. E.g. The override method in VpnTest assume it always returns true in the test. It will fail the vpn start flow due to interface gone. Bug: 169215213 Test: atest FrameworksNetTess Change-Id: I3e9a64f0900336b8205674b94db68f090b4e9ff9 --- services/core/java/com/android/server/connectivity/Vpn.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'services') diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index b55fd49a434a..e4149adeb96c 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -380,8 +380,8 @@ public class Vpn { } } - public boolean checkInterfacePresent(final Vpn vpn, final String iface) { - return vpn.jniCheck(iface) == 0; + public boolean isInterfacePresent(final Vpn vpn, final String iface) { + return vpn.jniCheck(iface) != 0; } } @@ -2989,7 +2989,7 @@ public class Vpn { checkInterruptAndDelay(false); // Check if the interface is gone while we are waiting. - if (mDeps.checkInterfacePresent(Vpn.this, mConfig.interfaze)) { + if (!mDeps.isInterfacePresent(Vpn.this, mConfig.interfaze)) { throw new IllegalStateException(mConfig.interfaze + " is gone"); } -- cgit v1.2.3-59-g8ed1b