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.landenlabs.all_devtool.PackageFragment.java
void loadAndAddPackages(boolean showSys, int flags) { List<PackageInfo> packList = getActivity().getPackageManager().getInstalledPackages(flags); if (packList != null) { for (int idx = 0; idx < packList.size(); idx++) { PackageInfo packInfo = packList.get(idx); if (((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) == showSys) { addPackageInfo(packInfo); }/* ww w .j a v a 2 s. co m*/ } } }
From source file:com.landenlabs.all_devtool.PackageFragment.java
boolean addPackageInfo(PackageInfo packInfo) { if (packInfo == null) return false; String packageName = packInfo.packageName.trim(); for (PackingItem item : m_workList) { if (item.fieldStr().equals(packageName)) { return false; }//from ww w . j av a 2 s. c o m } ArrayListPairString pkgList = new ArrayListPairString(); String appName = packInfo.applicationInfo.loadLabel(getActivity().getPackageManager()).toString().trim(); long pkgSize = 0; addList(pkgList, "Version", packInfo.versionName); addList(pkgList, "VerCode", String.valueOf(packInfo.versionCode)); // addList(pkgList, "Directory", packInfo.applicationInfo.sourceDir); try { File file = new File(packInfo.applicationInfo.sourceDir); pkgSize = file.length(); addList(pkgList, "FileSize", NumberFormat.getNumberInstance(Locale.getDefault()).format(pkgSize)); } catch (Exception ex) { } if (!TextUtils.isEmpty(packInfo.applicationInfo.permission)) addList(pkgList, "Permission", packInfo.applicationInfo.permission); if (packInfo.applicationInfo.sharedLibraryFiles != null) addList(pkgList, "ShrLibs", packInfo.applicationInfo.sharedLibraryFiles.toString()); addList(pkgList, "TargetSDK", String.valueOf(packInfo.applicationInfo.targetSdkVersion)); m_date.setTime(packInfo.firstInstallTime); addList(pkgList, "Install First", s_timeFormat.format(m_date)); m_date.setTime(packInfo.lastUpdateTime); addList(pkgList, "Install Last", s_timeFormat.format(m_date)); if (packInfo.requestedPermissions != null) { // addList(pkgList, "RegPermissions", Arrays.toString(packInfo.requestedPermissions).replaceAll("[a-z]*", "").replaceAll(",", "\n")); addList(pkgList, m_regPermissionsStr, String.format(" #%d", packInfo.requestedPermissions.length)); if (false) { for (int pidx = 0; pidx != packInfo.requestedPermissions.length; pidx++) { String perm = packInfo.requestedPermissions[pidx].replaceAll("[a-z.]*", ""); if (perm.length() > 30) perm = perm.substring(0, 30); addList(pkgList, String.format(" %2d", pidx), perm); } } } if (packInfo.permissions != null) { addList(pkgList, m_permissionsStr, String.format(" #%d", packInfo.permissions.length)); } if (packInfo.activities != null) { addList(pkgList, m_activitiesStr, String.format(" #%d", packInfo.activities.length)); } if (packInfo.services != null) { addList(pkgList, m_servicesStr, String.format(" #%d", packInfo.services.length)); } if (Build.VERSION.SDK_INT > 21) { if (packInfo.splitNames != null && packInfo.splitNames.length != 0) { for (int splitIdx = 0; splitIdx != packInfo.splitNames.length; splitIdx++) { addList(pkgList, String.format(" SplitName%2d", splitIdx), packInfo.splitNames[splitIdx]); } } } addList(pkgList, "Apk File", packInfo.applicationInfo.publicSourceDir); StringBuilder flagStr = new StringBuilder(); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) flagStr.append(" Debug "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_IS_GAME) != 0) flagStr.append(" Game "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) != 0) flagStr.append(" AllowBackup "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) flagStr.append(" System "); if ((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0) flagStr.append(" LargeHeap "); if (flagStr.length() != 0) { addList(pkgList, "Flags", flagStr.toString()); } if (packInfo.signatures != null) { String signatures = ""; for (android.content.pm.Signature sig : packInfo.signatures) { signatures = signatures + " " + sig.toCharsString(); } addList(pkgList, "Signature", signatures); } if (packInfo.providers != null) { addList(pkgList, m_providers, String.valueOf(packInfo.providers.length)); if (false) { String providers = ""; for (ProviderInfo providerInfo : packInfo.providers) { providers = providers + " " + providerInfo.name; } addList(pkgList, "Providers", providers); } } m_workList.add(new PackingItem(packInfo.packageName.trim(), pkgList, packInfo, pkgSize, appName)); return true; }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
/** * Displays an alert dialog that allows the user to select applications from all non-system * applications installed on the current profile. After the user selects an app, this app can't * be uninstallation.//from w ww . j ava 2 s. c om */ private void showBlockUninstallationPrompt() { Activity activity = getActivity(); if (activity == null || activity.isFinishing()) { return; } List<ApplicationInfo> applicationInfoList = mPackageManager.getInstalledApplications(0 /* No flag */); List<ResolveInfo> resolveInfoList = new ArrayList<ResolveInfo>(); Collections.sort(applicationInfoList, new ApplicationInfo.DisplayNameComparator(mPackageManager)); for (ApplicationInfo applicationInfo : applicationInfoList) { // Ignore system apps because they can't be uninstalled. if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.resolvePackageName = applicationInfo.packageName; resolveInfoList.add(resolveInfo); } } final BlockUninstallationInfoArrayAdapter blockUninstallationInfoArrayAdapter = new BlockUninstallationInfoArrayAdapter( getActivity(), R.id.pkg_name, resolveInfoList); ListView listview = new ListView(getActivity()); listview.setAdapter(blockUninstallationInfoArrayAdapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { blockUninstallationInfoArrayAdapter.onItemClick(parent, view, pos, id); } }); new AlertDialog.Builder(getActivity()).setTitle(R.string.block_uninstallation_title).setView(listview) .setPositiveButton(R.string.close, null /* Nothing to do */).show(); }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
/** * Shows an alert dialog which displays a list of disabled system apps. Clicking an app in the * dialog enables the app./*from ww w.j a v a2 s .c o m*/ */ private void showEnableSystemAppsPrompt() { // Disabled system apps list = {All system apps} - {Enabled system apps} final List<String> disabledSystemApps = new ArrayList<String>(); // This list contains both enabled and disabled apps. List<ApplicationInfo> allApps = mPackageManager .getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES); Collections.sort(allApps, new ApplicationInfo.DisplayNameComparator(mPackageManager)); // This list contains all enabled apps. List<ApplicationInfo> enabledApps = mPackageManager.getInstalledApplications(0 /* Default flags */); Set<String> enabledAppsPkgNames = new HashSet<String>(); for (ApplicationInfo applicationInfo : enabledApps) { enabledAppsPkgNames.add(applicationInfo.packageName); } for (ApplicationInfo applicationInfo : allApps) { // Interested in disabled system apps only. if (!enabledAppsPkgNames.contains(applicationInfo.packageName) && (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { disabledSystemApps.add(applicationInfo.packageName); } } if (disabledSystemApps.isEmpty()) { showToast(R.string.no_disabled_system_apps); } else { AppInfoArrayAdapter appInfoArrayAdapter = new AppInfoArrayAdapter(getActivity(), R.id.pkg_name, disabledSystemApps, true); new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.enable_system_apps_title)) .setAdapter(appInfoArrayAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int position) { String packageName = disabledSystemApps.get(position); mDevicePolicyManager.enableSystemApp(mAdminComponentName, packageName); showToast(R.string.enable_system_apps_by_package_name_success_msg, packageName); } }).show(); } }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
protected boolean isLauncherPreinstalled() { if (mLauncherCallbacks != null) { return mLauncherCallbacks.isLauncherPreinstalled(); }//from w w w. j a va 2 s .com PackageManager pm = getPackageManager(); try { ApplicationInfo ai = pm.getApplicationInfo(getComponentName().getPackageName(), 0); if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { return true; } else { return false; } } catch (NameNotFoundException e) { e.printStackTrace(); return false; } }