Example usage for android.content.pm PackageManager COMPONENT_ENABLED_STATE_DEFAULT

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

Introduction

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

Prototype

int COMPONENT_ENABLED_STATE_DEFAULT

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

Click Source Link

Document

Flag for #setApplicationEnabledSetting(String,int,int) and #setComponentEnabledSetting(ComponentName,int,int) : This component or application is in its default enabled state (as specified in its manifest).

Usage

From source file:com.newsrob.EntryManager.java

public void maintainBootReceiverState() {
    final ComponentName cName = new ComponentName(ctx, BootReceiver.class);
    final PackageManager pm = ctx.getPackageManager();

    final int newComponentState = isAutoSyncEnabled() ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
            : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;

    if (pm.getComponentEnabledSetting(cName) != newComponentState) {
        Log.d(TAG, "Setting new component enabled state on BootReceiver: " + isAutoSyncEnabled());
        pm.setComponentEnabledSetting(cName, newComponentState, PackageManager.DONT_KILL_APP);
    }/*from   w w w . ja  v  a 2  s.  co m*/
    PL.log("EntryManager.maintainBootReceiverState(): Component enabled="
            + pm.getComponentEnabledSetting(cName), ctx);

}

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;
    }/*from www  .j a  v  a  2s .c  om*/
    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;
}