summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/ImeFocusController.java12
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java24
2 files changed, 18 insertions, 18 deletions
diff --git a/core/java/android/view/ImeFocusController.java b/core/java/android/view/ImeFocusController.java
index 4e162f58b69e..fc8885ba00ca 100644
--- a/core/java/android/view/ImeFocusController.java
+++ b/core/java/android/view/ImeFocusController.java
@@ -82,12 +82,10 @@ public final class ImeFocusController {
@UiThread
void onPreWindowFocus(boolean hasWindowFocus, WindowManager.LayoutParams windowAttribute) {
- if (!mHasImeFocus || isInLocalFocusMode(windowAttribute)) {
+ if (!hasWindowFocus || !mHasImeFocus || isInLocalFocusMode(windowAttribute)) {
return;
}
- if (hasWindowFocus) {
- getImmDelegate().setCurrentRootView(mViewRootImpl);
- }
+ getImmDelegate().onPreWindowGainedFocus(mViewRootImpl);
}
@UiThread
@@ -113,7 +111,7 @@ public final class ImeFocusController {
windowAttribute.softInputMode));
}
- getImmDelegate().onPostWindowFocus(viewForWindowFocus, windowAttribute);
+ getImmDelegate().onPostWindowGainedFocus(viewForWindowFocus, windowAttribute);
}
/**
@@ -187,7 +185,8 @@ public final class ImeFocusController {
* @hide
*/
public interface InputMethodManagerDelegate {
- void onPostWindowFocus(View viewForWindowFocus,
+ void onPreWindowGainedFocus(ViewRootImpl viewRootImpl);
+ void onPostWindowGainedFocus(View viewForWindowFocus,
@NonNull WindowManager.LayoutParams windowAttribute);
void onViewFocusChanged(@NonNull View view, boolean hasFocus);
boolean checkFocus(boolean forceNewFocus, boolean startInput, ViewRootImpl viewRootImpl);
@@ -195,7 +194,6 @@ public final class ImeFocusController {
void onWindowDismissed(ViewRootImpl viewRootImpl);
void finishInputAndReportToIme();
- void setCurrentRootView(ViewRootImpl rootView);
boolean isCurrentRootView(ViewRootImpl rootView);
}
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 84e711c6a27c..74ed348d663f 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -759,7 +759,14 @@ public final class InputMethodManager {
}
@Override
- public void onPostWindowFocus(View viewForWindowFocus,
+ public void onPreWindowGainedFocus(ViewRootImpl viewRootImpl) {
+ synchronized (mH) {
+ setCurrentRootViewLocked(viewRootImpl);
+ }
+ }
+
+ @Override
+ public void onPostWindowGainedFocus(View viewForWindowFocus,
@NonNull WindowManager.LayoutParams windowAttribute) {
boolean forceFocus = false;
synchronized (mH) {
@@ -932,19 +939,14 @@ public final class InputMethodManager {
if (mServedView != null) {
finishInputLocked();
}
- setCurrentRootView(null);
+ setCurrentRootViewLocked(null);
}
}
- /**
- * Used for {@link ImeFocusController} to set the current focused root view.
- */
- @Override
- public void setCurrentRootView(ViewRootImpl rootView) {
- synchronized (mH) {
- mImeDispatcher.switchRootView(mCurRootView, rootView);
- mCurRootView = rootView;
- }
+ @GuardedBy("mH")
+ private void setCurrentRootViewLocked(ViewRootImpl rootView) {
+ mImeDispatcher.switchRootView(mCurRootView, rootView);
+ mCurRootView = rootView;
}
/**