List of usage examples for android.content.pm PackageManager GET_DISABLED_COMPONENTS
int GET_DISABLED_COMPONENTS
To view the source code for android.content.pm PackageManager GET_DISABLED_COMPONENTS.
Click Source Link
From source file:Main.java
public static List<ApplicationInfo> getInstalledApplications(PackageManager pm) { int retrieveFlags = PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS; List<ApplicationInfo> packages = pm.getInstalledApplications(retrieveFlags); return packages; }
From source file:com.github.michalbednarski.intentslab.browser.ApplicationFetcher.java
@Override
Object getEntries(Context context) {
PackageManager pm = context.getPackageManager();
int requestedPackageInfoFlags = PackageManager.GET_DISABLED_COMPONENTS
| (requireMetaDataSubstring != null ? PackageManager.GET_META_DATA : 0);
List<PackageInfo> allPackages = pm.getInstalledPackages(requestedPackageInfoFlags);
ArrayList<Component> selectedApps = new ArrayList<Component>();
for (PackageInfo pack : allPackages) {
ApplicationInfo applicationInfo = pack.applicationInfo;
// Filter out non-applications
if (applicationInfo == null) {
continue;
}/*from w w w . j a v a 2 s.c o m*/
// System app filter
if ((((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 ? APP_TYPE_SYSTEM : APP_TYPE_USER)
& appType) == 0) {
continue;
}
// Metadata filter
if (!checkMetaDataFilter(applicationInfo)) {
continue;
}
// Build and add app descriptor
Component app = new Component();
app.title = String.valueOf(applicationInfo.loadLabel(pm));
app.subtitle = pack.packageName;
app.componentInfo = applicationInfo;
selectedApps.add(app);
// Allow cancelling task
if (Thread.interrupted()) {
return null;
}
}
return selectedApps.toArray(new Component[selectedApps.size()]);
}
From source file:info.guardianproject.checkey.AppListLoader.java
/** * This is where the bulk of the work. This function is called in a * background thread and should generate a new set of data to be published * by the loader./* w w w . java 2s . co m*/ */ @Override public List<AppEntry> loadInBackground() { // Retrieve all known applications List<ApplicationInfo> apps = pm.getInstalledApplications( PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS); if (apps == null) { apps = new ArrayList<ApplicationInfo>(); } // Create corresponding array of entries and load their labels List<AppEntry> entries = new ArrayList<AppEntry>(apps.size()); for (ApplicationInfo applicationInfo : apps) { AppEntry entry = new AppEntry(this, applicationInfo); entry.loadLabel(pm); entries.add(entry); } Collections.sort(entries, Comparator.ALPHA_COMPARATOR); return entries; }
From source file:net.binaryparadox.kerplapp.AppListLoader.java
/** * This is where the bulk of the work. This function is called in a * background thread and should generate a new set of data to be published * by the loader./*from w ww .jav a 2 s.com*/ */ @Override public List<AppEntry> loadInBackground() { // Retrieve all known applications List<ApplicationInfo> apps = pm.getInstalledApplications( PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS); if (apps == null) { apps = new ArrayList<ApplicationInfo>(); } final Context context = getContext(); // Create corresponding array of entries and load their labels List<AppEntry> entries = new ArrayList<AppEntry>(apps.size()); for (ApplicationInfo applicationInfo : apps) { AppEntry entry = new AppEntry(this, applicationInfo); PackageInfo packageInfo = null; // Need to load the package info to get the app version code. // We can use the repo dir, the package name and the version code to // determine if the app is already in the repo to preselect it. try { entry.loadLabel(pm); packageInfo = pm.getPackageInfo(entry.getPackageName(), 0); } catch (NameNotFoundException e) { e.printStackTrace(); continue; //We need the package info for versionCode, skip this app } catch (Exception e) { e.printStackTrace(); continue; } String apkName = packageInfo.packageName + "_" + packageInfo.versionCode + ".apk"; File apkFile = new File(FDroidApp.localRepo.repoDir, apkName); if (apkFile.exists()) entry.setEnabled(true); entries.add(entry); // Add the entry if nothing has gone wrong } Collections.sort(entries, Comparator.ALPHA_COMPARATOR); return entries; }
From source file:fr.simon.marquis.preferencesmanager.util.Utils.java
public static ArrayList<AppEntry> getApplications(Context ctx) { PackageManager pm = ctx.getPackageManager(); if (pm == null) { applications = new ArrayList<AppEntry>(); } else {//w w w . j av a2s . c o m boolean showSystemApps = isShowSystemApps(ctx); List<ApplicationInfo> appsInfo = pm.getInstalledApplications( PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS); if (appsInfo == null) { appsInfo = new ArrayList<ApplicationInfo>(); } List<AppEntry> entries = new ArrayList<AppEntry>(appsInfo.size()); for (ApplicationInfo a : appsInfo) { if (showSystemApps || (a.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { entries.add(new AppEntry(a, ctx)); } } Collections.sort(entries, new MyComparator()); applications = new ArrayList<AppEntry>(entries); } Log.d(TAG, "Applications: " + Arrays.toString(applications.toArray())); return applications; }
From source file:com.github.michalbednarski.intentslab.editor.ComponentPickerDialogFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true);//ww w . ja va2 s . c o m // Get edited intent IntentEditorActivity intentEditor = (IntentEditorActivity) getActivity(); Intent intent = new Intent(intentEditor.getEditedIntent()); intent.setComponent(null); // Get components PackageManager pm = intentEditor.getPackageManager(); List<ResolveInfo> ri = null; switch (intentEditor.getComponentType()) { case IntentEditorConstants.ACTIVITY: ri = pm.queryIntentActivities(intent, PackageManager.GET_DISABLED_COMPONENTS); break; case IntentEditorConstants.BROADCAST: ri = pm.queryBroadcastReceivers(intent, PackageManager.GET_DISABLED_COMPONENTS); break; case IntentEditorConstants.SERVICE: ri = pm.queryIntentServices(intent, PackageManager.GET_DISABLED_COMPONENTS); break; } // Cancel if no components if (ri.isEmpty()) { Toast.makeText(getActivity(), R.string.no_matching_components_found, Toast.LENGTH_SHORT).show(); dismiss(); return; } // Split enabled and disabled choices ArrayList<ResolveInfo> choices = new ArrayList<ResolveInfo>(); ArrayList<ResolveInfo> disabledChoices = new ArrayList<ResolveInfo>(); for (ResolveInfo resolveInfo : ri) { (isComponentEnabled(pm, resolveInfo) ? choices : disabledChoices).add(resolveInfo); } mEnabledChoicesCount = choices.size(); choices.addAll(disabledChoices); mChoices = choices.toArray(new ResolveInfo[choices.size()]); }
From source file:com.github.michalbednarski.intentslab.browser.ComponentFetcher.java
@Override
Object getEntries(Context context) {
PackageManager pm = context.getPackageManager();
int requestedPackageInfoFlags = type | PackageManager.GET_DISABLED_COMPONENTS
| (requireMetaDataSubstring != null ? PackageManager.GET_META_DATA : 0);
boolean workAroundSmallBinderBuffer = false;
List<PackageInfo> allPackages = null;
try {/*w w w . jav a2 s . c o m*/
allPackages = pm.getInstalledPackages(requestedPackageInfoFlags);
} catch (Exception e) {
Log.w(TAG, "Loading all apps at once failed, retrying separately", e);
}
if (allPackages == null || allPackages.isEmpty()) {
workAroundSmallBinderBuffer = true;
allPackages = pm.getInstalledPackages(0);
}
ArrayList<Category> selectedApps = new ArrayList<Category>();
for (PackageInfo pack : allPackages) {
// Filter out non-applications
if (pack.applicationInfo == null) {
continue;
}
// System app filter
if ((((pack.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 ? APP_TYPE_SYSTEM : APP_TYPE_USER)
& appType) == 0) {
continue;
}
// Load component information separately if they were to big to send them all at once
if (workAroundSmallBinderBuffer) {
try {
pack = pm.getPackageInfo(pack.packageName, requestedPackageInfoFlags);
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "getPackageInfo() thrown NameNotFoundException for " + pack.packageName, e);
continue;
}
}
// Scan components
ArrayList<Component> selectedComponents = new ArrayList<Component>();
if ((type & PackageManager.GET_ACTIVITIES) != 0) {
scanComponents(pm, pack.activities, selectedComponents);
}
if ((type & PackageManager.GET_RECEIVERS) != 0) {
scanComponents(pm, pack.receivers, selectedComponents);
}
if ((type & PackageManager.GET_SERVICES) != 0) {
scanComponents(pm, pack.services, selectedComponents);
}
if ((type & PackageManager.GET_PROVIDERS) != 0) {
scanComponents(pm, pack.providers, selectedComponents);
}
// Check if we filtered out all components and skip whole app if so
if (selectedComponents.isEmpty()) {
continue;
}
// Build and add app descriptor
Category app = new Category();
app.title = String.valueOf(pack.applicationInfo.loadLabel(pm));
app.subtitle = pack.packageName;
app.components = selectedComponents.toArray(new Component[selectedComponents.size()]);
selectedApps.add(app);
// Allow cancelling task
if (Thread.interrupted()) {
return null;
}
}
return selectedApps.toArray(new Category[selectedApps.size()]);
}
From source file:at.jclehner.appopsxposed.BugReportBuilder.java
private void collectApkInfo(StringBuilder sb) { sb.append("\n---------------------------------------------------"); sb.append("\n--------------------- APK INFO --------------------"); final Intent intent = new Intent(); intent.setAction("android.settings.SETTINGS"); final HashMap<String, List<String>> appMap = new HashMap<String, List<String>>(); final List<ResolveInfo> rInfos = mContext.getPackageManager().queryIntentActivities(intent, PackageManager.GET_DISABLED_COMPONENTS); for (ResolveInfo rInfo : rInfos) { final ActivityInfo aInfo = rInfo.activityInfo; final String key = aInfo.applicationInfo.sourceDir + " (" + aInfo.packageName + ")" + toTickedBox(rInfo.activityInfo.applicationInfo.enabled); final List<String> activityList; if (!appMap.containsKey(key)) { activityList = new ArrayList<String>(); appMap.put(key, activityList); } else// www .j a va2s .co m activityList = appMap.get(key); activityList.add(aInfo.name + toTickedBox(aInfo.enabled)); } for (String key : appMap.keySet()) { sb.append("\n" + key); for (String activity : appMap.get(key)) sb.append("\n " + activity); } }
From source file:com.github.michalbednarski.intentslab.providerlab.ProviderInfoFragment.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) private void fillProviderInfo() throws PackageManager.NameNotFoundException { mProviderInfo = getActivity().getPackageManager().getProviderInfo( new ComponentName(mPackageName, mComponentName), PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_META_DATA | PackageManager.GET_URI_PERMISSION_PATTERNS); }
From source file:com.github.michalbednarski.intentslab.providerlab.ProviderInfoFragment.java
private void fillProviderInfoLegacy() throws PackageManager.NameNotFoundException { PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(mPackageName, PackageManager.GET_PROVIDERS | PackageManager.GET_DISABLED_COMPONENTS | PackageManager.GET_META_DATA | PackageManager.GET_URI_PERMISSION_PATTERNS); for (ProviderInfo provider : packageInfo.providers) { if (provider.name.equals(mComponentName)) { mProviderInfo = provider;/*from www. java2 s . c om*/ return; } } throw new PackageManager.NameNotFoundException("No such provider (manual search in PackageInfo)"); }