Example usage for android.content.pm PackageManager COMPONENT_ENABLED_STATE_ENABLED

List of usage examples for android.content.pm PackageManager COMPONENT_ENABLED_STATE_ENABLED

Introduction

In this page you can find the example usage for android.content.pm PackageManager COMPONENT_ENABLED_STATE_ENABLED.

Prototype

int COMPONENT_ENABLED_STATE_ENABLED

To view the source code for android.content.pm PackageManager COMPONENT_ENABLED_STATE_ENABLED.

Click Source Link

Document

Flag for #setApplicationEnabledSetting(String,int,int) and #setComponentEnabledSetting(ComponentName,int,int) : This component or application has been explictily enabled, regardless of what it has specified in its manifest.

Usage

From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java

private void startKioskMode(String[] lockTaskArray) {
    // start locked activity
    Intent launchIntent = new Intent(getActivity(), KioskModeActivity.class);
    launchIntent.putExtra(KioskModeActivity.LOCKED_APP_PACKAGE_LIST, lockTaskArray);
    launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mPackageManager.setComponentEnabledSetting(
            new ComponentName(mPackageName, KioskModeActivity.class.getName()),
            PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
    startActivity(launchIntent);//from   ww  w . j  a  v  a 2 s.  c om
    getActivity().finish();
}

From source file:android.content.pm.PackageParser.java

private static boolean copyNeeded(int flags, Package p, PackageUserState state, Bundle metaData, int userId) {
    if (userId != UserHandle.USER_OWNER) {
        // We always need to copy for other users, since we need
        // to fix up the uid.
        return true;
    }//  www .j  ava2 s  .com
    if (state.enabled != PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) {
        boolean enabled = state.enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
        if (p.applicationInfo.enabled != enabled) {
            return true;
        }
    }
    if (!state.installed || state.hidden) {
        return true;
    }
    if (state.stopped) {
        return true;
    }
    if ((flags & PackageManager.GET_META_DATA) != 0 && (metaData != null || p.mAppMetaData != null)) {
        return true;
    }
    if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0 && p.usesLibraryFiles != null) {
        return true;
    }
    return false;
}

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 w w  w.j  a  va  2  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;
}