List of usage examples for android.content.pm ApplicationInfo FLAG_SYSTEM
int FLAG_SYSTEM
To view the source code for android.content.pm ApplicationInfo FLAG_SYSTEM.
Click Source Link
From source file:cn.whereyougo.framework.utils.PackageManagerUtil.java
/** * ?? ???????//w ww .java 2s.co m * * @return */ public static List<PackageInfo> getInstalledUserApps(Context context) { PackageManager packageManager = context.getPackageManager(); List<PackageInfo> result = new ArrayList<PackageInfo>(); List<PackageInfo> list = packageManager.getInstalledPackages(0);// ? for (PackageInfo packageInfo : list) { if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) <= 0) { // ??? result.add(packageInfo); } } return result; }
From source file:com.dnielfe.manager.AppManager.java
private void get_downloaded_apps() { List<ApplicationInfo> all_apps = pm.getInstalledApplications(PackageManager.GET_META_DATA); if (!mAppList.isEmpty()) mAppList.clear();// w w w . jav a 2s. c o m for (ApplicationInfo appInfo : all_apps) { if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0 && (appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0 && appInfo.flags != 0) mAppList.add(appInfo); } // Sorting ListView showing Installed Applications Collections.sort(mAppList, new ApplicationInfo.DisplayNameComparator(pm)); // update UI initActionBar(); mAdapter.notifyDataSetChanged(); }
From source file:org.cyanogenmod.theme.chooser.ChooserDetailFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { try {/* w ww. ja va 2s .co m*/ ApplicationInfo themeApplicationInfo = getActivity().getPackageManager().getApplicationInfo(mPkgName, 0); if (!mPkgName.equals("system") && (themeApplicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { inflater.inflate(R.menu.chooser_detail_menu, menu); } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, e.getMessage()); } }
From source file:nl.jalava.appostle.AppListFragment.java
private void updateApps() { List<PackageInfo> apps = pm.getInstalledPackages(0); Vector<AppInfo> app_data = new Vector<>(); for (PackageInfo pi : apps) { ApplicationInfo ai;//from w ww .j a va 2 s . c o m try { ai = pm.getApplicationInfo(pi.packageName, 0); } catch (NameNotFoundException e) { continue; } // Which apps? switch (mCurrentAppType) { case 0: if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) continue; // Skip system apps. break; case 1: if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0) continue; // Skip installed apps. break; } String name = (String) pm.getApplicationLabel(ai); // Get last updated date. long updated = pi.lastUpdateTime; // Localized date. String dateString = android.text.format.DateFormat.getDateFormat(mContext).format(new Date(updated)); // Get app info. AppInfo app = new AppInfo(); app.name = name; app.date = dateString; app.version = pi.versionName; app.packageName = pi.packageName; app.lastUpdateTime = updated; app_data.add(app); } mAppInfoAdapter = new AppInfoAdapter(mContext, R.layout.app_row, app_data); SortAppInfoAdapter(); }
From source file:android_network.hetnet.vpn_service.Util.java
public static boolean isSystem(String packageName, Context context) { try {/*from w w w . j ava 2 s . c o m*/ PackageManager pm = context.getPackageManager(); PackageInfo info = pm.getPackageInfo(packageName, 0); return ((info.applicationInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0); /* PackageInfo pkg = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); PackageInfo sys = pm.getPackageInfo("android", PackageManager.GET_SIGNATURES); return (pkg != null && pkg.signatures != null && pkg.signatures.length > 0 && sys.signatures.length > 0 && sys.signatures[0].equals(pkg.signatures[0])); */ } catch (PackageManager.NameNotFoundException ignore) { return false; } }
From source file:org.wso2.iot.agent.api.ApplicationManager.java
/** * Returns a list of all the applications installed on the device by user. * * @return - List of applications which installed on the device by user. *//*from w w w. j a v a2s .c om*/ public List<String> getInstalledAppsByUser() { List<String> packagesInstalledByUser = new ArrayList<>(); int flags = PackageManager.GET_META_DATA; List<ApplicationInfo> applications = packageManager.getInstalledApplications(flags); for (ApplicationInfo appInfo : applications) { if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 1) { packagesInstalledByUser.add(appInfo.packageName); } } return packagesInstalledByUser; }
From source file:org.wso2.iot.agent.api.ApplicationManager.java
/** * Return the list of the package names of the apps(hidden and visible) that are user owned * * @return - list of package names of the apps that are not system apps */// w ww . j a va 2 s . c om public List<String> getAppsOfUser() { List<String> packagesInstalledByUser = new ArrayList<>(); int flags = PackageManager.GET_META_DATA | PackageManager.GET_SHARED_LIBRARY_FILES | PackageManager.GET_UNINSTALLED_PACKAGES; List<ApplicationInfo> applications = packageManager.getInstalledApplications(flags); for (ApplicationInfo appInfo : applications) { if (!((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1)) { packagesInstalledByUser.add(appInfo.packageName); } } return packagesInstalledByUser; }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Return whether the given PackgeInfo represents a system package or not. * User-installed packages should not be denoted as system packages. * /*w w w . j av a 2s .co m*/ * @param appInfo * @return */ public static boolean system_isSystemPackage(ApplicationInfo appInfo) { return ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) ? true : false; }
From source file:org.mozilla.gecko.GeckoApp.java
String[] getPluginDirectories() { // we don't support Honeycomb if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && Build.VERSION.SDK_INT < 14 /*Build.VERSION_CODES.ICE_CREAM_SANDWICH*/ ) return new String[0]; Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - start of getPluginDirectories"); ArrayList<String> directories = new ArrayList<String>(); PackageManager pm = mAppContext.getPackageManager(); List<ResolveInfo> plugins = pm.queryIntentServices(new Intent(PLUGIN_ACTION), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA); synchronized (mPackageInfoCache) { // clear the list of existing packageInfo objects mPackageInfoCache.clear();/*from www . ja v a 2 s . c o m*/ for (ResolveInfo info : plugins) { // retrieve the plugin's service information ServiceInfo serviceInfo = info.serviceInfo; if (serviceInfo == null) { Log.w(LOGTAG, "Ignore bad plugin"); continue; } // Blacklist HTC's flash lite. // See bug #704516 - We're not quite sure what Flash Lite does, // but loading it causes Flash to give errors and fail to draw. if (serviceInfo.packageName.equals("com.htc.flashliteplugin")) { Log.w(LOGTAG, "Skipping HTC's flash lite plugin"); continue; } Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName); // retrieve information from the plugin's manifest PackageInfo pkgInfo; try { pkgInfo = pm.getPackageInfo(serviceInfo.packageName, PackageManager.GET_PERMISSIONS | PackageManager.GET_SIGNATURES); } catch (Exception e) { Log.w(LOGTAG, "Can't find plugin: " + serviceInfo.packageName); continue; } if (pkgInfo == null) { Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName + ". Could not load package information."); continue; } /* * find the location of the plugin's shared library. The default * is to assume the app is either a user installed app or an * updated system app. In both of these cases the library is * stored in the app's data directory. */ String directory = pkgInfo.applicationInfo.dataDir + "/lib"; final int appFlags = pkgInfo.applicationInfo.flags; final int updatedSystemFlags = ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP; // preloaded system app with no user updates if ((appFlags & updatedSystemFlags) == ApplicationInfo.FLAG_SYSTEM) { directory = PLUGIN_SYSTEM_LIB + pkgInfo.packageName; } // check if the plugin has the required permissions String permissions[] = pkgInfo.requestedPermissions; if (permissions == null) { Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName + ". Does not have required permission."); continue; } boolean permissionOk = false; for (String permit : permissions) { if (PLUGIN_PERMISSION.equals(permit)) { permissionOk = true; break; } } if (!permissionOk) { Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName + ". Does not have required permission (2)."); continue; } // check to ensure the plugin is properly signed Signature signatures[] = pkgInfo.signatures; if (signatures == null) { Log.w(LOGTAG, "Loading plugin: " + serviceInfo.packageName + ". Not signed."); continue; } // determine the type of plugin from the manifest if (serviceInfo.metaData == null) { Log.e(LOGTAG, "The plugin '" + serviceInfo.name + "' has no type defined"); continue; } String pluginType = serviceInfo.metaData.getString(PLUGIN_TYPE); if (!TYPE_NATIVE.equals(pluginType)) { Log.e(LOGTAG, "Unrecognized plugin type: " + pluginType); continue; } try { Class<?> cls = getPluginClass(serviceInfo.packageName, serviceInfo.name); //TODO implement any requirements of the plugin class here! boolean classFound = true; if (!classFound) { Log.e(LOGTAG, "The plugin's class' " + serviceInfo.name + "' does not extend the appropriate class."); continue; } } catch (NameNotFoundException e) { Log.e(LOGTAG, "Can't find plugin: " + serviceInfo.packageName); continue; } catch (ClassNotFoundException e) { Log.e(LOGTAG, "Can't find plugin's class: " + serviceInfo.name); continue; } // if all checks have passed then make the plugin available mPackageInfoCache.add(pkgInfo); directories.add(directory); } } String[] result = directories.toArray(new String[directories.size()]); Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - end of getPluginDirectories"); return result; }
From source file:com.android.tv.settings.MainFragment.java
private ResolveInfo systemIntentIsHandled(Intent intent) { if (intent == null) { return null; }//from w w w . j a va2 s . c om final PackageManager pm = getContext().getPackageManager(); for (ResolveInfo info : pm.queryIntentActivities(intent, 0)) { if (info.activityInfo != null && info.activityInfo.enabled && (info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == ApplicationInfo.FLAG_SYSTEM) { return info; } } return null; }