use of com.android.settings.applications.UserAppInfo in project android_packages_apps_Settings by omnirom.
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 omnirom.
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 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());
}
Aggregations