Example usage for android.content.pm ApplicationInfo ApplicationInfo

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

Introduction

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

Prototype

@SuppressWarnings("unchecked")
    private ApplicationInfo(Parcel source) 

Source Link

Usage

From source file:com.nachiket.titan.LibraryActivity.java

@Override
public ApplicationInfo getApplicationInfo() {
    ApplicationInfo info;/*from w  w  w .ja  v  a 2s . co  m*/
    if (mFakeTarget) {
        info = mFakeInfo;
        if (info == null) {
            info = new ApplicationInfo(super.getApplicationInfo());
            info.targetSdkVersion = Build.VERSION_CODES.GINGERBREAD;
            mFakeInfo = info;
        }
    } else {
        info = super.getApplicationInfo();
    }
    return info;
}

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 .  j  a v  a2  s . co  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  w w.  ja  va  2s .c  o  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;
}