Skip to content

Commit

Permalink
Clear InputMethodManager.sInstance for SDK > P
Browse files Browse the repository at this point in the history
This fixes a minor case of test pollution when a test interacts with a
TextView.

InputMethodManager.sInstance still gets populated in SDK > P, and it may
contain a reference to a ViewRootImpl (mCurRootView), which causes an Activity
to leak across tests.

PiperOrigin-RevId: 411153919
  • Loading branch information
hoisie committed Nov 28, 2021
1 parent bda68fd commit 5a1f02a
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -267,9 +267,10 @@ public static void reset() {
_InputMethodManager_ _reflector = reflector(_InputMethodManager_.class);
if (apiLevel <= JELLY_BEAN_MR1) {
_reflector.setMInstance(null);
} else if (apiLevel <= P) {
_reflector.setInstance(null);
} else {
_reflector.setInstance(null);
}
if (apiLevel > P) {
_reflector.getInstanceMap().clear();
}
}
Expand Down

0 comments on commit 5a1f02a

Please sign in to comment.