use of com.android.settings.applications.UserAppInfo in project android_packages_apps_Settings by SudaMod.
the class EnterpriseSetDefaultAppsListPreferenceControllerTest method testMultipleAppsForOneTypeOfDefault.
@Test
public void testMultipleAppsForOneTypeOfDefault() {
final UserInfo user = new UserInfo(USER_ID, "main", UserInfo.FLAG_ADMIN);
final ApplicationInfo appInfo1 = ApplicationTestUtils.buildInfo(APP_UID, APP_1, 0, 0);
final ApplicationInfo appInfo2 = ApplicationTestUtils.buildInfo(APP_UID, APP_2, 0, 0);
when(mFeatureFactory.userFeatureProvider.getUserProfiles()).thenReturn(Arrays.asList(new UserHandle(USER_ID)));
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isInCompMode()).thenReturn(false);
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(anyInt(), any())).thenReturn(Collections.emptyList());
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(eq(USER_ID), eq(EnterpriseDefaultApps.BROWSER.getIntents()))).thenReturn(Arrays.asList(new UserAppInfo(user, appInfo1)));
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(eq(USER_ID), eq(EnterpriseDefaultApps.PHONE.getIntents()))).thenReturn(Arrays.asList(new UserAppInfo(user, appInfo1), new UserAppInfo(user, appInfo2)));
new EnterpriseSetDefaultAppsListPreferenceController(mContext, mFragment, mPackageManager);
ShadowApplication.runBackgroundTasks();
ArgumentCaptor<Preference> apps = ArgumentCaptor.forClass(Preference.class);
verify(mScreen, times(2)).addPreference(apps.capture());
assertThat(apps.getAllValues().get(0).getTitle()).isEqualTo(BROWSER_TITLE);
assertThat(apps.getAllValues().get(0).getSummary()).isEqualTo(APP_1);
assertThat(apps.getAllValues().get(1).getTitle()).isEqualTo(PHONE_TITLE);
assertThat(apps.getAllValues().get(1).getSummary()).isEqualTo(APP_1 + ", " + APP_2);
}
use of com.android.settings.applications.UserAppInfo in project android_packages_apps_Settings by SudaMod.
the class EnterpriseSetDefaultAppsPreferenceControllerTest method setEnterpriseSetDefaultApps.
private void setEnterpriseSetDefaultApps(Intent[] intents, int number) {
final ApplicationInfo appInfo = new ApplicationInfo();
appInfo.packageName = "app";
for (int i = 0; i < number; i++) {
final List<UserAppInfo> apps = new ArrayList<>(number);
apps.add(new UserAppInfo(new UserInfo(i, "user." + i, UserInfo.FLAG_ADMIN), appInfo));
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(eq(i), argThat(matchesIntents(intents)))).thenReturn(apps);
}
}
use of com.android.settings.applications.UserAppInfo in project android_packages_apps_Settings by DirtyUnicorns.
the class EnterpriseSetDefaultAppsListPreferenceControllerTest method testMultipleAppsForOneTypeOfDefault.
@Test
public void testMultipleAppsForOneTypeOfDefault() {
final UserInfo user = new UserInfo(USER_ID, "main", UserInfo.FLAG_ADMIN);
final ApplicationInfo appInfo1 = ApplicationTestUtils.buildInfo(APP_UID, APP_1, 0, 0);
final ApplicationInfo appInfo2 = ApplicationTestUtils.buildInfo(APP_UID, APP_2, 0, 0);
when(mFeatureFactory.userFeatureProvider.getUserProfiles()).thenReturn(Arrays.asList(new UserHandle(USER_ID)));
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isInCompMode()).thenReturn(false);
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(anyInt(), any())).thenReturn(Collections.emptyList());
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(eq(USER_ID), eq(EnterpriseDefaultApps.BROWSER.getIntents()))).thenReturn(Arrays.asList(new UserAppInfo(user, appInfo1)));
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(eq(USER_ID), eq(EnterpriseDefaultApps.PHONE.getIntents()))).thenReturn(Arrays.asList(new UserAppInfo(user, appInfo1), new UserAppInfo(user, appInfo2)));
new EnterpriseSetDefaultAppsListPreferenceController(mContext, mFragment, mPackageManager);
ShadowApplication.runBackgroundTasks();
ArgumentCaptor<Preference> apps = ArgumentCaptor.forClass(Preference.class);
verify(mScreen, times(2)).addPreference(apps.capture());
assertThat(apps.getAllValues().get(0).getTitle()).isEqualTo(BROWSER_TITLE);
assertThat(apps.getAllValues().get(0).getSummary()).isEqualTo(APP_1);
assertThat(apps.getAllValues().get(1).getTitle()).isEqualTo(PHONE_TITLE);
assertThat(apps.getAllValues().get(1).getSummary()).isEqualTo(APP_1 + ", " + APP_2);
}
use of com.android.settings.applications.UserAppInfo in project platform_packages_apps_Settings by BlissRoms.
the class EnterpriseSetDefaultAppsListPreferenceController method buildAppList.
/**
* Builds data for UI. Updates mUsers and mApps so that they contain non-empty list.
*/
private void buildAppList() {
mUsers = new ArrayList<>();
mApps = new ArrayList<>();
for (UserHandle user : mUserFeatureProvider.getUserProfiles()) {
boolean hasDefaultsForUser = false;
EnumMap<EnterpriseDefaultApps, List<ApplicationInfo>> userMap = null;
for (EnterpriseDefaultApps typeOfDefault : EnterpriseDefaultApps.values()) {
List<UserAppInfo> apps = mApplicationFeatureProvider.findPersistentPreferredActivities(user.getIdentifier(), typeOfDefault.getIntents());
if (apps.isEmpty()) {
continue;
}
if (!hasDefaultsForUser) {
hasDefaultsForUser = true;
mUsers.add(apps.get(0).userInfo);
userMap = new EnumMap<>(EnterpriseDefaultApps.class);
mApps.add(userMap);
}
ArrayList<ApplicationInfo> applicationInfos = new ArrayList<>();
for (UserAppInfo userAppInfo : apps) {
applicationInfos.add(userAppInfo.appInfo);
}
userMap.put(typeOfDefault, applicationInfos);
}
}
new Handler(mContext.getMainLooper()).post(() -> {
updateUi();
});
}
use of com.android.settings.applications.UserAppInfo in project platform_packages_apps_Settings by BlissRoms.
the class EnterpriseSetDefaultAppsListPreferenceControllerTest method testMultipleAppsForOneTypeOfDefault.
@Test
public void testMultipleAppsForOneTypeOfDefault() {
final UserInfo user = new UserInfo(USER_ID, "main", UserInfo.FLAG_ADMIN);
final ApplicationInfo appInfo1 = ApplicationTestUtils.buildInfo(APP_UID, APP_1, 0, 0);
final ApplicationInfo appInfo2 = ApplicationTestUtils.buildInfo(APP_UID, APP_2, 0, 0);
when(mFeatureFactory.userFeatureProvider.getUserProfiles()).thenReturn(Arrays.asList(new UserHandle(USER_ID)));
when(mFeatureFactory.enterprisePrivacyFeatureProvider.isInCompMode()).thenReturn(false);
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(anyInt(), any())).thenReturn(Collections.emptyList());
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(eq(USER_ID), eq(EnterpriseDefaultApps.BROWSER.getIntents()))).thenReturn(Arrays.asList(new UserAppInfo(user, appInfo1)));
when(mFeatureFactory.applicationFeatureProvider.findPersistentPreferredActivities(eq(USER_ID), eq(EnterpriseDefaultApps.PHONE.getIntents()))).thenReturn(Arrays.asList(new UserAppInfo(user, appInfo1), new UserAppInfo(user, appInfo2)));
new EnterpriseSetDefaultAppsListPreferenceController(mContext, mFragment, mPackageManager);
ShadowApplication.runBackgroundTasks();
ArgumentCaptor<Preference> apps = ArgumentCaptor.forClass(Preference.class);
verify(mScreen, times(2)).addPreference(apps.capture());
assertThat(apps.getAllValues().get(0).getTitle()).isEqualTo(BROWSER_TITLE);
assertThat(apps.getAllValues().get(0).getSummary()).isEqualTo(APP_1);
assertThat(apps.getAllValues().get(1).getTitle()).isEqualTo(PHONE_TITLE);
assertThat(apps.getAllValues().get(1).getSummary()).isEqualTo(APP_1 + ", " + APP_2);
}
Aggregations