Do not include disabled activity in Default Browser.
- query the intent activites with flags 0, so that only enabled activities will be returned. Change-Id: I6ec4e3f3fdff850228a723bcb2d2bdc5721b41eb Fixes: 111796304 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -18,9 +18,9 @@ package com.android.settings.applications.defaultapps;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -133,8 +133,11 @@ public class DefaultBrowserPreferenceControllerTest {
|
||||
@Test
|
||||
public void isBrowserDefault_onlyApp_shouldReturnTrue() {
|
||||
when(mPackageManager.getDefaultBrowserPackageNameAsUser(anyInt())).thenReturn(null);
|
||||
final List<ResolveInfo> resolveInfos = new ArrayList<>();
|
||||
final String PACKAGE_ONE = "pkg";
|
||||
resolveInfos.add(createResolveInfo(PACKAGE_ONE));
|
||||
when(mPackageManager.queryIntentActivitiesAsUser(any(Intent.class), anyInt(), anyInt()))
|
||||
.thenReturn(Collections.singletonList(new ResolveInfo()));
|
||||
.thenReturn(resolveInfos);
|
||||
|
||||
assertThat(mController.isBrowserDefault("pkg", 0)).isTrue();
|
||||
}
|
||||
@@ -161,6 +164,15 @@ public class DefaultBrowserPreferenceControllerTest {
|
||||
assertThat(defaultBrowserInfo.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCandidates_shouldQueryActivityWithFlagsEquals0() {
|
||||
|
||||
mController.getCandidates(mPackageManager, 0 /* userId */);
|
||||
|
||||
verify(mPackageManager).queryIntentActivitiesAsUser(
|
||||
any(Intent.class), eq(0) /* flags */, eq(0) /* userId */);
|
||||
}
|
||||
|
||||
private ResolveInfo createResolveInfo(String packageName) {
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.handleAllWebDataURI = true;
|
||||
|
Reference in New Issue
Block a user