Skip to content

Commit 4478de3

Browse files
committed
Clear IMM references when window dismissed.
Match behavior of removeViewLocked(), where InputMethodManager clears any strong references to Views, and also clear mCurRootView. Without this, IMM can leak a DecorView instance after the user has left the application. Bug: 6413553 Change-Id: Iad09cf5dbb7f6f156fd39ed243431432e00f8945
1 parent f5d70fd commit 4478de3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

core/java/android/view/WindowManagerImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ public void removeViewImmediate(View view) {
340340
View curView = root.getView();
341341

342342
root.mAddNesting = 0;
343+
344+
if (view != null) {
345+
InputMethodManager imm = InputMethodManager.getInstance(view.getContext());
346+
if (imm != null) {
347+
imm.windowDismissed(mViews[index].getWindowToken());
348+
}
349+
}
350+
343351
root.die(true);
344352
finishRemoveViewLocked(curView, index);
345353
if (curView == view) {

core/java/android/view/inputmethod/InputMethodManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ void clearConnectionLocked() {
672672
* Disconnect any existing input connection, clearing the served view.
673673
*/
674674
void finishInputLocked() {
675+
mCurRootView = null;
675676
mNextServedView = null;
676677
if (mServedView != null) {
677678
if (DEBUG) Log.v(TAG, "FINISH INPUT: " + mServedView);

0 commit comments

Comments
 (0)