Loading services/core/java/com/android/server/connectivity/Vpn.java +6 −6 Original line number Diff line number Diff line Loading @@ -711,10 +711,6 @@ public class Vpn { return mEnableTeardown; } private boolean isVpnMetricsLoggable() { return mVpnConnectivityMetrics != null && mVpnConnectivityMetrics.isPlatformVpn(); } /** * Update current state, dispatching event to listeners. */ Loading @@ -735,7 +731,7 @@ public class Vpn { case CONNECTED: if (null != mNetworkAgent) { mNetworkAgent.markConnected(); if (isVpnMetricsLoggable()) { if (mVpnConnectivityMetrics != null) { mVpnConnectivityMetrics.notifyVpnConnected(); } } Loading @@ -745,7 +741,7 @@ public class Vpn { if (null != mNetworkAgent) { mNetworkAgent.unregister(); mNetworkAgent = null; if (isVpnMetricsLoggable()) { if (mVpnConnectivityMetrics != null) { mVpnConnectivityMetrics.notifyVpnDisconnected(); // Clear the metrics since the NetworkAgent is disconnected. mVpnConnectivityMetrics.resetMetrics(); Loading Loading @@ -1818,6 +1814,10 @@ public class Vpn { config.interfaze = mInterface; config.startTime = SystemClock.elapsedRealtime(); mConfig = config; // Log VPN service events for connection establishment if (mVpnConnectivityMetrics != null) { mVpnConnectivityMetrics.setVpnType(VpnManager.TYPE_VPN_SERVICE); } // Set up forwarding and DNS rules. // First attempt to do a seamless handover that only changes the interface name and Loading services/core/java/com/android/server/connectivity/VpnConnectivityMetrics.java +0 −13 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import static android.net.IpSecAlgorithm.AUTH_HMAC_SHA512; import static android.net.IpSecAlgorithm.CRYPT_AES_CBC; import static android.net.IpSecAlgorithm.CRYPT_AES_CTR; import static android.net.VpnManager.TYPE_VPN_OEM; import static android.net.VpnManager.TYPE_VPN_PLATFORM; import android.net.ConnectivityManager; import android.net.LinkAddress; Loading Loading @@ -390,18 +389,6 @@ public class VpnConnectivityMetrics { return ipProtocol; } /** * Checks if the VPN associated with these metrics is a platform-managed VPN. * The determination is based on the internal {@code mVpnType} field, which * should be set during the VPN's configuration. * * @return {@code true} if the VPN type matches {@code TYPE_VPN_PLATFORM}; * {@code false} otherwise. */ public boolean isPlatformVpn() { return mVpnType == TYPE_VPN_PLATFORM; } /** * Validates and corrects the internal VPN metrics to ensure the collected data fall within * acceptable ranges. Loading services/tests/VpnTests/java/com/android/server/connectivity/VpnTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -1517,6 +1517,7 @@ public class VpnTest extends VpnTestBase { eq(TEST_VPN_PKG), eq(null) /* attributionTag */, eq(null) /* message */); verify(mVpnConnectivityMetrics, times(1)).setVpnType(VpnManager.TYPE_VPN_SERVICE); // Call establish() twice with the same config, it should match seamless handover case and // startOp() shouldn't be called again. vpn.establish(config); Loading @@ -1526,6 +1527,7 @@ public class VpnTest extends VpnTestBase { eq(TEST_VPN_PKG), eq(null) /* attributionTag */, eq(null) /* message */); verify(mVpnConnectivityMetrics, times(2)).setVpnType(VpnManager.TYPE_VPN_SERVICE); } private void verifyVpnManagerEvent(String sessionKey, String category, int errorClass, Loading Loading @@ -3336,7 +3338,6 @@ public class VpnTest extends VpnTestBase { verify(mConnectivityManager, times(1)).registerNetworkProvider(argThat( provider -> provider.getName().contains("VpnNetworkProvider") )); doReturn(true).when(mVpnConnectivityMetrics).isPlatformVpn(); return vpn; } Loading Loading
services/core/java/com/android/server/connectivity/Vpn.java +6 −6 Original line number Diff line number Diff line Loading @@ -711,10 +711,6 @@ public class Vpn { return mEnableTeardown; } private boolean isVpnMetricsLoggable() { return mVpnConnectivityMetrics != null && mVpnConnectivityMetrics.isPlatformVpn(); } /** * Update current state, dispatching event to listeners. */ Loading @@ -735,7 +731,7 @@ public class Vpn { case CONNECTED: if (null != mNetworkAgent) { mNetworkAgent.markConnected(); if (isVpnMetricsLoggable()) { if (mVpnConnectivityMetrics != null) { mVpnConnectivityMetrics.notifyVpnConnected(); } } Loading @@ -745,7 +741,7 @@ public class Vpn { if (null != mNetworkAgent) { mNetworkAgent.unregister(); mNetworkAgent = null; if (isVpnMetricsLoggable()) { if (mVpnConnectivityMetrics != null) { mVpnConnectivityMetrics.notifyVpnDisconnected(); // Clear the metrics since the NetworkAgent is disconnected. mVpnConnectivityMetrics.resetMetrics(); Loading Loading @@ -1818,6 +1814,10 @@ public class Vpn { config.interfaze = mInterface; config.startTime = SystemClock.elapsedRealtime(); mConfig = config; // Log VPN service events for connection establishment if (mVpnConnectivityMetrics != null) { mVpnConnectivityMetrics.setVpnType(VpnManager.TYPE_VPN_SERVICE); } // Set up forwarding and DNS rules. // First attempt to do a seamless handover that only changes the interface name and Loading
services/core/java/com/android/server/connectivity/VpnConnectivityMetrics.java +0 −13 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import static android.net.IpSecAlgorithm.AUTH_HMAC_SHA512; import static android.net.IpSecAlgorithm.CRYPT_AES_CBC; import static android.net.IpSecAlgorithm.CRYPT_AES_CTR; import static android.net.VpnManager.TYPE_VPN_OEM; import static android.net.VpnManager.TYPE_VPN_PLATFORM; import android.net.ConnectivityManager; import android.net.LinkAddress; Loading Loading @@ -390,18 +389,6 @@ public class VpnConnectivityMetrics { return ipProtocol; } /** * Checks if the VPN associated with these metrics is a platform-managed VPN. * The determination is based on the internal {@code mVpnType} field, which * should be set during the VPN's configuration. * * @return {@code true} if the VPN type matches {@code TYPE_VPN_PLATFORM}; * {@code false} otherwise. */ public boolean isPlatformVpn() { return mVpnType == TYPE_VPN_PLATFORM; } /** * Validates and corrects the internal VPN metrics to ensure the collected data fall within * acceptable ranges. Loading
services/tests/VpnTests/java/com/android/server/connectivity/VpnTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -1517,6 +1517,7 @@ public class VpnTest extends VpnTestBase { eq(TEST_VPN_PKG), eq(null) /* attributionTag */, eq(null) /* message */); verify(mVpnConnectivityMetrics, times(1)).setVpnType(VpnManager.TYPE_VPN_SERVICE); // Call establish() twice with the same config, it should match seamless handover case and // startOp() shouldn't be called again. vpn.establish(config); Loading @@ -1526,6 +1527,7 @@ public class VpnTest extends VpnTestBase { eq(TEST_VPN_PKG), eq(null) /* attributionTag */, eq(null) /* message */); verify(mVpnConnectivityMetrics, times(2)).setVpnType(VpnManager.TYPE_VPN_SERVICE); } private void verifyVpnManagerEvent(String sessionKey, String category, int errorClass, Loading Loading @@ -3336,7 +3338,6 @@ public class VpnTest extends VpnTestBase { verify(mConnectivityManager, times(1)).registerNetworkProvider(argThat( provider -> provider.getName().contains("VpnNetworkProvider") )); doReturn(true).when(mVpnConnectivityMetrics).isPlatformVpn(); return vpn; } Loading