From ee68a1e34cb0151950038cd8a5f5b76397e85907 Mon Sep 17 00:00:00 2001 From: Wilson Wu Date: Tue, 6 Sep 2022 19:48:46 +0800 Subject: [PATCH] Improve lock annotation for InputMethodManager (3/N) Add @GuardedBy("mH") annotation for those Locked methods which should be guarded by mH in InputMethodManager. Bug: b/236937383 Test: presubmit Change-Id: I271f78bc54c7cd406d56775aef0db9d6c4084ee0 --- .../android/view/inputmethod/InputMethodManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index bf5ec3dbfb033..9acd1af952aea 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -896,21 +896,25 @@ public final class InputMethodManager { return mDelegate.hasActiveConnection(view); } + @GuardedBy("mH") private View getServedViewLocked() { return mCurRootView != null ? mCurRootView.getImeFocusController().getServedView() : null; } + @GuardedBy("mH") private View getNextServedViewLocked() { return mCurRootView != null ? mCurRootView.getImeFocusController().getNextServedView() : null; } + @GuardedBy("mH") private void setServedViewLocked(View view) { if (mCurRootView != null) { mCurRootView.getImeFocusController().setServedView(view); } } + @GuardedBy("mH") private void setNextServedViewLocked(View view) { if (mCurRootView != null) { mCurRootView.getImeFocusController().setNextServedView(view); @@ -929,6 +933,7 @@ public final class InputMethodManager { /** * Returns {@code true} when the given view has been served by Input Method. */ + @GuardedBy("mH") private boolean hasServedByInputMethodLocked(View view) { final View servedView = getServedViewLocked(); return (servedView == view @@ -3252,6 +3257,7 @@ public final class InputMethodManager { } } + @GuardedBy("mH") private void flushPendingEventsLocked() { mH.removeMessages(MSG_FLUSH_INPUT_EVENT); @@ -3264,6 +3270,7 @@ public final class InputMethodManager { } } + @GuardedBy("mH") private PendingEvent obtainPendingEventLocked(InputEvent event, Object token, String inputMethodId, FinishedInputEventCallback callback, Handler handler) { PendingEvent p = mPendingEventPool.acquire(); @@ -3278,6 +3285,7 @@ public final class InputMethodManager { return p; } + @GuardedBy("mH") private void recyclePendingEventLocked(PendingEvent p) { p.recycle(); mPendingEventPool.release(p); @@ -3310,6 +3318,7 @@ public final class InputMethodManager { mServiceInvoker.showInputMethodPickerFromSystem(mClient, mode, displayId); } + @GuardedBy("mH") private void showInputMethodPickerLocked() { mServiceInvoker.showInputMethodPickerFromClient(mClient, SHOW_IM_PICKER_MODE_AUTO); } @@ -3844,6 +3853,7 @@ public final class InputMethodManager { } } + @GuardedBy("mH") private void forAccessibilitySessionsLocked( Consumer consumer) { for (int i = 0; i < mAccessibilityInputMethodSession.size(); i++) {