[RESTRICT AUTOMERGE] Attempt to fix exception in IMS
IMS might throw IllegalStateException in WindowContextController#attachToWindowToken when #initializeInternal is called. A possible root cause may be #initializeInternal is called after onDestroy, which detach IMS from ImeContainer. This CL add a flag in #onDestroy to prevent #initializeInternal from being called after #onDestroy. Bug: 211062619 Test: presubmit Change-Id: Ie7814da801878a3487123fefdc9e71d0e1ed28d7
This commit is contained in:
@@ -524,6 +524,7 @@ public class InputMethodService extends AbstractInputMethodService {
|
|||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private boolean mImeSurfaceScheduledForRemoval;
|
private boolean mImeSurfaceScheduledForRemoval;
|
||||||
private ImsConfigurationTracker mConfigTracker = new ImsConfigurationTracker();
|
private ImsConfigurationTracker mConfigTracker = new ImsConfigurationTracker();
|
||||||
|
private boolean mDestroyed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An opaque {@link Binder} token of window requesting {@link InputMethodImpl#showSoftInput}
|
* An opaque {@link Binder} token of window requesting {@link InputMethodImpl#showSoftInput}
|
||||||
@@ -604,6 +605,11 @@ public class InputMethodService extends AbstractInputMethodService {
|
|||||||
Log.w(TAG, "The token has already registered, ignore this initialization.");
|
Log.w(TAG, "The token has already registered, ignore this initialization.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (mDestroyed) {
|
||||||
|
Log.i(TAG, "The InputMethodService has already onDestroyed()."
|
||||||
|
+ "Ignore the initialization.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.initializeInternal");
|
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.initializeInternal");
|
||||||
mConfigTracker.onInitialize(configChanges);
|
mConfigTracker.onInitialize(configChanges);
|
||||||
mPrivOps.set(privilegedOperations);
|
mPrivOps.set(privilegedOperations);
|
||||||
@@ -1403,6 +1409,7 @@ public class InputMethodService extends AbstractInputMethodService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onDestroy() {
|
@Override public void onDestroy() {
|
||||||
|
mDestroyed = true;
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
mRootView.getViewTreeObserver().removeOnComputeInternalInsetsListener(
|
mRootView.getViewTreeObserver().removeOnComputeInternalInsetsListener(
|
||||||
mInsetsComputer);
|
mInsetsComputer);
|
||||||
|
|||||||
Reference in New Issue
Block a user