UpdateLockServicepublic 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 void | acquireUpdateLock(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 void | dump(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.String | makeTag(java.lang.String tag)
return "{tag=" + tag
+ " uid=" + Binder.getCallingUid()
+ " pid=" + Binder.getCallingPid() + '}";
| public void | releaseUpdateLock(android.os.IBinder token)
if (DEBUG) {
Slog.d(TAG, "release(" + token + ')");
}
mContext.enforceCallingOrSelfPermission(PERMISSION, "releaseUpdateLock");
mLocks.release(token);
| void | sendLockChangedBroadcast(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);
}
|
|