Store displayIdToShowIme in an IMMS field
This change allows the IMMS to remember the last display id the IME was requested to bind on. One use case is when we want to prevent binding the IME if there is no currently focused editText, and yet we want to still be able to handle an explicit request to show the IME later. Remembering the display id helps to show it on the correct screen. Bug: 199887357 Bug: 37617707 Test: make Change-Id: I98459c4a44416fd7209150932a2a2520612da818
This commit is contained in:
@@ -383,7 +383,7 @@ final class InputMethodBindingController {
|
||||
|
||||
@GuardedBy("mMethodMap")
|
||||
@NonNull
|
||||
InputBindResult bindCurrentMethodLocked(int displayIdToShowIme) {
|
||||
InputBindResult bindCurrentMethodLocked() {
|
||||
InputMethodInfo info = mMethodMap.get(mSelectedMethodId);
|
||||
if (info == null) {
|
||||
throw new IllegalArgumentException("Unknown id: " + mSelectedMethodId);
|
||||
@@ -395,7 +395,7 @@ final class InputMethodBindingController {
|
||||
mCurId = info.getId();
|
||||
mLastBindTime = SystemClock.uptimeMillis();
|
||||
|
||||
addFreshWindowTokenLocked(displayIdToShowIme);
|
||||
addFreshWindowTokenLocked();
|
||||
return new InputBindResult(
|
||||
InputBindResult.ResultCode.SUCCESS_WAITING_IME_BINDING,
|
||||
null, null, mCurId, mCurSeq, false);
|
||||
@@ -420,7 +420,8 @@ final class InputMethodBindingController {
|
||||
}
|
||||
|
||||
@GuardedBy("mMethodMap")
|
||||
private void addFreshWindowTokenLocked(int displayIdToShowIme) {
|
||||
private void addFreshWindowTokenLocked() {
|
||||
int displayIdToShowIme = mService.getDisplayIdToShowIme();
|
||||
mCurToken = new Binder();
|
||||
|
||||
mService.setCurTokenDisplayId(displayIdToShowIme);
|
||||
|
||||
@@ -305,6 +305,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
@GuardedBy("mMethodMap")
|
||||
private int mMethodMapUpdateCount = 0;
|
||||
|
||||
/**
|
||||
* The display id for which the latest startInput was called.
|
||||
*/
|
||||
@GuardedBy("mMethodMap")
|
||||
int getDisplayIdToShowIme() {
|
||||
return mDisplayIdToShowIme;
|
||||
}
|
||||
|
||||
@GuardedBy("mMethodMap")
|
||||
private int mDisplayIdToShowIme = INVALID_DISPLAY;
|
||||
|
||||
// Ongoing notification
|
||||
private NotificationManager mNotificationManager;
|
||||
KeyguardManager mKeyguardManager;
|
||||
@@ -2340,10 +2351,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
// Compute the final shown display ID with validated cs.selfReportedDisplayId for this
|
||||
// session & other conditions.
|
||||
final int displayIdToShowIme = computeImeDisplayIdForTarget(cs.selfReportedDisplayId,
|
||||
mDisplayIdToShowIme = computeImeDisplayIdForTarget(cs.selfReportedDisplayId,
|
||||
mImeDisplayValidator);
|
||||
|
||||
if (displayIdToShowIme == INVALID_DISPLAY) {
|
||||
if (mDisplayIdToShowIme == INVALID_DISPLAY) {
|
||||
mImeHiddenByDisplayPolicy = true;
|
||||
hideCurrentInputLocked(mCurFocusedWindow, 0, null,
|
||||
SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE);
|
||||
@@ -2364,7 +2375,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
// Check if the input method is changing.
|
||||
// We expect the caller has already verified that the client is allowed to access this
|
||||
// display ID.
|
||||
if (isSelectedMethodBound(displayIdToShowIme)) {
|
||||
if (isSelectedMethodBound()) {
|
||||
if (cs.curSession != null) {
|
||||
// Fast case: if we are already connected to the input method,
|
||||
// then just return it.
|
||||
@@ -2380,13 +2391,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
|
||||
mBindingController.unbindCurrentMethodLocked();
|
||||
|
||||
return mBindingController.bindCurrentMethodLocked(displayIdToShowIme);
|
||||
return mBindingController.bindCurrentMethodLocked();
|
||||
}
|
||||
|
||||
private boolean isSelectedMethodBound(int displayIdToShowIme) {
|
||||
private boolean isSelectedMethodBound() {
|
||||
String curId = getCurId();
|
||||
return curId != null && curId.equals(getSelectedMethodId())
|
||||
&& displayIdToShowIme == mCurTokenDisplayId;
|
||||
&& mDisplayIdToShowIme == mCurTokenDisplayId;
|
||||
}
|
||||
|
||||
@GuardedBy("mMethodMap")
|
||||
|
||||
Reference in New Issue
Block a user