Example usage for android.content.pm ApplicationInfo FLAG_STOPPED

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

Introduction

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

Prototype

int FLAG_STOPPED

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

Click Source Link

Document

Value for #flags : true if this application's package is in the stopped state.

Usage

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

public static ApplicationInfo generateApplicationInfo(Package p, int flags, PackageUserState state,
        int userId) {
    if (p == null)
        return null;
    if (!checkUseInstalledOrHidden(flags, state)) {
        return null;
    }//from  w  w  w . ja va  2  s . c o  m
    if (!copyNeeded(flags, p, state, null, userId)
            && ((flags & PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS) == 0
                    || state.enabled != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED)) {
        // In this case it is safe to directly modify the internal ApplicationInfo state:
        // - CompatibilityMode is global state, so will be the same for every call.
        // - We only come in to here if the app should reported as installed; this is the
        // default state, and we will do a copy otherwise.
        // - The enable state will always be reported the same for the application across
        // calls; the only exception is for the UNTIL_USED mode, and in that case we will
        // be doing a copy.
        updateApplicationInfo(p.applicationInfo, flags, state);
        return p.applicationInfo;
    }

    // Make shallow copy so we can store the metadata/libraries safely
    ApplicationInfo ai = new ApplicationInfo(p.applicationInfo);
    ai.uid = UserHandle.getUid(userId, ai.uid);
    ai.dataDir = Environment.getDataUserPackageDirectory(ai.volumeUuid, userId, ai.packageName)
            .getAbsolutePath();
    if ((flags & PackageManager.GET_META_DATA) != 0) {
        ai.metaData = p.mAppMetaData;
    }
    if ((flags & PackageManager.GET_SHARED_LIBRARY_FILES) != 0) {
        ai.sharedLibraryFiles = p.usesLibraryFiles;
    }
    if (state.stopped) {
        ai.flags |= ApplicationInfo.FLAG_STOPPED;
    } else {
        ai.flags &= ~ApplicationInfo.FLAG_STOPPED;
    }
    updateApplicationInfo(ai, flags, state);
    return ai;
}

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

public static ApplicationInfo generateApplicationInfo(ApplicationInfo ai, int flags, PackageUserState state,
        int userId) {
    if (ai == null)
        return null;
    if (!checkUseInstalledOrHidden(flags, state)) {
        return null;
    }//from  w ww  .  ja va  2s .co m
    // This is only used to return the ResolverActivity; we will just always
    // make a copy.
    ai = new ApplicationInfo(ai);
    ai.uid = UserHandle.getUid(userId, ai.uid);
    ai.dataDir = Environment.getDataUserPackageDirectory(ai.volumeUuid, userId, ai.packageName)
            .getAbsolutePath();
    if (state.stopped) {
        ai.flags |= ApplicationInfo.FLAG_STOPPED;
    } else {
        ai.flags &= ~ApplicationInfo.FLAG_STOPPED;
    }
    updateApplicationInfo(ai, flags, state);
    return ai;
}