FileDocCategorySizeDatePackage
PackageSettingBase.javaAPI DocAndroid 5.1 API14802Thu Mar 12 22:22:42 GMT 2015com.android.server.pm

PackageSettingBase

public class PackageSettingBase extends GrantedPermissions
Settings base class for pending and resolved classes.

Fields Summary
static final int
PKG_INSTALL_COMPLETE
Indicates the state of installation. Used by PackageManager to figure out incomplete installations. Say a package is being installed (the state is set to PKG_INSTALL_INCOMPLETE) and remains so till the package installation is successful or unsuccessful in which case the PackageManager will no longer maintain state information associated with the package. If some exception(like device freeze or battery being pulled out) occurs during installation of a package, the PackageManager needs this information to clean up the previously failed installation.
static final int
PKG_INSTALL_INCOMPLETE
final String
name
final String
realName
File
codePath
Path where this package was found on disk. For monolithic packages this is path to single base APK file; for cluster packages this is path to the cluster directory.
String
codePathString
File
resourcePath
String
resourcePathString
String
legacyNativeLibraryPathString
The path under which native libraries have been unpacked. This path is always derived at runtime, and is only stored here for cleanup when a package is uninstalled.
String
primaryCpuAbiString
The primary CPU abi for this package. This value is regenerated at every boot scan.
String
secondaryCpuAbiString
The secondary CPU abi for this package. This value is regenerated at every boot scan.
String
cpuAbiOverrideString
The install time CPU override, if any. This value is written at install time and doesn't change during the life of an install. If non-null, {@code primaryCpuAbiString} will contain the same value.
long
timeStamp
long
firstInstallTime
long
lastUpdateTime
int
versionCode
boolean
uidError
PackageSignatures
signatures
boolean
permissionsFixed
boolean
haveGids
PackageKeySetData
keySetData
private static final android.content.pm.PackageUserState
DEFAULT_USER_STATE
private final android.util.SparseArray
userState
int
installStatus
PackageSettingBase
origPackage
String
installerPackageName
Constructors Summary
PackageSettingBase(String name, String realName, File codePath, File resourcePath, String legacyNativeLibraryPathString, String primaryCpuAbiString, String secondaryCpuAbiString, String cpuAbiOverrideString, int pVersionCode, int pkgFlags)

           
               
               
                
        super(pkgFlags);
        this.name = name;
        this.realName = realName;
        init(codePath, resourcePath, legacyNativeLibraryPathString, primaryCpuAbiString,
                secondaryCpuAbiString, cpuAbiOverrideString, pVersionCode);
    
PackageSettingBase(PackageSettingBase base)
New instance of PackageSetting with one-level-deep cloning.

        super(base);

        name = base.name;
        realName = base.realName;
        codePath = base.codePath;
        codePathString = base.codePathString;
        resourcePath = base.resourcePath;
        resourcePathString = base.resourcePathString;
        legacyNativeLibraryPathString = base.legacyNativeLibraryPathString;
        primaryCpuAbiString = base.primaryCpuAbiString;
        secondaryCpuAbiString = base.secondaryCpuAbiString;
        cpuAbiOverrideString = base.cpuAbiOverrideString;
        timeStamp = base.timeStamp;
        firstInstallTime = base.firstInstallTime;
        lastUpdateTime = base.lastUpdateTime;
        versionCode = base.versionCode;

        uidError = base.uidError;

        signatures = new PackageSignatures(base.signatures);

        permissionsFixed = base.permissionsFixed;
        haveGids = base.haveGids;
        userState.clear();
        for (int i=0; i<base.userState.size(); i++) {
            userState.put(base.userState.keyAt(i),
                    new PackageUserState(base.userState.valueAt(i)));
        }
        installStatus = base.installStatus;

        origPackage = base.origPackage;

        installerPackageName = base.installerPackageName;

        keySetData = new PackageKeySetData(base.keySetData);

    
Methods Summary
voidaddDisabledComponent(java.lang.String componentClassName, int userId)

        modifyUserStateComponents(userId, true, false).disabledComponents.add(componentClassName);
    
