Merge "Don't list apps that are disabled by the system" into klp-dev

This commit is contained in:
Amith Yamasani
2013-08-27 21:42:57 +00:00
committed by Android (Google) Code Review

View File

@@ -479,13 +479,24 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_UNINSTALLED_PACKAGES);
for (ResolveInfo app : launchableApps) {
if (app.activityInfo != null && app.activityInfo.applicationInfo != null) {
final String packageName = app.activityInfo.packageName;
int flags = app.activityInfo.applicationInfo.flags;
if ((flags & ApplicationInfo.FLAG_SYSTEM) != 0
|| (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
// System app
// Skip excluded packages
if (excludePackages.contains(app.activityInfo.packageName)) continue;
if (excludePackages.contains(packageName)) continue;
int enabled = pm.getApplicationEnabledSetting(packageName);
if (enabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
|| enabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
// Check if the app is already enabled for the target user
ApplicationInfo targetUserAppInfo = getAppInfoForUser(packageName,
0, mUser);
if (targetUserAppInfo == null
|| (targetUserAppInfo.flags&ApplicationInfo.FLAG_INSTALLED) == 0) {
continue;
}
}
SelectableAppInfo info = new SelectableAppInfo();
info.packageName = app.activityInfo.packageName;
info.appName = app.activityInfo.applicationInfo.loadLabel(pm);
@@ -499,6 +510,16 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
}
}
private ApplicationInfo getAppInfoForUser(String packageName, int flags, UserHandle user) {
try {
ApplicationInfo targetUserAppInfo = mIPm.getApplicationInfo(packageName, flags,
user.getIdentifier());
return targetUserAppInfo;
} catch (RemoteException re) {
return null;
}
}
private class AppLoadingTask extends AsyncTask<Void, Void, Void> {
@Override
@@ -567,6 +588,7 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
}
}
// Get the list of apps already installed for the user
mUserApps = null;
try {
mUserApps = ipm.getInstalledApplications(
@@ -590,6 +612,8 @@ public class AppRestrictionsFragment extends SettingsPreferenceFragment implemen
}
}
}
// Sort the list of visible apps
Collections.sort(mVisibleApps, new AppLabelComparator());
// Remove dupes