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

Commit 6924863b authored by Ming-Shin Lu's avatar Ming-Shin Lu
Browse files

Remove ImeFocusController#set{Served, NextServed}View

As ImeFocusController#set{Served, NextServed}View originally exposes to
InputMethodManager is only for clearing the served view in
IMM#finishInputLocked() with a special code logic:

```
  setNextServedView(null);
  if (getServedView() != null) {
      // do finish input
     setServedView(null);
  }
```

which isn't necessary and can be clean-up with a method to notify
ImeFocusController to clear the served / next served view, then doing
the rest of finshing logic when the method has cleared the served view:

```
if (controller.clearServedViewsLocked() != null) {
    // do finish input
}
```

With this change, we can simply remove the set{Served, NextServed}View
to get rid of this dependency with InputMethodManager.

Bug: 244504062
Test: atest CtsInputMethodTestCases

Change-Id: Ibcde35765c0e2e6c372aa64dbc7e774a8d860543
parent 31e46784
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -328,14 +328,23 @@ public final class ImeFocusController {
        return mNextServedView;
    }

    // TODO(b/244504062): Remove this method dependency from InputMethodManager.
    public void setServedViewLocked(View view) {
        mServedView = view;
    /**
     * Clears the served & the next served view when the controller triggers
     * {@link InputMethodManagerDelegate#finishInput()} or
     * {@link InputMethodManagerDelegate#finishInputAndReportToIme()}.
     * Note that this method requires to be called inside {@code InputMethodManager#mH} lock for
     * data consistency.
     *
     * @return The {@code mServedView} that has cleared, or {@code null} means nothing to clear.
     */
    public View clearServedViewsLocked() {
        View clearedView = null;
        mNextServedView = null;
        if (mServedView != null) {
            clearedView = mServedView;
            mServedView = null;
        }

    // TODO(b/244504062): Remove this method dependency from InputMethodManager.
    public void setNextServedViewLocked(View view) {
        mNextServedView = view;
        return clearedView;
    }

    /**
+4 −18
Original line number Diff line number Diff line
@@ -933,20 +933,6 @@ public final class InputMethodManager {
                : null;
    }

    @GuardedBy("mH")
    private void setServedViewLocked(View view) {
        if (mCurRootView != null) {
            mCurRootView.getImeFocusController().setServedViewLocked(view);
        }
    }

    @GuardedBy("mH")
    private void setNextServedViewLocked(View view) {
        if (mCurRootView != null) {
            mCurRootView.getImeFocusController().setNextServedViewLocked(view);
        }
    }

    private ImeFocusController getFocusController() {
        synchronized (mH) {
            if (mCurRootView != null) {
@@ -1793,13 +1779,13 @@ public final class InputMethodManager {
    @GuardedBy("mH")
    void finishInputLocked() {
        mVirtualDisplayToScreenMatrix = null;
        setNextServedViewLocked(null);
        if (getServedViewLocked() != null) {
        final ImeFocusController controller = getFocusController();
        final View clearedView = controller != null ? controller.clearServedViewsLocked() : null;
        if (clearedView != null) {
            if (DEBUG) {
                Log.v(TAG, "FINISH INPUT: mServedView="
                        + InputMethodDebug.dumpViewInfo(getServedViewLocked()));
                        + InputMethodDebug.dumpViewInfo(clearedView));
            }
            setServedViewLocked(null);
            mCompletions = null;
            mServedConnecting = false;
            clearConnectionLocked();