FileDocCategorySizeDatePackage
UpdateLockService.javaAPI DocAndroid 5.1 API4215Thu Mar 12 22:22:42 GMT 2015com.android.server

UpdateLockService

public class UpdateLockService extends IUpdateLock.Stub

Fields Summary
static final boolean
DEBUG
static final String
TAG
static final String
PERMISSION
android.content.Context
mContext
LockWatcher
mLocks
Constructors Summary
UpdateLockService(android.content.Context context)

        mContext = context;
        mLocks = new LockWatcher(new Handler(), "UpdateLocks");

        // Consider just-booting to be a reasonable time to allow
        // interruptions for update installation etc.
        sendLockChangedBroadcast(true);
    
Methods Summary
public voidacquireUpdateLock(android.os.IBinder token, java.lang.String tag)

        if (DEBUG) {
            Slog.d(TAG, "acquire(" + token + ") by " + makeTag(tag));
        }

        mContext.enforceCallingOrSelfPermission(PERMISSION, "acquireUpdateLock");
        mLocks.acquire(token, makeTag(tag));
    
public voiddump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)

        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                != PackageManager.PERMISSION_GRANTED) {
            pw.println("Permission Denial: can't dump update lock service from from pid="
                    + Binder.getCallingPid()
                    + ", uid=" + Binder.getCallingUid());
            return;
        }

        mLocks.dump(pw);
    
private java.lang.StringmakeTag(java.lang.String tag)

        return "{tag=" + tag
                + " uid=" + Binder.getCallingUid()
                + " pid=" + Binder.getCallingPid() + '}";
    
public voidreleaseUpdateLock(android.os.IBinder token)

        if (DEBUG) {
            Slog.d(TAG, "release(" + token + ')");
        }

        mContext.enforceCallingOrSelfPermission(PERMISSION, "releaseUpdateLock");
        mLocks.release(token);
    
voidsendLockChangedBroadcast(boolean state)

        // Safe early during boot because this broadcast only goes to registered receivers.
        long oldIdent = Binder.clearCallingIdentity();
        try {
            Intent intent = new Intent(UpdateLock.UPDATE_LOCK_CHANGED)
                    .putExtra(UpdateLock.NOW_IS_CONVENIENT, state)
                    .putExtra(UpdateLock.TIMESTAMP, System.currentTimeMillis())
                    .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
            mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
        } finally {
            Binder.restoreCallingIdentity(oldIdent);
        }