Frameworks: Annotate trivial @GuardedBy in services/core
Add @GuardedBy for simple functions that require locks and have a name in
one of the frameworks naming styles for locks ("^.*(Locked|LPw|LPr|L[a-zA-Z]|UL|AL|NL)$").
Derived by errorprone.
Bug: 73000847
Test: m
Change-Id: Ic48bbb2f95c686fb44b6e3169c67fa52d6df80b4
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 4b8ece9..fd74613 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -1913,6 +1913,7 @@
return startInputInnerLocked();
}
+ @GuardedBy("mMethodMap")
InputBindResult startInputInnerLocked() {
if (mCurMethodId == null) {
return InputBindResult.NO_IME;
@@ -2549,6 +2550,7 @@
}
}
+ @GuardedBy("mMethodMap")
boolean showCurrentInputLocked(int flags, ResultReceiver resultReceiver) {
mShowRequested = true;
if (mAccessibilityRequestingNoSoftKeyboard) {
diff --git a/services/core/java/com/android/server/TextServicesManagerService.java b/services/core/java/com/android/server/TextServicesManagerService.java
index c043e18..40f81b3 100644
--- a/services/core/java/com/android/server/TextServicesManagerService.java
+++ b/services/core/java/com/android/server/TextServicesManagerService.java
@@ -342,6 +342,7 @@
mMonitor.register(context, null, UserHandle.ALL, true);
}
+ @GuardedBy("mLock")
private void initializeInternalStateLocked(@UserIdInt int userId) {
// When DISABLE_PER_PROFILE_SPELL_CHECKER is true, we make sure here that work profile users
// will never have non-null TextServicesData for their user ID.
@@ -756,6 +757,7 @@
* @return {@link TextServicesData} for the given user. {@code null} if spell checker is not
* temporarily / permanently available for the specified user
*/
+ @GuardedBy("mLock")
@Nullable
private TextServicesData getDataFromCallingUserIdLocked(@UserIdInt int callingUserId) {
final int spellCheckerOwnerUserId = mSpellCheckerOwnerUserIdMap.get(callingUserId);
diff --git a/services/core/java/com/android/server/biometrics/face/FaceUserState.java b/services/core/java/com/android/server/biometrics/face/FaceUserState.java
index 7d67c62..e12498e 100644
--- a/services/core/java/com/android/server/biometrics/face/FaceUserState.java
+++ b/services/core/java/com/android/server/biometrics/face/FaceUserState.java
@@ -23,6 +23,7 @@
import android.util.Slog;
import android.util.Xml;
+import com.android.internal.annotations.GuardedBy;
import com.android.server.biometrics.common.BiometricUserState;
import libcore.io.IoUtils;
@@ -133,6 +134,7 @@
}
}
+ @GuardedBy("this")
@Override
protected void parseBiometricsLocked(XmlPullParser parser)
throws IOException, XmlPullParserException {
diff --git a/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java b/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java
index 005212f..d36ab3f 100644
--- a/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java
+++ b/services/core/java/com/android/server/textclassifier/TextClassificationManagerService.java
@@ -249,10 +249,12 @@
}
}
+ @GuardedBy("mLock")
private UserState getCallingUserStateLocked() {
return getUserStateLocked(UserHandle.getCallingUserId());
}
+ @GuardedBy("mLock")
private UserState getUserStateLocked(int userId) {
UserState result = mUserStates.get(userId);
if (result == null) {
@@ -262,6 +264,7 @@
return result;
}
+ @GuardedBy("mLock")
UserState peekUserStateLocked(int userId) {
return mUserStates.get(userId);
}
@@ -389,6 +392,7 @@
}
}
+ @GuardedBy("mLock")
private boolean bindIfHasPendingRequestsLocked() {
return !mPendingRequests.isEmpty() && bindLocked();
}
@@ -397,6 +401,7 @@
* @return true if the service is bound or in the process of being bound.
* Returns false otherwise.
*/
+ @GuardedBy("mLock")
private boolean bindLocked() {
if (isBoundLocked() || mBinding) {
return true;