Merge "Use MATCH_ALL to query available browsers."
This commit is contained in:
committed by
Android (Google) Code Review
commit
1de49122d3
@@ -45,7 +45,8 @@ public class DefaultBrowserPreferenceController extends DefaultAppPreferenceCont
|
|||||||
static final Intent BROWSE_PROBE = new Intent()
|
static final Intent BROWSE_PROBE = new Intent()
|
||||||
.setAction(Intent.ACTION_VIEW)
|
.setAction(Intent.ACTION_VIEW)
|
||||||
.addCategory(Intent.CATEGORY_BROWSABLE)
|
.addCategory(Intent.CATEGORY_BROWSABLE)
|
||||||
.setData(Uri.parse("http:"));
|
.setData(Uri.parse("http:"))
|
||||||
|
.addFlags(Intent.FLAG_IGNORE_EPHEMERAL);
|
||||||
|
|
||||||
public DefaultBrowserPreferenceController(Context context) {
|
public DefaultBrowserPreferenceController(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -112,11 +113,13 @@ public class DefaultBrowserPreferenceController extends DefaultAppPreferenceCont
|
|||||||
final List<ResolveInfo> candidates = new ArrayList<>();
|
final List<ResolveInfo> candidates = new ArrayList<>();
|
||||||
// Resolve that intent and check that the handleAllWebDataURI boolean is set
|
// Resolve that intent and check that the handleAllWebDataURI boolean is set
|
||||||
final List<ResolveInfo> list = packageManager.queryIntentActivitiesAsUser(
|
final List<ResolveInfo> list = packageManager.queryIntentActivitiesAsUser(
|
||||||
BROWSE_PROBE, 0 /* flags */, userId);
|
BROWSE_PROBE, PackageManager.MATCH_ALL, userId);
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
final Set<String> addedPackages = new ArraySet<>();
|
final Set<String> addedPackages = new ArraySet<>();
|
||||||
for (ResolveInfo info : list) {
|
for (ResolveInfo info : list) {
|
||||||
if (info.activityInfo == null || !info.handleAllWebDataURI) {
|
if (!info.handleAllWebDataURI || info.activityInfo == null
|
||||||
|
|| !info.activityInfo.enabled
|
||||||
|
|| !info.activityInfo.applicationInfo.enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final String packageName = info.activityInfo.packageName;
|
final String packageName = info.activityInfo.packageName;
|
||||||
|
@@ -181,11 +181,11 @@ public class DefaultBrowserPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getCandidates_shouldQueryActivityWithFlagsEquals0() {
|
public void getCandidates_shouldQueryActivityWithMatchAll() {
|
||||||
DefaultBrowserPreferenceController.getCandidates(mPackageManager, 0 /* userId */);
|
DefaultBrowserPreferenceController.getCandidates(mPackageManager, 0 /* userId */);
|
||||||
|
|
||||||
verify(mPackageManager).queryIntentActivitiesAsUser(
|
verify(mPackageManager).queryIntentActivitiesAsUser(
|
||||||
any(Intent.class), eq(0) /* flags */, eq(0) /* userId */);
|
any(Intent.class), eq(PackageManager.MATCH_ALL), eq(0) /* userId */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -221,6 +221,7 @@ public class DefaultBrowserPreferenceControllerTest {
|
|||||||
info.handleAllWebDataURI = true;
|
info.handleAllWebDataURI = true;
|
||||||
info.activityInfo = new ActivityInfo();
|
info.activityInfo = new ActivityInfo();
|
||||||
info.activityInfo.packageName = packageName;
|
info.activityInfo.packageName = packageName;
|
||||||
|
info.activityInfo.applicationInfo = createApplicationInfo(packageName);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user