List of usage examples for android.content.pm ApplicationInfo FLAG_INSTALLED
int FLAG_INSTALLED
To view the source code for android.content.pm ApplicationInfo FLAG_INSTALLED.
Click Source Link
From source file:com.example.android.apprestrictionenforcer.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_real); if (null == savedInstanceState) { DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService( Context.DEVICE_POLICY_SERVICE); PackageManager packageManager = getPackageManager(); if (!devicePolicyManager.isProfileOwnerApp(getApplicationContext().getPackageName())) { // If the managed profile is not yet set up, we show the setup screen. showSetupProfile();//from www . j a v a2s . c o m } else { try { ApplicationInfo info = packageManager.getApplicationInfo( Constants.PACKAGE_NAME_APP_RESTRICTION_SCHEMA, PackageManager.GET_UNINSTALLED_PACKAGES); if (0 == (info.flags & ApplicationInfo.FLAG_INSTALLED)) { // Need to reinstall the sample app showStatusProfile(); } else if (devicePolicyManager.isApplicationHidden( EnforcerDeviceAdminReceiver.getComponentName(this), Constants.PACKAGE_NAME_APP_RESTRICTION_SCHEMA)) { // The app is installed but hidden in this profile showStatusProfile(); } else { // Everything is clear; show the main screen showMainFragment(); } } catch (PackageManager.NameNotFoundException e) { showStatusProfile(); } } } }
From source file:com.example.android.apprestrictionenforcer.StatusFragment.java
private void updateUi(Activity activity) { PackageManager packageManager = activity.getPackageManager(); try {//from w ww . j av a 2 s . co m ApplicationInfo info = packageManager.getApplicationInfo(Constants.PACKAGE_NAME_APP_RESTRICTION_SCHEMA, PackageManager.GET_UNINSTALLED_PACKAGES); DevicePolicyManager devicePolicyManager = (DevicePolicyManager) activity .getSystemService(Activity.DEVICE_POLICY_SERVICE); if ((info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) { if (!devicePolicyManager.isApplicationHidden(EnforcerDeviceAdminReceiver.getComponentName(activity), Constants.PACKAGE_NAME_APP_RESTRICTION_SCHEMA)) { // The app is ready to enforce restrictions // This is unlikely to happen in this sample as unhideApp() handles it. mListener.onStatusUpdated(); } else { // The app is installed but hidden in this profile mTextStatus.setText(R.string.status_not_activated); mButtonUnhide.setVisibility(View.VISIBLE); } } else { // Need to reinstall the sample app mTextStatus.setText(R.string.status_need_reinstall); mButtonUnhide.setVisibility(View.GONE); } } catch (PackageManager.NameNotFoundException e) { // Need to reinstall the sample app mTextStatus.setText(R.string.status_need_reinstall); mButtonUnhide.setVisibility(View.GONE); } }
From source file:com.android.tv.settings.users.AppRestrictionsFragment.java
private boolean isAppEnabledForUser(PackageInfo pi) { if (pi == null) return false; final int flags = pi.applicationInfo.flags; final int privateFlags = pi.applicationInfo.privateFlags; // Return true if it is installed and not hidden return ((flags & ApplicationInfo.FLAG_INSTALLED) != 0 && (privateFlags & ApplicationInfo.PRIVATE_FLAG_HIDDEN) == 0); }
From source file:com.android.packageinstaller.PackageInstallerActivity.java
private void initiateInstall() { String pkgName = mPkgInfo.packageName; // Check if there is already a package on the device with this name // but it has been renamed to something else. String[] oldName = mPm.canonicalToCurrentPackageNames(new String[] { pkgName }); if (oldName != null && oldName.length > 0 && oldName[0] != null) { pkgName = oldName[0];//from w ww .ja va 2 s . co m mPkgInfo.packageName = pkgName; mPkgInfo.applicationInfo.packageName = pkgName; } // Check if package is already installed. display confirmation dialog if replacing pkg try { // This is a little convoluted because we want to get all uninstalled // apps, but this may include apps with just data, and if it is just // data we still want to count it as "installed". mAppInfo = mPm.getApplicationInfo(pkgName, PackageManager.GET_UNINSTALLED_PACKAGES); if ((mAppInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0) { mAppInfo = null; } } catch (NameNotFoundException e) { mAppInfo = null; } startInstallConfirm(); }
From source file:android.content.pm.PackageParser.java
private static void updateApplicationInfo(ApplicationInfo ai, int flags, PackageUserState state) { // CompatibilityMode is global state. if (!sCompatibilityModeEnabled) { ai.disableCompatibilityMode();/*from ww w.ja va 2 s. c om*/ } if (state.installed) { ai.flags |= ApplicationInfo.FLAG_INSTALLED; } else { ai.flags &= ~ApplicationInfo.FLAG_INSTALLED; } if (state.hidden) { ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_HIDDEN; } else { ai.privateFlags &= ~ApplicationInfo.PRIVATE_FLAG_HIDDEN; } if (state.enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { ai.enabled = true; } else if (state.enabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED) { ai.enabled = (flags & PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS) != 0; } else if (state.enabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED || state.enabled == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) { ai.enabled = false; } ai.enabledSetting = state.enabled; }