use of com.android.settings.applications.UserAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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(Collections.singletonList(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(Collections.singletonList(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 Resurrection_packages_apps_Settings by ResurrectionRemix.
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);
}
}
ThreadUtils.postOnMainThread(() -> updateUi());
}
use of com.android.settings.applications.UserAppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ApplicationListPreferenceController method onListOfAppsResult.
@Override
public void onListOfAppsResult(List<UserAppInfo> result) {
final PreferenceScreen screen = mParent.getPreferenceScreen();
if (screen == null) {
return;
}
final IconDrawableFactory iconDrawableFactory = IconDrawableFactory.newInstance(mContext);
final Context prefContext = mParent.getPreferenceManager().getContext();
for (int position = 0; position < result.size(); position++) {
final UserAppInfo item = result.get(position);
final Preference preference = new AppPreference(prefContext);
preference.setTitle(item.appInfo.loadLabel(mPm));
preference.setIcon(iconDrawableFactory.getBadgedIcon(item.appInfo));
preference.setOrder(position);
preference.setSelectable(false);
screen.addPreference(preference);
}
}
use of com.android.settings.applications.UserAppInfo in project android_packages_apps_Settings by omnirom.
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(Collections.singletonList(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(Collections.singletonList(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 LineageOS.
the class ApplicationListPreferenceController method onListOfAppsResult.
@Override
public void onListOfAppsResult(List<UserAppInfo> result) {
final PreferenceScreen screen = mParent.getPreferenceScreen();
if (screen == null) {
return;
}
final Context prefContext = mParent.getPreferenceManager().getContext();
for (int position = 0; position < result.size(); position++) {
final UserAppInfo item = result.get(position);
final Preference preference = new Preference(prefContext);
preference.setLayoutResource(R.layout.preference_app);
preference.setTitle(item.appInfo.loadLabel(mPm));
preference.setIcon(item.appInfo.loadIcon(mPm));
preference.setOrder(position);
preference.setSelectable(false);
screen.addPreference(preference);
}
}
Aggregations