Merge "Fixes NON_BROWSER flag behavior" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e199e2d27b
@@ -33,7 +33,6 @@ import android.content.pm.AuxiliaryResolveInfo;
|
||||
import android.content.pm.InstantAppResolveInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
import android.content.pm.PackageManagerInternal.PrivateResolveFlags;
|
||||
import android.content.pm.PackageUserState;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
@@ -261,10 +260,9 @@ public class ComponentResolver {
|
||||
|
||||
@Nullable
|
||||
List<ResolveInfo> queryActivities(Intent intent, String resolvedType, int flags,
|
||||
@PrivateResolveFlags int privateResolveFlags, int userId) {
|
||||
int userId) {
|
||||
synchronized (mLock) {
|
||||
return mActivities.queryIntent(
|
||||
intent, resolvedType, flags, privateResolveFlags, userId);
|
||||
return mActivities.queryIntent(intent, resolvedType, flags, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +425,7 @@ public class ComponentResolver {
|
||||
@Nullable
|
||||
List<ResolveInfo> queryReceivers(Intent intent, String resolvedType, int flags, int userId) {
|
||||
synchronized (mLock) {
|
||||
return mReceivers.queryIntent(intent, resolvedType, flags, 0, userId);
|
||||
return mReceivers.queryIntent(intent, resolvedType, flags, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1293,12 +1291,11 @@ public class ComponentResolver {
|
||||
}
|
||||
|
||||
List<ResolveInfo> queryIntent(Intent intent, String resolvedType, int flags,
|
||||
int privateResolveFlags, int userId) {
|
||||
int userId) {
|
||||
if (!sUserManager.exists(userId)) {
|
||||
return null;
|
||||
}
|
||||
mFlags = flags;
|
||||
mPrivateResolveFlags = privateResolveFlags;
|
||||
return super.queryIntent(intent, resolvedType,
|
||||
(flags & PackageManager.MATCH_DEFAULT_ONLY) != 0,
|
||||
userId);
|
||||
@@ -1495,11 +1492,6 @@ public class ComponentResolver {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
final boolean matchNonBrowserOnly =
|
||||
(mPrivateResolveFlags & PackageManagerInternal.RESOLVE_NON_BROWSER_ONLY) != 0;
|
||||
if (matchNonBrowserOnly && info.handleAllWebDataURI()) {
|
||||
return null;
|
||||
}
|
||||
final ResolveInfo res = new ResolveInfo();
|
||||
res.activityInfo = ai;
|
||||
if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
|
||||
@@ -1579,7 +1571,6 @@ public class ComponentResolver {
|
||||
private final ArrayMap<ComponentName, ParsedActivity> mActivities =
|
||||
new ArrayMap<>();
|
||||
private int mFlags;
|
||||
private int mPrivateResolveFlags;
|
||||
}
|
||||
|
||||
// Both receivers and activities share a class, but point to different get methods
|
||||
|
||||
@@ -6414,6 +6414,11 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
final ResolveInfo bestChoice =
|
||||
chooseBestActivity(
|
||||
intent, resolvedType, flags, privateResolveFlags, query, userId);
|
||||
final boolean nonBrowserOnly =
|
||||
(privateResolveFlags & PackageManagerInternal.RESOLVE_NON_BROWSER_ONLY) != 0;
|
||||
if (nonBrowserOnly && bestChoice != null && bestChoice.handleAllWebDataURI) {
|
||||
return null;
|
||||
}
|
||||
return bestChoice;
|
||||
} finally {
|
||||
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
|
||||
@@ -6601,9 +6606,13 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
if (ri != null) {
|
||||
return ri;
|
||||
}
|
||||
// If we have an ephemeral app, use it
|
||||
int browserCount = 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
ri = query.get(i);
|
||||
if (ri.handleAllWebDataURI) {
|
||||
browserCount++;
|
||||
}
|
||||
// If we have an ephemeral app, use it
|
||||
if (ri.activityInfo.applicationInfo.isInstantApp()) {
|
||||
final String packageName = ri.activityInfo.packageName;
|
||||
final PackageSetting ps = mSettings.mPackages.get(packageName);
|
||||
@@ -6619,6 +6628,9 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
return null;
|
||||
}
|
||||
ri = new ResolveInfo(mResolveInfo);
|
||||
// if all resolve options are browsers, mark the resolver's info as if it were
|
||||
// also a browser.
|
||||
ri.handleAllWebDataURI = browserCount == N;
|
||||
ri.activityInfo = new ActivityInfo(ri.activityInfo);
|
||||
ri.activityInfo.labelRes = ResolverActivity.getLabelRes(intent.getAction());
|
||||
// If all of the options come from the same package, show the application's
|
||||
@@ -7129,7 +7141,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
// Check for results in the current profile.
|
||||
result = filterIfNotSystemUser(mComponentResolver.queryActivities(
|
||||
intent, resolvedType, flags, privateResolveFlags, userId), userId);
|
||||
intent, resolvedType, flags, userId), userId);
|
||||
addInstant = isInstantAppResolutionAllowed(intent, result, userId,
|
||||
false /*skipPackageCheck*/);
|
||||
// Check for cross profile results.
|
||||
@@ -7228,7 +7240,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
| PackageManager.GET_RESOLVED_FILTER
|
||||
| PackageManager.MATCH_INSTANT
|
||||
| PackageManager.MATCH_VISIBLE_TO_INSTANT_APP_ONLY,
|
||||
0, userId);
|
||||
userId);
|
||||
for (int i = instantApps.size() - 1; i >= 0; --i) {
|
||||
final ResolveInfo info = instantApps.get(i);
|
||||
final String packageName = info.activityInfo.packageName;
|
||||
@@ -7332,7 +7344,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
return null;
|
||||
}
|
||||
List<ResolveInfo> resultTargetUser = mComponentResolver.queryActivities(intent,
|
||||
resolvedType, flags, 0, parentUserId);
|
||||
resolvedType, flags, parentUserId);
|
||||
|
||||
if (resultTargetUser == null || resultTargetUser.isEmpty()) {
|
||||
return null;
|
||||
@@ -7780,7 +7792,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
String resolvedType, int flags, int sourceUserId) {
|
||||
int targetUserId = filter.getTargetUserId();
|
||||
List<ResolveInfo> resultTargetUser = mComponentResolver.queryActivities(intent,
|
||||
resolvedType, flags, 0, targetUserId);
|
||||
resolvedType, flags, targetUserId);
|
||||
if (resultTargetUser != null && isUserEnabled(targetUserId)) {
|
||||
// If all the matches in the target profile are suspended, return null.
|
||||
for (int i = resultTargetUser.size() - 1; i >= 0; i--) {
|
||||
|
||||
Reference in New Issue
Block a user