[RESTRICT AUTOMERGE] Attempt to fix exception in IMS am: 468f72f016
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16601123
Change-Id: I7e68b82bea841ddbb48cd5d3955605de143eb33f
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index e0324c0..9f79886 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -524,6 +524,7 @@
private Handler mHandler;
private boolean mImeSurfaceScheduledForRemoval;
private ImsConfigurationTracker mConfigTracker = new ImsConfigurationTracker();
+ private boolean mDestroyed;
/**
* An opaque {@link Binder} token of window requesting {@link InputMethodImpl#showSoftInput}
@@ -604,6 +605,11 @@
Log.w(TAG, "The token has already registered, ignore this initialization.");
return;
}
+ if (mDestroyed) {
+ Log.i(TAG, "The InputMethodService has already onDestroyed()."
+ + "Ignore the initialization.");
+ return;
+ }
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.initializeInternal");
mConfigTracker.onInitialize(configChanges);
mPrivOps.set(privilegedOperations);
@@ -1403,6 +1409,7 @@
}
@Override public void onDestroy() {
+ mDestroyed = true;
super.onDestroy();
mRootView.getViewTreeObserver().removeOnComputeInternalInsetsListener(
mInsetsComputer);