Adds null check before applyPostResolutionFilter
Calls to mComponentResolver.query* may return null. This change appropriately annotates those methods and does checks before passing the results on to applyPostResolutionFilter (which has also been annotated). Test: atest DeviceOwnerPlusProfileOwnerTest.testWipeData_managedProfile Fixes: 142311634 Change-Id: I911041c87964a117f60a71d0957d42f16a7ab8cb
This commit is contained in:
@@ -23,6 +23,7 @@ import static com.android.server.pm.PackageManagerService.DEBUG_PACKAGE_SCANNING
|
||||
import static com.android.server.pm.PackageManagerService.DEBUG_REMOVE;
|
||||
import static com.android.server.pm.PackageManagerService.fixProcessName;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@@ -219,12 +220,14 @@ public class ComponentResolver {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryActivities(Intent intent, String resolvedType, int flags, int userId) {
|
||||
synchronized (mLock) {
|
||||
return mActivities.queryIntent(intent, resolvedType, flags, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryActivities(Intent intent, String resolvedType, int flags,
|
||||
List<PackageParser.Activity> activities, int userId) {
|
||||
synchronized (mLock) {
|
||||
@@ -233,12 +236,14 @@ public class ComponentResolver {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryProviders(Intent intent, String resolvedType, int flags, int userId) {
|
||||
synchronized (mLock) {
|
||||
return mProviders.queryIntent(intent, resolvedType, flags, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryProviders(Intent intent, String resolvedType, int flags,
|
||||
List<PackageParser.Provider> providers, int userId) {
|
||||
synchronized (mLock) {
|
||||
@@ -246,6 +251,7 @@ public class ComponentResolver {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ProviderInfo> queryProviders(String processName, String metaDataKey, int uid, int flags,
|
||||
int userId) {
|
||||
if (!sUserManager.exists(userId)) {
|
||||
@@ -285,6 +291,7 @@ public class ComponentResolver {
|
||||
return providerList;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
ProviderInfo queryProvider(String authority, int flags, int userId) {
|
||||
synchronized (mLock) {
|
||||
final PackageParser.Provider p = mProvidersByAuthority.get(authority);
|
||||
@@ -326,12 +333,14 @@ public class ComponentResolver {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryReceivers(Intent intent, String resolvedType, int flags, int userId) {
|
||||
synchronized (mLock) {
|
||||
return mReceivers.queryIntent(intent, resolvedType, flags, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryReceivers(Intent intent, String resolvedType, int flags,
|
||||
List<PackageParser.Activity> receivers, int userId) {
|
||||
synchronized (mLock) {
|
||||
@@ -339,12 +348,14 @@ public class ComponentResolver {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryServices(Intent intent, String resolvedType, int flags, int userId) {
|
||||
synchronized (mLock) {
|
||||
return mServices.queryIntent(intent, resolvedType, flags, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryServices(Intent intent, String resolvedType, int flags,
|
||||
List<PackageParser.Service> services, int userId) {
|
||||
synchronized (mLock) {
|
||||
@@ -1355,6 +1366,7 @@ public class ComponentResolver {
|
||||
return super.queryIntent(intent, resolvedType, defaultOnly, userId);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryIntent(Intent intent, String resolvedType, int flags,
|
||||
int userId) {
|
||||
if (!sUserManager.exists(userId)) {
|
||||
@@ -1366,6 +1378,7 @@ public class ComponentResolver {
|
||||
userId);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType,
|
||||
int flags, List<PackageParser.Provider> packageProviders, int userId) {
|
||||
if (!sUserManager.exists(userId)) {
|
||||
|
||||
@@ -6977,7 +6977,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
* @param intent
|
||||
* @return A filtered list of resolved activities.
|
||||
*/
|
||||
private List<ResolveInfo> applyPostResolutionFilter(List<ResolveInfo> resolveInfos,
|
||||
private List<ResolveInfo> applyPostResolutionFilter(@NonNull List<ResolveInfo> resolveInfos,
|
||||
String ephemeralPkgName, boolean allowDynamicSplits, int filterCallingUid,
|
||||
boolean resolveForStart, int userId, Intent intent) {
|
||||
final boolean blockInstant = intent.isWebIntent() && areWebInstantAppsDisabled(userId);
|
||||
@@ -7634,6 +7634,9 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
if (pkgName == null) {
|
||||
final List<ResolveInfo> result =
|
||||
mComponentResolver.queryReceivers(intent, resolvedType, flags, userId);
|
||||
if (result == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return applyPostResolutionFilter(
|
||||
result, instantAppPkgName, allowDynamicSplits, callingUid, false, userId,
|
||||
intent);
|
||||
@@ -7642,6 +7645,9 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
if (pkg != null) {
|
||||
final List<ResolveInfo> result = mComponentResolver.queryReceivers(
|
||||
intent, resolvedType, flags, pkg.receivers, userId);
|
||||
if (result == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return applyPostResolutionFilter(
|
||||
result, instantAppPkgName, allowDynamicSplits, callingUid, false, userId,
|
||||
intent);
|
||||
@@ -7736,15 +7742,25 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
synchronized (mLock) {
|
||||
String pkgName = intent.getPackage();
|
||||
if (pkgName == null) {
|
||||
final List<ResolveInfo> resolveInfos = mComponentResolver.queryServices(intent,
|
||||
resolvedType, flags, userId);
|
||||
if (resolveInfos == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return applyPostServiceResolutionFilter(
|
||||
mComponentResolver.queryServices(intent, resolvedType, flags, userId),
|
||||
resolveInfos,
|
||||
instantAppPkgName);
|
||||
}
|
||||
final PackageParser.Package pkg = mPackages.get(pkgName);
|
||||
if (pkg != null) {
|
||||
final List<ResolveInfo> resolveInfos = mComponentResolver.queryServices(intent,
|
||||
resolvedType, flags, pkg.services,
|
||||
userId);
|
||||
if (resolveInfos == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return applyPostServiceResolutionFilter(
|
||||
mComponentResolver.queryServices(intent, resolvedType, flags, pkg.services,
|
||||
userId),
|
||||
resolveInfos,
|
||||
instantAppPkgName);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
@@ -7854,15 +7870,25 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
synchronized (mLock) {
|
||||
String pkgName = intent.getPackage();
|
||||
if (pkgName == null) {
|
||||
final List<ResolveInfo> resolveInfos = mComponentResolver.queryProviders(intent,
|
||||
resolvedType, flags, userId);
|
||||
if (resolveInfos == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return applyPostContentProviderResolutionFilter(
|
||||
mComponentResolver.queryProviders(intent, resolvedType, flags, userId),
|
||||
resolveInfos,
|
||||
instantAppPkgName);
|
||||
}
|
||||
final PackageParser.Package pkg = mPackages.get(pkgName);
|
||||
if (pkg != null) {
|
||||
final List<ResolveInfo> resolveInfos = mComponentResolver.queryProviders(intent,
|
||||
resolvedType, flags,
|
||||
pkg.providers, userId);
|
||||
if (resolveInfos == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return applyPostContentProviderResolutionFilter(
|
||||
mComponentResolver.queryProviders(intent, resolvedType, flags,
|
||||
pkg.providers, userId),
|
||||
resolveInfos,
|
||||
instantAppPkgName);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
Reference in New Issue
Block a user