From 1bb3f75b0547cf992a39cef3f4fe9b6a6d74eeb3 Mon Sep 17 00:00:00 2001 From: junyulai Date: Fri, 19 Mar 2021 20:23:45 +0800 Subject: [PATCH] Remove reference of getActiveLinkproperties For callers who access the hidden API, replaced with public APIs. Test: atest FrameworksNetTests Bug: 182963397 Change-Id: Ic0e895c77cf3efb78ddc333c4f3b1016cebcfe17 --- services/core/java/com/android/server/VpnManagerService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/VpnManagerService.java b/services/core/java/com/android/server/VpnManagerService.java index 56aabc2080278..d756c1ffd00f9 100644 --- a/services/core/java/com/android/server/VpnManagerService.java +++ b/services/core/java/com/android/server/VpnManagerService.java @@ -352,7 +352,10 @@ public class VpnManagerService extends IVpnManager.Stub { @Override public void startLegacyVpn(VpnProfile profile) { int user = UserHandle.getUserId(mDeps.getCallingUid()); - final LinkProperties egress = mCm.getActiveLinkProperties(); + // Note that if the caller is not system (uid >= Process.FIRST_APPLICATION_UID), + // the code might not work well since getActiveNetwork might return null if the uid is + // blocked by NetworkPolicyManagerService. + final LinkProperties egress = mCm.getLinkProperties(mCm.getActiveNetwork()); if (egress == null) { throw new IllegalStateException("Missing active network connection"); }