Merge "Fix package visibility broadcast regression" into tm-dev am: e825776dce
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18171369 Change-Id: I00c6bcbf343bb0712348198069ce1f62b05f190d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -334,10 +334,14 @@ public abstract class PackageManagerInternal {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all receivers that can handle a broadcast of the given intent.
|
* Retrieve all receivers that can handle a broadcast of the given intent.
|
||||||
|
* @param filterCallingUid The results will be filtered in the context of this UID instead
|
||||||
|
* of the calling UID.
|
||||||
|
* @param forSend true if the invocation is intended for sending broadcasts. The value
|
||||||
|
* of this parameter affects how packages are filtered.
|
||||||
*/
|
*/
|
||||||
public abstract List<ResolveInfo> queryIntentReceivers(Intent intent,
|
public abstract List<ResolveInfo> queryIntentReceivers(Intent intent,
|
||||||
String resolvedType, @PackageManager.ResolveInfoFlagsBits long flags,
|
String resolvedType, @PackageManager.ResolveInfoFlagsBits long flags,
|
||||||
int filterCallingUid, int userId);
|
int filterCallingUid, int userId, boolean forSend);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all services that can be performed for the given intent.
|
* Retrieve all services that can be performed for the given intent.
|
||||||
|
|||||||
@@ -13248,8 +13248,8 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
UserManager.DISALLOW_DEBUGGING_FEATURES, user)) {
|
UserManager.DISALLOW_DEBUGGING_FEATURES, user)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<ResolveInfo> newReceivers = mPackageManagerInt
|
List<ResolveInfo> newReceivers = mPackageManagerInt.queryIntentReceivers(
|
||||||
.queryIntentReceivers(intent, resolvedType, pmFlags, callingUid, user);
|
intent, resolvedType, pmFlags, callingUid, user, true /* forSend */);
|
||||||
if (user != UserHandle.USER_SYSTEM && newReceivers != null) {
|
if (user != UserHandle.USER_SYSTEM && newReceivers != null) {
|
||||||
// If this is not the system user, we need to check for
|
// If this is not the system user, we need to check for
|
||||||
// any receivers that should be filtered out.
|
// any receivers that should be filtered out.
|
||||||
@@ -13265,8 +13265,9 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
if (newReceivers != null) {
|
if (newReceivers != null) {
|
||||||
for (int i = newReceivers.size() - 1; i >= 0; i--) {
|
for (int i = newReceivers.size() - 1; i >= 0; i--) {
|
||||||
final ResolveInfo ri = newReceivers.get(i);
|
final ResolveInfo ri = newReceivers.get(i);
|
||||||
final Resolution<ResolveInfo> resolution = mComponentAliasResolver
|
final Resolution<ResolveInfo> resolution =
|
||||||
.resolveReceiver(intent, ri, resolvedType, pmFlags, user, callingUid);
|
mComponentAliasResolver.resolveReceiver(intent, ri, resolvedType,
|
||||||
|
pmFlags, user, callingUid, true /* forSend */);
|
||||||
if (resolution == null) {
|
if (resolution == null) {
|
||||||
// It was an alias, but the target was not found.
|
// It was an alias, but the target was not found.
|
||||||
newReceivers.remove(i);
|
newReceivers.remove(i);
|
||||||
|
|||||||
@@ -483,7 +483,7 @@ public class ComponentAliasResolver {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public Resolution<ResolveInfo> resolveReceiver(@NonNull Intent intent,
|
public Resolution<ResolveInfo> resolveReceiver(@NonNull Intent intent,
|
||||||
@NonNull ResolveInfo receiver, @Nullable String resolvedType,
|
@NonNull ResolveInfo receiver, @Nullable String resolvedType,
|
||||||
int packageFlags, int userId, int callingUid) {
|
int packageFlags, int userId, int callingUid, boolean forSend) {
|
||||||
// Resolve this alias.
|
// Resolve this alias.
|
||||||
final Resolution<ComponentName> resolution = resolveComponentAlias(() ->
|
final Resolution<ComponentName> resolution = resolveComponentAlias(() ->
|
||||||
receiver.activityInfo.getComponentName());
|
receiver.activityInfo.getComponentName());
|
||||||
@@ -506,8 +506,8 @@ public class ComponentAliasResolver {
|
|||||||
i.setPackage(null);
|
i.setPackage(null);
|
||||||
i.setComponent(resolution.getTarget());
|
i.setComponent(resolution.getTarget());
|
||||||
|
|
||||||
List<ResolveInfo> resolved = pmi.queryIntentReceivers(i,
|
List<ResolveInfo> resolved = pmi.queryIntentReceivers(
|
||||||
resolvedType, packageFlags, callingUid, userId);
|
i, resolvedType, packageFlags, callingUid, userId, forSend);
|
||||||
if (resolved == null || resolved.size() == 0) {
|
if (resolved == null || resolved.size() == 0) {
|
||||||
// Target component not found.
|
// Target component not found.
|
||||||
Slog.w(TAG, "Alias target " + target.flattenToShortString() + " not found");
|
Slog.w(TAG, "Alias target " + target.flattenToShortString() + " not found");
|
||||||
|
|||||||
@@ -315,9 +315,9 @@ abstract class PackageManagerInternalBase extends PackageManagerInternal {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public final List<ResolveInfo> queryIntentReceivers(Intent intent,
|
public final List<ResolveInfo> queryIntentReceivers(Intent intent,
|
||||||
String resolvedType, @PackageManager.ResolveInfoFlagsBits long flags,
|
String resolvedType, @PackageManager.ResolveInfoFlagsBits long flags,
|
||||||
int filterCallingUid, int userId) {
|
int filterCallingUid, int userId, boolean forSend) {
|
||||||
return getResolveIntentHelper().queryIntentReceiversInternal(
|
return getResolveIntentHelper().queryIntentReceiversInternal(snapshot(), intent,
|
||||||
snapshot(), intent, resolvedType, flags, userId, filterCallingUid);
|
resolvedType, flags, userId, filterCallingUid, forSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -306,16 +306,32 @@ final class ResolveIntentHelper {
|
|||||||
return new IntentSender(target);
|
return new IntentSender(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In this method, we have to know the actual calling UID, but in some cases Binder's
|
/**
|
||||||
// call identity is removed, so the UID has to be passed in explicitly.
|
* Retrieve all receivers that can handle a broadcast of the given intent.
|
||||||
public @NonNull List<ResolveInfo> queryIntentReceiversInternal(Computer computer, Intent intent,
|
* @param queryingUid the results will be filtered in the context of this UID instead.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public List<ResolveInfo> queryIntentReceiversInternal(Computer computer, Intent intent,
|
||||||
String resolvedType, @PackageManager.ResolveInfoFlagsBits long flags, int userId,
|
String resolvedType, @PackageManager.ResolveInfoFlagsBits long flags, int userId,
|
||||||
int filterCallingUid) {
|
int queryingUid) {
|
||||||
|
return queryIntentReceiversInternal(computer, intent, resolvedType, flags, userId,
|
||||||
|
queryingUid, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PackageManagerInternal#queryIntentReceivers(Intent, String, long, int, int, boolean)
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public List<ResolveInfo> queryIntentReceiversInternal(Computer computer, Intent intent,
|
||||||
|
String resolvedType, @PackageManager.ResolveInfoFlagsBits long flags, int userId,
|
||||||
|
int filterCallingUid, boolean forSend) {
|
||||||
if (!mUserManager.exists(userId)) return Collections.emptyList();
|
if (!mUserManager.exists(userId)) return Collections.emptyList();
|
||||||
computer.enforceCrossUserPermission(filterCallingUid, userId, false /*requireFullPermission*/,
|
// The identity used to filter the receiver components
|
||||||
false /*checkShell*/, "query intent receivers");
|
final int queryingUid = forSend ? Process.SYSTEM_UID : filterCallingUid;
|
||||||
final String instantAppPkgName = computer.getInstantAppPackageName(filterCallingUid);
|
computer.enforceCrossUserPermission(queryingUid, userId,
|
||||||
flags = computer.updateFlagsForResolve(flags, userId, filterCallingUid,
|
false /*requireFullPermission*/, false /*checkShell*/, "query intent receivers");
|
||||||
|
final String instantAppPkgName = computer.getInstantAppPackageName(queryingUid);
|
||||||
|
flags = computer.updateFlagsForResolve(flags, userId, queryingUid,
|
||||||
false /*includeInstantApps*/,
|
false /*includeInstantApps*/,
|
||||||
computer.isImplicitImageCaptureIntentAndNotSetByDpc(intent, userId,
|
computer.isImplicitImageCaptureIntentAndNotSetByDpc(intent, userId,
|
||||||
resolvedType, flags));
|
resolvedType, flags));
|
||||||
@@ -397,7 +413,7 @@ final class ResolveIntentHelper {
|
|||||||
list, true, originalIntent, resolvedType, filterCallingUid);
|
list, true, originalIntent, resolvedType, filterCallingUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return computer.applyPostResolutionFilter(list, instantAppPkgName, false, filterCallingUid,
|
return computer.applyPostResolutionFilter(list, instantAppPkgName, false, queryingUid,
|
||||||
false, userId, intent);
|
false, userId, intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user