From 5a684c6362727be7a7b094157d133c40ca03a551 Mon Sep 17 00:00:00 2001 From: lucaslin Date: Thu, 14 Jul 2022 08:48:55 +0800 Subject: [PATCH] Skip sending VpnManager events for Settings VPNs This change early-exits from the sendEventToVpnManagerApp() method if the profile was not a VPN app. Otherwise the sendEventToVpnManagerApp() will call getRedactedNetworkCapabilities() which will call AppOpsManager#checkPackage() eventually. And AppOpsManager#checkPackage() will check if the given package is the same as the given uid. In this case, VPN sends "[Legacy VPN]" as the package and sends 1000 as the uid, but there is no package named "[Legacy VPN], so the SecurityException is thrown. Bug: 236315805 Test: atest FrameworksNetTests:VpnTest Change-Id: I228f62a5e09017dbf985a614f2e42434238a220c --- services/core/java/com/android/server/connectivity/Vpn.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index c3fc8e0a7535e..86a773627c17d 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -3337,7 +3337,7 @@ public class Vpn { // TODO(b/230548427): Remove SDK check once VPN related stuff are // decoupled from ConnectivityServiceTest. - if (SdkLevel.isAtLeastT() && category != null) { + if (SdkLevel.isAtLeastT() && category != null && isVpnApp(mPackage)) { sendEventToVpnManagerApp(category, errorClass, errorCode, getPackage(), mSessionKey, makeVpnProfileStateLocked(), mActiveNetwork,