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:com.example.util.Utils.java
/** * ??//from w ww.j av a 2s. com */ public static List<PackageInfo> getInstalledApps(Context context) { PackageManager pm = context.getPackageManager(); final String ourPackageName = Session.get(context).getPackageName(); List<PackageInfo> packages = pm.getInstalledPackages(0); List<PackageInfo> apps = new ArrayList<PackageInfo>(); for (PackageInfo info : packages) { // ??? if (((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) && !ourPackageName.equals(info.packageName)) { apps.add(info); } } return apps; }
From source file:com.mappn.gfan.common.util.Utils.java
/** * ?/* ww w . j a v a2s.c o m*/ */ public static List<PackageInfo> getInstalledApps(Context context) { PackageManager pm = context.getPackageManager(); final String ourPackageName = Session.get(context).getPackageName(); List<PackageInfo> packages = pm.getInstalledPackages(0); List<PackageInfo> apps = new ArrayList<PackageInfo>(); for (PackageInfo info : packages) { // ?? if (((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) && !ourPackageName.equals(info.packageName)) { apps.add(info); } } return apps; }
From source file:android.content.pm.PackageParser.java
public static PackageInfo generatePackageInfo(PackageParser.Package p, int gids[], int flags, long firstInstallTime, long lastUpdateTime, Set<String> grantedPermissions, PackageUserState state, int userId) { if (!checkUseInstalledOrHidden(flags, state)) { return null; }//w w w. j a v a2 s.co m PackageInfo pi = new PackageInfo(); pi.packageName = p.packageName; pi.splitNames = p.splitNames; pi.versionCode = p.mVersionCode; pi.baseRevisionCode = p.baseRevisionCode; pi.splitRevisionCodes = p.splitRevisionCodes; pi.versionName = p.mVersionName; pi.sharedUserId = p.mSharedUserId; pi.sharedUserLabel = p.mSharedUserLabel; pi.applicationInfo = generateApplicationInfo(p, flags, state, userId); pi.installLocation = p.installLocation; pi.coreApp = p.coreApp; if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 || (pi.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) { pi.requiredForAllUsers = p.mRequiredForAllUsers; } pi.restrictedAccountType = p.mRestrictedAccountType; pi.requiredAccountType = p.mRequiredAccountType; pi.overlayTarget = p.mOverlayTarget; pi.firstInstallTime = firstInstallTime; pi.lastUpdateTime = lastUpdateTime; if ((flags & PackageManager.GET_GIDS) != 0) { pi.gids = gids; } if ((flags & PackageManager.GET_CONFIGURATIONS) != 0) { int N = p.configPreferences != null ? p.configPreferences.size() : 0; if (N > 0) { pi.configPreferences = new ConfigurationInfo[N]; p.configPreferences.toArray(pi.configPreferences); } N = p.reqFeatures != null ? p.reqFeatures.size() : 0; if (N > 0) { pi.reqFeatures = new FeatureInfo[N]; p.reqFeatures.toArray(pi.reqFeatures); } N = p.featureGroups != null ? p.featureGroups.size() : 0; if (N > 0) { pi.featureGroups = new FeatureGroupInfo[N]; p.featureGroups.toArray(pi.featureGroups); } } if ((flags & PackageManager.GET_ACTIVITIES) != 0) { int N = p.activities.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.activities = new ActivityInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.activities.get(i).info.enabled) num++; } pi.activities = new ActivityInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Activity activity = p.activities.get(i); if (activity.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.activities[j++] = generateActivityInfo(p.activities.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_RECEIVERS) != 0) { int N = p.receivers.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.receivers = new ActivityInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.receivers.get(i).info.enabled) num++; } pi.receivers = new ActivityInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Activity activity = p.receivers.get(i); if (activity.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.receivers[j++] = generateActivityInfo(p.receivers.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_SERVICES) != 0) { int N = p.services.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.services = new ServiceInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.services.get(i).info.enabled) num++; } pi.services = new ServiceInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Service service = p.services.get(i); if (service.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.services[j++] = generateServiceInfo(p.services.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_PROVIDERS) != 0) { int N = p.providers.size(); if (N > 0) { if ((flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.providers = new ProviderInfo[N]; } else { int num = 0; for (int i = 0; i < N; i++) { if (p.providers.get(i).info.enabled) num++; } pi.providers = new ProviderInfo[num]; } for (int i = 0, j = 0; i < N; i++) { final Provider provider = p.providers.get(i); if (provider.info.enabled || (flags & PackageManager.GET_DISABLED_COMPONENTS) != 0) { pi.providers[j++] = generateProviderInfo(p.providers.get(i), flags, state, userId); } } } } if ((flags & PackageManager.GET_INSTRUMENTATION) != 0) { int N = p.instrumentation.size(); if (N > 0) { pi.instrumentation = new InstrumentationInfo[N]; for (int i = 0; i < N; i++) { pi.instrumentation[i] = generateInstrumentationInfo(p.instrumentation.get(i), flags); } } } if ((flags & PackageManager.GET_PERMISSIONS) != 0) { int N = p.permissions.size(); if (N > 0) { pi.permissions = new PermissionInfo[N]; for (int i = 0; i < N; i++) { pi.permissions[i] = generatePermissionInfo(p.permissions.get(i), flags); } } N = p.requestedPermissions.size(); if (N > 0) { pi.requestedPermissions = new String[N]; pi.requestedPermissionsFlags = new int[N]; for (int i = 0; i < N; i++) { final String perm = p.requestedPermissions.get(i); pi.requestedPermissions[i] = perm; // The notion of required permissions is deprecated but for compatibility. pi.requestedPermissionsFlags[i] |= PackageInfo.REQUESTED_PERMISSION_REQUIRED; if (grantedPermissions != null && grantedPermissions.contains(perm)) { pi.requestedPermissionsFlags[i] |= PackageInfo.REQUESTED_PERMISSION_GRANTED; } } } } if ((flags & PackageManager.GET_SIGNATURES) != 0) { int N = (p.mSignatures != null) ? p.mSignatures.length : 0; if (N > 0) { pi.signatures = new Signature[N]; System.arraycopy(p.mSignatures, 0, pi.signatures, 0, N); } } return pi; }
From source file:com.onesignal.OneSignal.java
private static void registerUser() { Log(LOG_LEVEL.DEBUG,/*from w ww. j a va2 s . c om*/ "registerUser: registerForPushFired:" + registerForPushFired + ", locationFired: " + locationFired); if (!registerForPushFired || !locationFired) return; if (ranSessionInitThread) { updateRegistrationId(); return; } ranSessionInitThread = true; new Thread(new Runnable() { public void run() { OneSignalStateSynchronizer.UserState userState = OneSignalStateSynchronizer.getNewUserState(); String packageName = appContext.getPackageName(); PackageManager packageManager = appContext.getPackageManager(); userState.set("app_id", appId); userState.set("identifier", lastRegistrationId); String adId = mainAdIdProvider.getIdentifier(appContext); // "... must use the advertising ID (when available on a device) in lieu of any other device identifiers ..." // https://play.google.com/about/developer-content-policy.html if (adId == null) adId = new AdvertisingIdProviderFallback().getIdentifier(appContext); userState.set("ad_id", adId); userState.set("device_os", Build.VERSION.RELEASE); userState.set("timezone", getTimeZoneOffset()); userState.set("language", Locale.getDefault().getLanguage()); userState.set("sdk", VERSION); userState.set("sdk_type", sdkType); userState.set("android_package", packageName); userState.set("device_model", Build.MODEL); userState.set("device_type", deviceType); userState.setState("subscribableStatus", subscribableStatus); try { userState.set("game_version", packageManager.getPackageInfo(packageName, 0).versionCode); } catch (PackageManager.NameNotFoundException e) { } List<PackageInfo> packList = packageManager.getInstalledPackages(0); int count = -1; for (int i = 0; i < packList.size(); i++) count += ((packList.get(i).applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) ? 1 : 0; userState.set("pkgc", count); userState.set("net_type", osUtils.getNetType()); userState.set("carrier", osUtils.getCarrierName()); userState.set("rooted", RootToolsInternalMethods.isRooted()); userState.set("lat", lastLocLat); userState.set("long", lastLocLong); userState.set("loc_acc", lastLocAcc); userState.set("loc_type", lastLocType); OneSignalStateSynchronizer.postSession(userState); } }).start(); }
From source file:org.uguess.android.sysinfo.ApplicationManager.java
List<ApplicationInfo> filterApps(List<ApplicationInfo> apps) { if (apps == null || apps.size() == 0) { return apps; }// w ww .j a v a 2s .co m int type = Util.getIntOption(getActivity(), PSTORE_APPMANAGER, PREF_KEY_FILTER_APP_TYPE, APP_TYPE_ALL); if (type == APP_TYPE_SYS) { List<ApplicationInfo> sysApps = new ArrayList<ApplicationInfo>(); for (int i = 0, size = apps.size(); i < size; i++) { ApplicationInfo ai = apps.get(i); if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { sysApps.add(ai); } } return sysApps; } else if (type == APP_TYPE_USER) { List<ApplicationInfo> userApps = new ArrayList<ApplicationInfo>(); for (int i = 0, size = apps.size(); i < size; i++) { ApplicationInfo ai = apps.get(i); if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { userApps.add(ai); } } return userApps; } return apps; }
From source file:dev.ukanth.ufirewall.MainActivity.java
/** * Show the list of applications/*w ww. ja va2s . co m*/ */ private void showApplications(final String searchStr, int flag, boolean showAll) { setDirty(false); List<PackageInfoData> searchApp = new ArrayList<PackageInfoData>(); final List<PackageInfoData> apps = Api.getApps(this, null); boolean isResultsFound = false; if (searchStr != null && searchStr.length() > 1) { for (PackageInfoData app : apps) { for (String str : app.names) { if (str.contains(searchStr.toLowerCase()) || str.toLowerCase().contains(searchStr.toLowerCase()) && !searchApp.contains(app)) { searchApp.add(app); isResultsFound = true; } } } } else if (flag > -1) { switch (flag) { case 0: for (PackageInfoData app : apps) { if (app.pkgName.startsWith("dev.afwall.special")) { searchApp.add(app); } } break; case 1: for (PackageInfoData app : apps) { if (app.appinfo != null && (app.appinfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { searchApp.add(app); } } break; case 2: for (PackageInfoData app : apps) { if (app.appinfo != null && (app.appinfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { searchApp.add(app); } } break; } } List<PackageInfoData> apps2; if (showAll || (searchStr != null && searchStr.equals(""))) { apps2 = apps; } else if (isResultsFound || searchApp.size() > 0) { apps2 = searchApp; } else { apps2 = new ArrayList<PackageInfoData>(); } // Sort applications - selected first, then alphabetically Collections.sort(apps2, new PackageComparator()); this.listview.setAdapter(new AppListArrayAdapter(this, getApplicationContext(), apps2)); // restore this.listview.setSelectionFromTop(index, top); }
From source file:com.tapjoy.TapjoyConnectCore.java
/** * Handles the response from calling Connect. * @param response HTTP response from the server. * @return TRUE if the response is handled and notifier has been called, FALSE otherwise. *//* w ww.j a v a2 s . c o m*/ private static boolean handleConnectResponse(String response) { // Create a document so we can parse the XML easily. Document document = TapjoyUtil.buildDocument(response); if (document != null) { String nodeValue = TapjoyUtil.getNodeTrimValue(document.getElementsByTagName("PackageNames")); // Parse package names. if (nodeValue != null && nodeValue.length() > 0) { String data = nodeValue; Vector<String> allPackageNames = new Vector<String>(); int current = 0; int index = -1; while (true) { index = data.indexOf(',', current); // No commas left, grab the rest of the string. if (index == -1) { // Trim whitespace. TapjoyLog.i(TAPJOY_CONNECT, "parse: " + data.substring(current).trim()); allPackageNames.add(data.substring(current).trim()); break; } // Comma found, so get the substring. else { // Trim whitespace. TapjoyLog.i(TAPJOY_CONNECT, "parse: " + data.substring(current, index).trim()); allPackageNames.add(data.substring(current, index).trim()); current = index + 1; } } matchingPackageNames = ""; List<ApplicationInfo> applications = context.getPackageManager().getInstalledApplications(0); for (ApplicationInfo appInfo : applications) { // System app. if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) { //android.util.Log.i(TAPJOY, "system: " + appInfo.packageName); } // User installed app. else { if (allPackageNames.contains(appInfo.packageName)) { TapjoyLog.i(TAPJOY_CONNECT, "MATCH: installed packageName: " + appInfo.packageName); // Comma separate if there are previous entries. if (matchingPackageNames.length() > 0) matchingPackageNames += ","; matchingPackageNames += appInfo.packageName; } } } } nodeValue = TapjoyUtil.getNodeTrimValue(document.getElementsByTagName("Success")); // The Tapjoy Connect call was successful. if (nodeValue != null && nodeValue.equals("true")) { //TapjoyLog.i(TAPJOY_CONNECT, "Successfully connected to tapjoy site."); return true; } // else // { // TapjoyLog.e(TAPJOY_CONNECT, "Tapjoy Connect call failed."); // } } return true; }
From source file:org.uguess.android.sysinfo.ApplicationManager.java
void export(final List<AppInfoHolder> apps) { if (apps == null || apps.isEmpty()) { Util.shortToast(getActivity(), R.string.no_app_selected); return;/*w w w.java 2s. co m*/ } if (progress != null) { progress.dismiss(); } progress = new ProgressDialog(getActivity()); progress.setMessage(getResources().getString(R.string.start_exporting)); progress.setIndeterminate(false); progress.setCancelable(false); progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progress.setMax(apps.size()); progress.show(); new Thread(new Runnable() { public void run() { String exportFolder = Util.getStringOption(getActivity(), PSTORE_APPMANAGER, PREF_KEY_APP_EXPORT_DIR, DEFAULT_EXPORT_FOLDER); File output = new File(exportFolder); if (!output.exists()) { if (!output.mkdirs()) { handler.sendMessage(Message.obtain(handler, MSG_COPING_ERROR, 0, 0, getString(R.string.error_create_folder, output.getAbsolutePath()))); return; } } File sysoutput = new File(output, SYS_APP); if (!sysoutput.exists()) { if (!sysoutput.mkdirs()) { handler.sendMessage(Message.obtain(handler, MSG_COPING_ERROR, 0, 0, getString(R.string.error_create_folder, sysoutput.getAbsolutePath()))); return; } } File useroutput = new File(output, USER_APP); if (!useroutput.exists()) { if (!useroutput.mkdirs()) { handler.sendMessage(Message.obtain(handler, MSG_COPING_ERROR, 0, 0, getString(R.string.error_create_folder, useroutput.getAbsolutePath()))); return; } } int skipped = 0; int succeed = 0; for (int i = 0, size = apps.size(); i < size; i++) { ApplicationInfo app = apps.get(i).appInfo; String src = app.sourceDir; if (src != null) { File srcFile = new File(src); if (src.contains("/data/app-private") //$NON-NLS-1$ || !srcFile.canRead()) { skipped++; continue; } String appName = getFileName(src); if (appName != null && app.packageName != null) { // always use package name as the file name for // versatile match appName = app.packageName + ".apk"; //$NON-NLS-1$ File targetOutput = useroutput; if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { targetOutput = sysoutput; } File destFile = new File(targetOutput, appName); handler.sendMessage(Message.obtain(handler, MSG_COPING, appName)); try { copyFile(srcFile, destFile); succeed++; } catch (Exception e) { Log.e(ApplicationManager.class.getName(), e.getLocalizedMessage(), e); handler.sendMessage( Message.obtain(handler, MSG_COPING_ERROR, 1, 0, e.getLocalizedMessage())); continue; } } } } handler.sendMessage(Message.obtain(handler, MSG_COPING_FINISHED, succeed, skipped, apps)); } }).start(); }
From source file:com.android.wfds.printservice.WPrintService.java
private static synchronized void loadLibraries(ApplicationInfo appInfo) { if (!mLibrariesLoaded) { if (((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) || ((appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0)) { System.loadLibrary("wfdscrypto"); System.loadLibrary("wfdsssl"); System.loadLibrary("wfdsjpeg"); System.loadLibrary("wfdspng"); System.loadLibrary("wfdscups"); System.loadLibrary("wfds"); } else {/*from w w w . j a va2 s . c o m*/ System.load(Environment.getRootDirectory() + "/lib/libwfdscrypto.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdsssl.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdsjpeg.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdspng.so"); System.load(Environment.getRootDirectory() + "/lib/libwfdscups.so"); System.load(Environment.getRootDirectory() + "/lib/libwfds.so"); } mLibrariesLoaded = true; } }