Frameworks: Annotate trivial @GuardedBy in services/ misc

Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.

Derived by errorprone.

Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: Id1d9fbe5018250e3b9d1466fc5f670d5ad902fa3
This commit is contained in:
Andreas Gampe
2018-02-07 15:34:27 -08:00
parent b5cc72055f
commit bbab23ff97
10 changed files with 15 additions and 0 deletions

View File

@@ -901,6 +901,7 @@ class MagnificationController implements Handler.Callback {
}
}
@GuardedBy("mLock")
private void setMagnificationSpecLocked(MagnificationSpec spec) {
if (mEnabled) {
if (DEBUG_SET_MAGNIFICATION_SPEC) {

View File

@@ -1931,6 +1931,7 @@ public class BackupManagerService implements BackupManagerServiceInterface {
/**
* Remove a package from the full-data queue.
*/
@GuardedBy("mQueueLock")
private void dequeueFullBackupLocked(String packageName) {
final int N = mFullBackupQueue.size();
for (int i = N - 1; i >= 0; i--) {

View File

@@ -193,6 +193,7 @@ public class DeviceAdminServiceController {
}
}
@GuardedBy("mLock")
private void disconnectServiceOnUserLocked(int userId, @NonNull String actionForLog) {
final DevicePolicyServiceConnection conn = mConnections.get(userId);
if (conn != null) {

View File

@@ -10221,6 +10221,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
mInjector.registerContentObserver(mDefaultImeChanged, false, this, UserHandle.USER_ALL);
}
@GuardedBy("DevicePolicyManagerService.this")
private void addPendingChangeByOwnerLocked(int userId) {
mUserIdsWithPendingChangesByOwner.add(userId);
}

View File

@@ -1068,6 +1068,7 @@ public class ApfFilter {
mLastInstallEvent.flags = ApfProgramEvent.flagsFor(mIPv4Address != null, mMulticastFilter);
}
@GuardedBy("this")
private void logApfProgramEventLocked(long now) {
if (mLastInstallEvent == null) {
return;

View File

@@ -268,6 +268,7 @@ public class RouterAdvertisementDaemon {
mUnicastResponder = null;
}
@GuardedBy("mLock")
private void assembleRaLocked() {
final ByteBuffer ra = ByteBuffer.wrap(mRA);
ra.order(ByteOrder.BIG_ENDIAN);

View File

@@ -596,6 +596,7 @@ final class RemotePrintSpooler {
}
}
@GuardedBy("mLock")
private void bindLocked() throws TimeoutException, InterruptedException {
while (mIsBinding) {
mLock.wait();

View File

@@ -539,6 +539,7 @@ public class AppStandbyController {
}
}
@GuardedBy("mAppIdleLock")
@StandbyBuckets int getBucketForLocked(String packageName, int userId,
long elapsedRealtime) {
int bucketIndex = mAppIdleHistory.getThresholdIndex(packageName, userId,

View File

@@ -314,6 +314,7 @@ class UsbProfileGroupSettingsManager {
* Upgrade any single-user settings from {@link #sSingleUserSettingsFile}.
* Should only by called by owner.
*/
@GuardedBy("mLock")
private void upgradeSingleUserLocked() {
if (sSingleUserSettingsFile.exists()) {
mDevicePreferenceMap.clear();
@@ -347,6 +348,7 @@ class UsbProfileGroupSettingsManager {
}
}
@GuardedBy("mLock")
private void readSettingsLocked() {
if (DEBUG) Slog.v(TAG, "readSettingsLocked()");
@@ -386,6 +388,7 @@ class UsbProfileGroupSettingsManager {
* <p>In the uncommon case that the system crashes in between the scheduling and the write the
* update is lost.</p>
*/
@GuardedBy("mLock")
private void scheduleWriteSettingsLocked() {
if (mIsWriteSettingsScheduled) {
return;
@@ -869,6 +872,7 @@ class UsbProfileGroupSettingsManager {
return null;
}
@GuardedBy("mLock")
private boolean clearCompatibleMatchesLocked(@NonNull UserPackage userPackage,
@NonNull DeviceFilter filter) {
ArrayList<DeviceFilter> keysToRemove = new ArrayList<>();
@@ -892,6 +896,7 @@ class UsbProfileGroupSettingsManager {
return !keysToRemove.isEmpty();
}
@GuardedBy("mLock")
private boolean clearCompatibleMatchesLocked(@NonNull UserPackage userPackage,
@NonNull AccessoryFilter filter) {
ArrayList<AccessoryFilter> keysToRemove = new ArrayList<>();
@@ -915,6 +920,7 @@ class UsbProfileGroupSettingsManager {
return !keysToRemove.isEmpty();
}
@GuardedBy("mLock")
private boolean handlePackageAddedLocked(UserPackage userPackage, ActivityInfo aInfo,
String metaDataName) {
XmlResourceParser parser = null;

View File

@@ -236,6 +236,7 @@ public class UsbService extends IUsbManager.Stub {
*
* @return Iff the caller is in the current user's profile group
*/
@GuardedBy("mLock")
private boolean isCallerInCurrentUserProfileGroupLocked() {
int userIdInt = UserHandle.getCallingUserId();