voidaddEnabledComponent(java.lang.String componentClassName, int userId)

        modifyUserStateComponents(userId, false, true).enabledComponents.add(componentClassName);
    
public voidcopyFrom(com.android.server.pm.PackageSettingBase base)
Make a shallow copy of this package settings.

        grantedPermissions = base.grantedPermissions;
        gids = base.gids;

        primaryCpuAbiString = base.primaryCpuAbiString;
        secondaryCpuAbiString = base.secondaryCpuAbiString;
        cpuAbiOverrideString = base.cpuAbiOverrideString;
        timeStamp = base.timeStamp;
        firstInstallTime = base.firstInstallTime;
        lastUpdateTime = base.lastUpdateTime;
        signatures = base.signatures;
        permissionsFixed = base.permissionsFixed;
        haveGids = base.haveGids;
        userState.clear();
        for (int i=0; i<base.userState.size(); i++) {
            userState.put(base.userState.keyAt(i), base.userState.valueAt(i));
        }
        installStatus = base.installStatus;
        keySetData = base.keySetData;
    
booleandisableComponentLPw(java.lang.String componentClassName, int userId)

        PackageUserState state = modifyUserStateComponents(userId, true, false);
        boolean changed = state.enabledComponents != null
                ? state.enabledComponents.remove(componentClassName) : false;
        changed |= state.disabledComponents.add(componentClassName);
        return changed;
    
booleanenableComponentLPw(java.lang.String componentClassName, int userId)

        PackageUserState state = modifyUserStateComponents(userId, false, true);
        boolean changed = state.disabledComponents != null
                ? state.disabledComponents.remove(componentClassName) : false;
        changed |= state.enabledComponents.add(componentClassName);
        return changed;
    
booleangetBlockUninstall(int userId)

        return readUserState(userId).blockUninstall;
    
intgetCurrentEnabledStateLPr(java.lang.String componentName, int userId)

        PackageUserState state = readUserState(userId);
        if (state.enabledComponents != null && state.enabledComponents.contains(componentName)) {
            return COMPONENT_ENABLED_STATE_ENABLED;
        } else if (state.disabledComponents != null
                && state.disabledComponents.contains(componentName)) {
            return COMPONENT_ENABLED_STATE_DISABLED;
        } else {
            return COMPONENT_ENABLED_STATE_DEFAULT;
        }
    
android.util.ArraySetgetDisabledComponents(int userId)

        return readUserState(userId).disabledComponents;
    
intgetEnabled(int userId)

        return readUserState(userId).enabled;
    
android.util.ArraySetgetEnabledComponents(int userId)

        return readUserState(userId).enabledComponents;
    
booleangetHidden(int userId)

        return readUserState(userId).hidden;
    
public intgetInstallStatus()

        return installStatus;
    
booleangetInstalled(int userId)

        return readUserState(userId).installed;
    
java.lang.StringgetInstallerPackageName()

        return installerPackageName;
    
java.lang.StringgetLastDisabledAppCaller(int userId)

        return readUserState(userId).lastDisableAppCaller;
    
booleangetNotLaunched(int userId)

        return readUserState(userId).notLaunched;
    
booleangetStopped(int userId)

        return readUserState(userId).stopped;
    
voidinit(java.io.File codePath, java.io.File resourcePath, java.lang.String legacyNativeLibraryPathString, java.lang.String primaryCpuAbiString, java.lang.String secondaryCpuAbiString, java.lang.String cpuAbiOverrideString, int pVersionCode)

        this.codePath = codePath;
        this.codePathString = codePath.toString();
        this.resourcePath = resourcePath;
        this.resourcePathString = resourcePath.toString();
        this.legacyNativeLibraryPathString = legacyNativeLibraryPathString;
        this.primaryCpuAbiString = primaryCpuAbiString;
        this.secondaryCpuAbiString = secondaryCpuAbiString;
        this.cpuAbiOverrideString = cpuAbiOverrideString;
        this.versionCode = pVersionCode;
    
booleanisAnyInstalled(int[] users)

        for (int user: users) {
            if (readUserState(user).installed) {
                return true;
            }
        }
        return false;
    
