Merge "Unregister ImeInsetsSourceConsumer when focus lost" into qt-dev
diff --git a/core/java/android/view/ImeInsetsSourceConsumer.java b/core/java/android/view/ImeInsetsSourceConsumer.java
index 1c811cb..83abf1a 100644
--- a/core/java/android/view/ImeInsetsSourceConsumer.java
+++ b/core/java/android/view/ImeInsetsSourceConsumer.java
@@ -85,6 +85,7 @@
@Override
public void onWindowFocusLost() {
mHasWindowFocus = false;
+ getImm().unregisterImeConsumer(this);
}
/**
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 2cfd622..6eabb37 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -1951,6 +1951,23 @@
}
/**
+ * Unregister for IME state callbacks and applying visibility in
+ * {@link android.view.ImeInsetsSourceConsumer}.
+ * @hide
+ */
+ public void unregisterImeConsumer(@NonNull ImeInsetsSourceConsumer imeInsetsConsumer) {
+ if (imeInsetsConsumer == null) {
+ throw new IllegalStateException("ImeInsetsSourceConsumer cannot be null.");
+ }
+
+ synchronized (mH) {
+ if (mImeInsetsConsumer == imeInsetsConsumer) {
+ mImeInsetsConsumer = null;
+ }
+ }
+ }
+
+ /**
* Call showSoftInput with currently focused view.
* @return {@code true} if IME can be shown.
* @hide