Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a36dc621 authored by Andreas Gampe's avatar Andreas Gampe
Browse files

Frameworks: Annotate trivial @GuardedBy in services/core

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: I6993325b11c71a4ec27c21935fb54a954d95455f
parent 3f24e69d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4061,6 +4061,7 @@ class AlarmManagerService extends SystemService {
        /**
         * Deliver an alarm and set up the post-delivery handling appropriately
         */
        @GuardedBy("mLock")
        public void deliverLocked(Alarm alarm, long nowELAPSED, boolean allowWhileIdle) {
            if (alarm.operation != null) {
                // PendingIntent alarm
+5 −0
Original line number Diff line number Diff line
@@ -497,6 +497,7 @@ public class ForceAppStandbyTracker {
    /**
     * Update {@link #mRunAnyRestrictedPackages} with the current app ops state.
     */
    @GuardedBy("mLock")
    private void refreshForcedAppStandbyUidPackagesLocked() {
        mRunAnyRestrictedPackages.clear();
        final List<PackageOps> ops = mAppOpsManager.getPackagesForOps(
@@ -536,6 +537,7 @@ public class ForceAppStandbyTracker {
    /**
     * Update {@link #mForceAllAppsStandby} and notifies the listeners.
     */
    @GuardedBy("mLock")
    private void toggleForceAllAppsStandbyLocked(boolean enable) {
        if (enable == mForceAllAppsStandby) {
            return;
@@ -545,6 +547,7 @@ public class ForceAppStandbyTracker {
        mHandler.notifyForceAllAppsStandbyChanged();
    }

    @GuardedBy("mLock")
    private int findForcedAppStandbyUidPackageIndexLocked(int uid, @NonNull String packageName) {
        final int size = mRunAnyRestrictedPackages.size();
        if (size > 8) {
@@ -563,6 +566,7 @@ public class ForceAppStandbyTracker {
    /**
     * @return whether a uid package-name pair is in mRunAnyRestrictedPackages.
     */
    @GuardedBy("mLock")
    boolean isRunAnyRestrictedLocked(int uid, @NonNull String packageName) {
        return findForcedAppStandbyUidPackageIndexLocked(uid, packageName) >= 0;
    }
@@ -570,6 +574,7 @@ public class ForceAppStandbyTracker {
    /**
     * Add to / remove from {@link #mRunAnyRestrictedPackages}.
     */
    @GuardedBy("mLock")
    boolean updateForcedAppStandbyUidPackageLocked(int uid, @NonNull String packageName,
            boolean restricted) {
        final int index = findForcedAppStandbyUidPackageIndexLocked(uid, packageName);
+6 −0
Original line number Diff line number Diff line
@@ -1166,6 +1166,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            mImePackageAppeared = false;
        }

        @GuardedBy("mMethodMap")
        private boolean shouldRebuildInputMethodListLocked() {
            // This method is guaranteed to be called only by getRegisteredHandler().

@@ -1467,6 +1468,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        setSelectedInputMethodAndSubtypeLocked(defIm, NOT_A_SUBTYPE_ID, false);
    }

    @GuardedBy("mMethodMap")
    private void switchUserLocked(int newUserId) {
        if (DEBUG) Slog.d(TAG, "Switching user stage 1/3. newUserId=" + newUserId
                + " currentUserId=" + mSettings.getCurrentUserId());
@@ -1817,6 +1819,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        return flags;
    }

    @GuardedBy("mMethodMap")
    @NonNull
    InputBindResult attachNewInputLocked(
            /* @InputMethodClient.StartInputReason */ final int startInputReason, boolean initial) {
@@ -1846,6 +1849,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                mCurId, mCurSeq, mCurUserActionNotificationSequenceNumber);
    }

    @GuardedBy("mMethodMap")
    @NonNull
    InputBindResult startInputLocked(
            /* @InputMethodClient.StartInputReason */ final int startInputReason,
@@ -1889,6 +1893,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                controlFlags, startInputReason);
    }

    @GuardedBy("mMethodMap")
    @NonNull
    InputBindResult startInputUncheckedLocked(@NonNull ClientState cs, IInputContext inputContext,
            /* @InputConnectionInspector.missingMethods */ final int missingMethods,
@@ -3642,6 +3647,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        return false;
    }

    @GuardedBy("mMethodMap")
    void buildInputMethodListLocked(boolean resetDefaultEnabledIme) {
        if (DEBUG) {
            Slog.d(TAG, "--- re-buildInputMethodList reset = " + resetDefaultEnabledIme
+3 −0
Original line number Diff line number Diff line
@@ -199,6 +199,7 @@ public class ServiceWatcher implements ServiceConnection {
     *            bound.
     * @returns {@code true} if a valid package was found to bind to.
     */
    @GuardedBy("mLock")
    private boolean bindBestPackageLocked(String justCheckThisPackage, boolean forceRebind) {
        Intent intent = new Intent(mAction);
        if (justCheckThisPackage != null) {
@@ -273,6 +274,7 @@ public class ServiceWatcher implements ServiceConnection {
        return true;
    }

    @GuardedBy("mLock")
    private void unbindLocked() {
        ComponentName component;
        component = mBoundComponent;
@@ -287,6 +289,7 @@ public class ServiceWatcher implements ServiceConnection {
        }
    }

    @GuardedBy("mLock")
    private void bindToPackageLocked(ComponentName component, int version, int userId) {
        Intent intent = new Intent(mAction);
        intent.setComponent(component);
+7 −0
Original line number Diff line number Diff line
@@ -809,6 +809,7 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    @GuardedBy("mLock")
    private void addInternalVolumeLocked() {
        // Create a stub volume that represents internal storage
        final VolumeInfo internal = new VolumeInfo(VolumeInfo.ID_PRIVATE_INTERNAL,
@@ -1109,6 +1110,7 @@ class StorageManagerService extends IStorageManager.Stub
        }
    };

    @GuardedBy("mLock")
    private void onDiskScannedLocked(DiskInfo disk) {
        int volumeCount = 0;
        for (int i = 0; i < mVolumes.size(); i++) {
@@ -1134,6 +1136,7 @@ class StorageManagerService extends IStorageManager.Stub
        mCallbacks.notifyDiskScanned(disk, volumeCount);
    }

    @GuardedBy("mLock")
    private void onVolumeCreatedLocked(VolumeInfo vol) {
        if (mPms.isOnlyCoreApps()) {
            Slog.d(TAG, "System booted in core-only mode; ignoring volume " + vol.getId());
@@ -1209,6 +1212,7 @@ class StorageManagerService extends IStorageManager.Stub
        return true;
    }

    @GuardedBy("mLock")
    private void onVolumeStateChangedLocked(VolumeInfo vol, int oldState, int newState) {
        // Remember that we saw this volume so we're ready to accept user
        // metadata, or so we can annoy them when a private volume is ejected
@@ -1299,6 +1303,7 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    @GuardedBy("mLock")
    private void onMoveStatusLocked(int status) {
        if (mMoveCallback == null) {
            Slog.w(TAG, "Odd, status but no move requested");
@@ -1515,6 +1520,7 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    @GuardedBy("mLock")
    private void readSettingsLocked() {
        mRecords.clear();
        mPrimaryStorageUuid = getDefaultPrimaryStorageUuid();
@@ -1559,6 +1565,7 @@ class StorageManagerService extends IStorageManager.Stub
        }
    }

    @GuardedBy("mLock")
    private void writeSettingsLocked() {
        FileOutputStream fos = null;
        try {
Loading