Replace PackageManager @hide APIs
ConnectivityService is using PackageManager#getApplicationInfoAsUser() to get application info but this API is not able to call after CS becomes a mainline module. Thus, replace it with formal API. Bug: 170593746 Test: atest FrameworksNetTests Test: atest CtsNetTestCasesLegacyApi22 Change-Id: Idd1269aa50e234801583097bb6f40b099bab8fba
This commit is contained in:
parent
635e43ae1a
commit
310c9fbc20
1 changed files with 5 additions and 4 deletions
|
|
@ -5566,11 +5566,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
}
|
||||
|
||||
private boolean checkUnsupportedStartingFrom(int version, String callingPackageName) {
|
||||
final PackageManager pm = mContext.getPackageManager();
|
||||
final int userId = UserHandle.getCallingUserId();
|
||||
final UserHandle user = UserHandle.getUserHandleForUid(Binder.getCallingUid());
|
||||
final PackageManager pm =
|
||||
mContext.createContextAsUser(user, 0 /* flags */).getPackageManager();
|
||||
try {
|
||||
final int callingVersion = pm.getApplicationInfoAsUser(
|
||||
callingPackageName, 0 /* flags */, userId).targetSdkVersion;
|
||||
final int callingVersion = pm.getApplicationInfo(
|
||||
callingPackageName, 0 /* flags */).targetSdkVersion;
|
||||
if (callingVersion < version) return false;
|
||||
} catch (PackageManager.NameNotFoundException e) { }
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue