From 7adf71f697155a0c46bd85732baebedbaa65d56a Mon Sep 17 00:00:00 2001 From: paulhu Date: Thu, 22 Oct 2020 21:39:22 +0800 Subject: Replace AppGlobals @hide APIs Connectivity service module is using a AppGlobals @hide API but it's not able to call after CS become a mainline module. Thus, replace it with similar System API. Bug: 170593746 Test: atest FrameworksNetTests Test: atest HostsideVpnTests Change-Id: I5ee3005e50640b186e7a0a2e3dc8dd51ffaf273b --- services/core/java/com/android/server/connectivity/Vpn.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 1a83272f5077..d5cad36ac351 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -31,7 +31,6 @@ import android.Manifest; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; -import android.app.AppGlobals; import android.app.AppOpsManager; import android.app.Notification; import android.app.NotificationManager; @@ -1330,16 +1329,17 @@ public class Vpn { // Restricted users are not allowed to create VPNs, they are tied to Owner enforceNotRestrictedUser(); - ResolveInfo info = AppGlobals.getPackageManager().resolveService(intent, - null, 0, mUserId); + final PackageManager packageManager = mUserIdContext.getPackageManager(); + if (packageManager == null) { + throw new UnsupportedOperationException("Cannot get PackageManager."); + } + final ResolveInfo info = packageManager.resolveService(intent, 0 /* flags */); if (info == null) { throw new SecurityException("Cannot find " + config.user); } if (!BIND_VPN_SERVICE.equals(info.serviceInfo.permission)) { throw new SecurityException(config.user + " does not require " + BIND_VPN_SERVICE); } - } catch (RemoteException e) { - throw new SecurityException("Cannot find " + config.user); } finally { Binder.restoreCallingIdentity(token); } -- cgit v1.2.3-59-g8ed1b