Merge "Avoids deadlock when applying preferred activities"
This commit is contained in:
committed by
Android (Google) Code Review
commit
d5cc921535
@@ -22,6 +22,7 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.content.pm.PackageManager.ApplicationInfoFlags;
|
||||
@@ -244,12 +245,16 @@ public abstract class PackageManagerInternal {
|
||||
|
||||
/**
|
||||
* Retrieve all activities that can be performed for the given intent.
|
||||
* @param resolvedType the resolved type of the intent, which should be resolved via
|
||||
* {@link Intent#resolveTypeIfNeeded(ContentResolver)} before passing to {@link PackageManager}
|
||||
* @param filterCallingUid The results will be filtered in the context of this UID instead
|
||||
* of the calling UID.
|
||||
* @see PackageManager#queryIntentActivities(Intent, int)
|
||||
*/
|
||||
public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
|
||||
@ResolveInfoFlags int flags, int filterCallingUid, int userId);
|
||||
public abstract List<ResolveInfo> queryIntentActivities(
|
||||
Intent intent, @Nullable String resolvedType, @ResolveInfoFlags int flags,
|
||||
int filterCallingUid, int userId);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve all services that can be performed for the given intent.
|
||||
|
||||
@@ -202,6 +202,7 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
|
||||
final List<ResolveInfo> apps =
|
||||
mInjector.getPackageManagerInternal().queryIntentActivities(
|
||||
launchIntent,
|
||||
launchIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
|
||||
MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE,
|
||||
callingUid,
|
||||
userId);
|
||||
|
||||
@@ -344,6 +344,7 @@ public class LauncherAppsService extends SystemService {
|
||||
final PackageManagerInternal pmInt =
|
||||
LocalServices.getService(PackageManagerInternal.class);
|
||||
List<ResolveInfo> apps = pmInt.queryIntentActivities(intent,
|
||||
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
|
||||
PackageManager.MATCH_DIRECT_BOOT_AWARE
|
||||
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
|
||||
callingUid, user.getIdentifier());
|
||||
@@ -468,6 +469,7 @@ public class LauncherAppsService extends SystemService {
|
||||
matchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
matchIntent.setPackage(packageName);
|
||||
final List<ResolveInfo> infoList = pmInt.queryIntentActivities(matchIntent,
|
||||
matchIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
|
||||
PackageManager.MATCH_DISABLED_COMPONENTS, Binder.getCallingUid(),
|
||||
getCallingUserId());
|
||||
final int size = infoList.size();
|
||||
@@ -539,6 +541,7 @@ public class LauncherAppsService extends SystemService {
|
||||
final PackageManagerInternal pmInt =
|
||||
LocalServices.getService(PackageManagerInternal.class);
|
||||
List<ResolveInfo> apps = pmInt.queryIntentActivities(intent,
|
||||
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
|
||||
PackageManager.MATCH_DIRECT_BOOT_AWARE
|
||||
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
|
||||
callingUid, user.getIdentifier());
|
||||
@@ -842,6 +845,7 @@ public class LauncherAppsService extends SystemService {
|
||||
// as calling startActivityAsUser ignores the category and just
|
||||
// resolves based on the component if present.
|
||||
List<ResolveInfo> apps = pmInt.queryIntentActivities(launchIntent,
|
||||
launchIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
|
||||
PackageManager.MATCH_DIRECT_BOOT_AWARE
|
||||
| PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
|
||||
callingUid, user.getIdentifier());
|
||||
|
||||
@@ -23097,8 +23097,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
@Override
|
||||
public List<ResolveInfo> queryIntentActivities(
|
||||
Intent intent, int flags, int filterCallingUid, int userId) {
|
||||
final String resolvedType = intent.resolveTypeIfNeeded(mContext.getContentResolver());
|
||||
Intent intent, String resolvedType, int flags, int filterCallingUid, int userId) {
|
||||
return PackageManagerService.this
|
||||
.queryIntentActivitiesInternal(intent, resolvedType, flags, filterCallingUid,
|
||||
userId, false /*resolveForStart*/, true /*allowDynamicSplits*/);
|
||||
|
||||
@@ -3348,7 +3348,8 @@ public final class Settings {
|
||||
int flags, ComponentName cn, String scheme, PatternMatcher ssp,
|
||||
IntentFilter.AuthorityEntry auth, PatternMatcher path, int userId) {
|
||||
final List<ResolveInfo> ri =
|
||||
pmInternal.queryIntentActivities(intent, flags, Binder.getCallingUid(), 0);
|
||||
pmInternal.queryIntentActivities(
|
||||
intent, intent.getType(), flags, Binder.getCallingUid(), 0);
|
||||
if (PackageManagerService.DEBUG_PREFERRED) {
|
||||
Log.d(TAG, "Queried " + intent + " results: " + ri);
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ public class CrossProfileAppsServiceImplTest {
|
||||
mActivityInfo = activityInfo;
|
||||
|
||||
when(mPackageManagerInternal.queryIntentActivities(
|
||||
any(Intent.class), anyInt(), anyInt(), anyInt()))
|
||||
any(Intent.class), nullable(String.class), anyInt(), anyInt(), anyInt()))
|
||||
.thenReturn(Collections.singletonList(resolveInfo));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user