private android.content.pm.PackageUserStatemodifyUserState(int userId)

        PackageUserState state = userState.get(userId);
        if (state == null) {
            state = new PackageUserState();
            userState.put(userId, state);
        }
        return state;
    
android.content.pm.PackageUserStatemodifyUserStateComponents(int userId, boolean disabled, boolean enabled)

        PackageUserState state = modifyUserState(userId);
        if (disabled && state.disabledComponents == null) {
            state.disabledComponents = new ArraySet<String>(1);
        }
        if (enabled && state.enabledComponents == null) {
            state.enabledComponents = new ArraySet<String>(1);
        }
        return state;
    
int[]queryInstalledUsers(int[] users, boolean installed)

        int num = 0;
        for (int user : users) {
            if (getInstalled(user) == installed) {
                num++;
            }
        }
        int[] res = new int[num];
        num = 0;
        for (int user : users) {
            if (getInstalled(user) == installed) {
                res[num] = user;
                num++;
            }
        }
        return res;
    
public android.content.pm.PackageUserStatereadUserState(int userId)

        PackageUserState state = userState.get(userId);
        if (state != null) {
            return state;
        }
        return DEFAULT_USER_STATE;
    
voidremoveUser(int userId)

        userState.delete(userId);
    
booleanrestoreComponentLPw(java.lang.String componentClassName, int userId)

        PackageUserState state = modifyUserStateComponents(userId, true, true);
        boolean changed = state.disabledComponents != null
                ? state.disabledComponents.remove(componentClassName) : false;
        changed |= state.enabledComponents != null
                ? state.enabledComponents.remove(componentClassName) : false;
        return changed;
    
voidsetBlockUninstall(boolean blockUninstall, int userId)

        modifyUserState(userId).blockUninstall = blockUninstall;
    
voidsetDisabledComponents(android.util.ArraySet components, int userId)

        modifyUserState(userId).disabledComponents = components;
    
voidsetDisabledComponentsCopy(android.util.ArraySet components, int userId)

        modifyUserState(userId).disabledComponents = components != null
                ? new ArraySet<String>(components) : null;
    
voidsetEnabled(int state, int userId, java.lang.String callingPackage)

        PackageUserState st = modifyUserState(userId);
        st.enabled = state;
        st.lastDisableAppCaller = callingPackage;
    
voidsetEnabledComponents(android.util.ArraySet components, int userId)

        modifyUserState(userId).enabledComponents = components;
    
voidsetEnabledComponentsCopy(android.util.ArraySet components, int userId)

        modifyUserState(userId).enabledComponents = components != null
                ? new ArraySet<String>(components) : null;
    
voidsetHidden(boolean hidden, int userId)

        modifyUserState(userId).hidden = hidden;
    
public voidsetInstallStatus(int newStatus)

        installStatus = newStatus;
    
voidsetInstalled(boolean inst, int userId)

        modifyUserState(userId).installed = inst;
    
public voidsetInstallerPackageName(java.lang.String packageName)

        installerPackageName = packageName;
    
voidsetNotLaunched(boolean stop, int userId)

        modifyUserState(userId).notLaunched = stop;
    
voidsetStopped(boolean stop, int userId)

        modifyUserState(userId).stopped = stop;
    
public voidsetTimeStamp(long newStamp)

        timeStamp = newStamp;
    
voidsetUserState(int userId, int enabled, boolean installed, boolean stopped, boolean notLaunched, boolean hidden, java.lang.String lastDisableAppCaller, android.util.ArraySet enabledComponents, android.util.ArraySet disabledComponents, boolean blockUninstall)

        PackageUserState state = modifyUserState(userId);
        state.enabled = enabled;
        state.installed = installed;
        state.stopped = stopped;
        state.notLaunched = notLaunched;
        state.hidden = hidden;
        state.lastDisableAppCaller = lastDisableAppCaller;
        state.enabledComponents = enabledComponents;
        state.disabledComponents = disabledComponents;
        state.blockUninstall = blockUninstall;