Example usage for android.content.pm ApplicationInfo PRIVATE_FLAG_HIDDEN

List of usage examples for android.content.pm ApplicationInfo PRIVATE_FLAG_HIDDEN

Introduction

In this page you can find the example usage for android.content.pm ApplicationInfo PRIVATE_FLAG_HIDDEN.

Prototype

int PRIVATE_FLAG_HIDDEN

To view the source code for android.content.pm ApplicationInfo PRIVATE_FLAG_HIDDEN.

Click Source Link

Document

Value for #privateFlags : true if the application is hidden via restrictions and for most purposes is considered as not installed.

Usage

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:android.content.pm.PackageParser.java

private static void updateApplicationInfo(ApplicationInfo ai, int flags, PackageUserState state) {
    // CompatibilityMode is global state.
    if (!sCompatibilityModeEnabled) {
        ai.disableCompatibilityMode();//w w  w.j  ava2 s  .  c o  m
    }
    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;
}