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

PackageVerificationState

public class PackageVerificationState extends Object
Tracks the package verification state for a particular package. Each package verification has a required verifier and zero or more sufficient verifiers. Only one of the sufficient verifier list must return affirmative to allow the package to be considered verified. If there are zero sufficient verifiers, then package verification is considered complete.

Fields Summary
private final com.android.server.pm.PackageManagerService.InstallArgs
mArgs
private final android.util.SparseBooleanArray
mSufficientVerifierUids
private final int
mRequiredVerifierUid
private boolean
mSufficientVerificationComplete
private boolean
mSufficientVerificationPassed
private boolean
mRequiredVerificationComplete
private boolean
mRequiredVerificationPassed
private boolean
mExtendedTimeout
Constructors Summary
public PackageVerificationState(int requiredVerifierUid, com.android.server.pm.PackageManagerService.InstallArgs args)
Create a new package verification state where {@code requiredVerifierUid} is the user ID for the package that must reply affirmative before things can continue.

param
requiredVerifierUid user ID of required package verifier
param
args

        mRequiredVerifierUid = requiredVerifierUid;
        mArgs = args;
        mSufficientVerifierUids = new SparseBooleanArray();
        mExtendedTimeout = false;
    
Methods Summary
public voidaddSufficientVerifier(int uid)
Add a verifier which is added to our sufficient list.

param
uid user ID of sufficient verifier

        mSufficientVerifierUids.put(uid, true);
    
public voidextendTimeout()
Extend the timeout for this Package to be verified.

        if (!mExtendedTimeout) {
            mExtendedTimeout = true;
        }
    
public com.android.server.pm.PackageManagerService.InstallArgsgetInstallArgs()

        return mArgs;
    
public booleanisInstallAllowed()
Returns whether installation should be allowed. This should only be called after {@link #isVerificationComplete()} returns {@code true}.

return
{@code true} if installation should be allowed

        if (!mRequiredVerificationPassed) {
            return false;
        }

        if (mSufficientVerificationComplete) {
            return mSufficientVerificationPassed;
        }

        return true;
    
public booleanisVerificationComplete()
Returns whether verification is considered complete. This means that the required verifier and at least one of the sufficient verifiers has returned a positive verification.

return
{@code true} when verification is considered complete

        if (!mRequiredVerificationComplete) {
            return false;
        }

        if (mSufficientVerifierUids.size() == 0) {
            return true;
        }

        return mSufficientVerificationComplete;
    
public booleansetVerifierResponse(int uid, int code)
Should be called when a verification is received from an agent so the state of the package verification can be tracked.

param
uid user ID of the verifying agent
return
{@code true} if the verifying agent actually exists in our list

        if (uid == mRequiredVerifierUid) {
            mRequiredVerificationComplete = true;
            switch (code) {
                case PackageManager.VERIFICATION_ALLOW_WITHOUT_SUFFICIENT:
                    mSufficientVerifierUids.clear();
                    // fall through
                case PackageManager.VERIFICATION_ALLOW:
                    mRequiredVerificationPassed = true;
                    break;
                default:
                    mRequiredVerificationPassed = false;
            }
            return true;
        } else {
            if (mSufficientVerifierUids.get(uid)) {
                if (code == PackageManager.VERIFICATION_ALLOW) {
                    mSufficientVerificationComplete = true;
                    mSufficientVerificationPassed = true;
                }

                mSufficientVerifierUids.delete(uid);
                if (mSufficientVerifierUids.size() == 0) {
                    mSufficientVerificationComplete = true;
                }

                return true;
            }
        }

        return false;
    
public booleantimeoutExtended()
Returns whether the timeout was extended for verification.

return
{@code true} if a timeout was already extended.

        return mExtendedTimeout;