Java Code Examples for android.content.pm.PackageManager#getApplicationEnabledSetting()
The following examples show how to use
android.content.pm.PackageManager#getApplicationEnabledSetting() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Rule.java From Android-Firewall with GNU General Public License v3.0 | 6 votes |
private Rule(PackageInfo info, boolean wifi_blocked, boolean other_blocked, boolean changed, Context context) { PackageManager pm = context.getPackageManager(); this.info = info; this.name = info.applicationInfo.loadLabel(pm).toString(); this.system = ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0); int setting = pm.getApplicationEnabledSetting(info.packageName); if (setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) this.disabled = !info.applicationInfo.enabled; else this.disabled = (setting != PackageManager.COMPONENT_ENABLED_STATE_ENABLED); this.wifi_blocked = wifi_blocked; this.other_blocked = other_blocked; this.changed = changed; }
Example 2
Source File: ApplicationInfoEx.java From XPrivacy with GNU General Public License v3.0 | 6 votes |
public boolean isFrozen(Context context) { if (mFrozen == null) { PackageManager pm = context.getPackageManager(); boolean enabled = false; for (ApplicationInfo appInfo : mMapAppInfo.values()) try { int setting = pm.getApplicationEnabledSetting(appInfo.packageName); enabled = (enabled || setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT); enabled = (enabled || setting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED); if (enabled) break; } catch (IllegalArgumentException ignored) { } mFrozen = !enabled; } return mFrozen; }
Example 3
Source File: Util.java From tracker-control-android with GNU General Public License v3.0 | 5 votes |
public static boolean isEnabled(PackageInfo info, Context context) { int setting; try { PackageManager pm = context.getPackageManager(); setting = pm.getApplicationEnabledSetting(info.packageName); } catch (IllegalArgumentException ex) { setting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; Log.w(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } if (setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) return info.applicationInfo.enabled; else return (setting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED); }
Example 4
Source File: Util.java From InviZible with GNU General Public License v3.0 | 5 votes |
static boolean isEnabled(PackageInfo info, Context context) { int setting; try { PackageManager pm = context.getPackageManager(); setting = pm.getApplicationEnabledSetting(info.packageName); } catch (IllegalArgumentException ex) { setting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; Log.w(LOG_TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } if (setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) return info.applicationInfo.enabled; else return (setting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED); }
Example 5
Source File: FUFUtils.java From FreezeYou with Apache License 2.0 | 5 votes |
public static boolean checkRootFrozen(Context context, String pkgName, PackageManager packageManager) { int tmp; try { tmp = packageManager == null ? context.getPackageManager().getApplicationEnabledSetting(pkgName) : packageManager.getApplicationEnabledSetting(pkgName); } catch (Exception e) { tmp = -1; } return ((tmp == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) || (tmp == PackageManager.COMPONENT_ENABLED_STATE_DISABLED)); }
Example 6
Source File: Util.java From kcanotify with GNU General Public License v3.0 | 5 votes |
public static boolean isEnabled(PackageInfo info, Context context) { int setting; try { PackageManager pm = context.getPackageManager(); setting = pm.getApplicationEnabledSetting(info.packageName); } catch (IllegalArgumentException ex) { setting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; Log.w(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } if (setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) return info.applicationInfo.enabled; else return (setting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED); }
Example 7
Source File: Util.java From NetGuard with GNU General Public License v3.0 | 5 votes |
public static boolean isEnabled(PackageInfo info, Context context) { int setting; try { PackageManager pm = context.getPackageManager(); setting = pm.getApplicationEnabledSetting(info.packageName); } catch (IllegalArgumentException ex) { setting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; Log.w(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } if (setting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) return info.applicationInfo.enabled; else return (setting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED); }
Example 8
Source File: InstalledApp.java From ApkTrack with GNU General Public License v3.0 | 4 votes |
/** * This function queries the system to obtain all the information needed to insert a new * app in the database. * The app will be persisted by this function. * * @param pacman The package manager * @param pi The PackageInfo object related to the target application * @return The resulting InstalledApp object, or <code>null</code> if the app couldn't be * created (happens if the app is deleted while this function runs). */ private static InstalledApp _create_application(PackageManager pacman, PackageInfo pi) { if (pi == null || pacman == null) { return null; } ApplicationInfo info; try { info = pacman.getApplicationInfo(pi.packageName, PackageManager.GET_META_DATA); } catch (final PackageManager.NameNotFoundException e) { info = null; } String applicationName = (String) (info != null ? pacman.getApplicationLabel(info) : null); InstalledApp app = new InstalledApp(pi.packageName, applicationName, pi.versionName, null, is_system_package(pi)); // Try to guess the update source UpdateSource us = UpdateSource.guess_update_source(pi, info != null ? info.metaData : null); if (us != null) { app.set_update_source(us.get_name()); } // If the app is disabled, assume the user wants to ignore its updates. int status; try { status = pacman.getApplicationEnabledSetting(pi.packageName); } // It happened once that the app was deleted in the meantime catch (IllegalArgumentException ignored) { return null; } if (status == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER || status == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) { app.set_ignored(true); } // Handle the icon if there is one present. _handle_icon(pacman, info, app); app.save(); return app; }