Loading services/core/java/com/android/server/inputmethod/ImeVisibilityStateComputer.java +23 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.accessibilityservice.AccessibilityService; import android.annotation.AnyThread; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.content.res.Configuration; import android.os.Binder; Loading Loading @@ -128,6 +129,15 @@ public final class ImeVisibilityStateComputer { @GuardedBy("ImfLock.class") private IBinder mCurVisibleImeInputTarget; /** * The last window token that we confirmed that IME started talking to. This is always updated * upon reports from the input method. If the window state is already changed before the report * is handled, this field just keeps the last value. */ @GuardedBy("ImfLock.class") @Nullable private IBinder mLastImeTargetWindow; /** Represent the invalid IME visibility state */ public static final int STATE_INVALID = -1; Loading Loading @@ -479,8 +489,7 @@ public final class ImeVisibilityStateComputer { break; case WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED: // Do nothing but preserving the last IME requested visibility state. final ImeTargetWindowState lastState = getWindowStateOrNull(mService.mLastImeTargetWindow); final ImeTargetWindowState lastState = getWindowStateOrNull(mLastImeTargetWindow); if (lastState != null) { state.setRequestedImeVisible(lastState.mRequestedImeVisible); } Loading Loading @@ -631,6 +640,17 @@ public final class ImeVisibilityStateComputer { mInputShown = inputShown; } @GuardedBy("ImfLock.class") @Nullable IBinder getLastImeTargetWindow() { return mLastImeTargetWindow; } @GuardedBy("ImfLock.class") void setLastImeTargetWindow(@Nullable IBinder imeTargetWindow) { mLastImeTargetWindow = imeTargetWindow; } @GuardedBy("ImfLock.class") void dumpDebug(ProtoOutputStream proto, long fieldId) { proto.write(SHOW_EXPLICITLY_REQUESTED, mRequestedShowExplicitly); Loading @@ -647,6 +667,7 @@ public final class ImeVisibilityStateComputer { + " mShowForced=" + mShowForced); p.println(prefix + "mImeHiddenByDisplayPolicy=" + mPolicy.isImeHiddenByDisplayPolicy()); p.println(prefix + "mInputShown=" + mInputShown); p.println(prefix + "mLastImeTargetWindow=" + mLastImeTargetWindow); } /** Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +10 −17 Original line number Diff line number Diff line Loading @@ -522,14 +522,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. return getUserData(userId).mBindingController; } /** * The last window token that we confirmed that IME started talking to. This is always updated * upon reports from the input method. If the window state is already changed before the report * is handled, this field just keeps the last value. */ @MultiUserUnawareField IBinder mLastImeTargetWindow; /** * Map of window perceptible states indexed by their associated window tokens. * Loading Loading @@ -2757,7 +2749,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. if (targetWindow != null) { mWindowManagerInternal.updateInputMethodTargetWindow(token, targetWindow); } mLastImeTargetWindow = targetWindow; mVisibilityStateComputer.setLastImeTargetWindow(targetWindow); } } Loading Loading @@ -4679,8 +4671,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. proto.write(CUR_SEQ, bindingController.getSequenceNumber()); proto.write(CUR_CLIENT, Objects.toString(userData.mCurClient)); userData.mImeBindingState.dumpDebug(proto, mWindowManagerInternal); proto.write(LAST_IME_TARGET_WINDOW_NAME, mWindowManagerInternal.getWindowName(mLastImeTargetWindow)); proto.write(LAST_IME_TARGET_WINDOW_NAME, mWindowManagerInternal.getWindowName( mVisibilityStateComputer.getLastImeTargetWindow())); proto.write(CUR_FOCUSED_WINDOW_SOFT_INPUT_MODE, InputMethodDebug.softInputModeToString( userData.mImeBindingState.mFocusedWindowSoftInputMode)); if (userData.mCurEditorInfo != null) { Loading Loading @@ -4854,8 +4846,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. .setImeVisibility(false, statsToken); } } else { hideCurrentInputLocked(mLastImeTargetWindow, statsToken, flags, null /* resultReceiver */, reason, userId); hideCurrentInputLocked(mVisibilityStateComputer.getLastImeTargetWindow(), statsToken, flags, null /* resultReceiver */, reason, userId); } } finally { Binder.restoreCallingIdentity(ident); Loading Loading @@ -4893,9 +4885,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. .setImeVisibility(true, statsToken); } } else { showCurrentInputLocked(mLastImeTargetWindow, statsToken, flags, MotionEvent.TOOL_TYPE_UNKNOWN, null /* resultReceiver */, reason, userId); showCurrentInputLocked(mVisibilityStateComputer.getLastImeTargetWindow(), statsToken, flags, MotionEvent.TOOL_TYPE_UNKNOWN, null /* resultReceiver */, reason, userId); } } finally { Binder.restoreCallingIdentity(ident); Loading Loading @@ -5911,7 +5903,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. // Hide the IME method menu only when the IME surface parent is changed by the // input target changed, in case seeing the dialog dismiss flickering during // the next focused window starting the input connection. if (mLastImeTargetWindow != userData.mImeBindingState.mFocusedWindow) { if (mVisibilityStateComputer.getLastImeTargetWindow() != userData.mImeBindingState.mFocusedWindow) { if (Flags.imeSwitcherRevamp()) { final var bindingController = getInputMethodBindingController(userId); mMenuControllerNew.hide(bindingController.getCurTokenDisplayId(), userId); Loading services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/ImeVisibilityStateComputerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -251,7 +251,7 @@ public class ImeVisibilityStateComputerTest extends InputMethodManagerServiceTes synchronized (ImfLock.class) { // Assume the last IME targeted window has requested IME visible final IBinder lastImeTargetWindowToken = new Binder(); mInputMethodManagerService.mLastImeTargetWindow = lastImeTargetWindowToken; mComputer.setLastImeTargetWindow(lastImeTargetWindowToken); mComputer.requestImeVisibility(lastImeTargetWindowToken, true); final ImeTargetWindowState lastState = mComputer.getWindowStateOrNull( lastImeTargetWindowToken); Loading Loading
services/core/java/com/android/server/inputmethod/ImeVisibilityStateComputer.java +23 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.accessibilityservice.AccessibilityService; import android.annotation.AnyThread; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.content.res.Configuration; import android.os.Binder; Loading Loading @@ -128,6 +129,15 @@ public final class ImeVisibilityStateComputer { @GuardedBy("ImfLock.class") private IBinder mCurVisibleImeInputTarget; /** * The last window token that we confirmed that IME started talking to. This is always updated * upon reports from the input method. If the window state is already changed before the report * is handled, this field just keeps the last value. */ @GuardedBy("ImfLock.class") @Nullable private IBinder mLastImeTargetWindow; /** Represent the invalid IME visibility state */ public static final int STATE_INVALID = -1; Loading Loading @@ -479,8 +489,7 @@ public final class ImeVisibilityStateComputer { break; case WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED: // Do nothing but preserving the last IME requested visibility state. final ImeTargetWindowState lastState = getWindowStateOrNull(mService.mLastImeTargetWindow); final ImeTargetWindowState lastState = getWindowStateOrNull(mLastImeTargetWindow); if (lastState != null) { state.setRequestedImeVisible(lastState.mRequestedImeVisible); } Loading Loading @@ -631,6 +640,17 @@ public final class ImeVisibilityStateComputer { mInputShown = inputShown; } @GuardedBy("ImfLock.class") @Nullable IBinder getLastImeTargetWindow() { return mLastImeTargetWindow; } @GuardedBy("ImfLock.class") void setLastImeTargetWindow(@Nullable IBinder imeTargetWindow) { mLastImeTargetWindow = imeTargetWindow; } @GuardedBy("ImfLock.class") void dumpDebug(ProtoOutputStream proto, long fieldId) { proto.write(SHOW_EXPLICITLY_REQUESTED, mRequestedShowExplicitly); Loading @@ -647,6 +667,7 @@ public final class ImeVisibilityStateComputer { + " mShowForced=" + mShowForced); p.println(prefix + "mImeHiddenByDisplayPolicy=" + mPolicy.isImeHiddenByDisplayPolicy()); p.println(prefix + "mInputShown=" + mInputShown); p.println(prefix + "mLastImeTargetWindow=" + mLastImeTargetWindow); } /** Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +10 −17 Original line number Diff line number Diff line Loading @@ -522,14 +522,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. return getUserData(userId).mBindingController; } /** * The last window token that we confirmed that IME started talking to. This is always updated * upon reports from the input method. If the window state is already changed before the report * is handled, this field just keeps the last value. */ @MultiUserUnawareField IBinder mLastImeTargetWindow; /** * Map of window perceptible states indexed by their associated window tokens. * Loading Loading @@ -2757,7 +2749,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. if (targetWindow != null) { mWindowManagerInternal.updateInputMethodTargetWindow(token, targetWindow); } mLastImeTargetWindow = targetWindow; mVisibilityStateComputer.setLastImeTargetWindow(targetWindow); } } Loading Loading @@ -4679,8 +4671,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. proto.write(CUR_SEQ, bindingController.getSequenceNumber()); proto.write(CUR_CLIENT, Objects.toString(userData.mCurClient)); userData.mImeBindingState.dumpDebug(proto, mWindowManagerInternal); proto.write(LAST_IME_TARGET_WINDOW_NAME, mWindowManagerInternal.getWindowName(mLastImeTargetWindow)); proto.write(LAST_IME_TARGET_WINDOW_NAME, mWindowManagerInternal.getWindowName( mVisibilityStateComputer.getLastImeTargetWindow())); proto.write(CUR_FOCUSED_WINDOW_SOFT_INPUT_MODE, InputMethodDebug.softInputModeToString( userData.mImeBindingState.mFocusedWindowSoftInputMode)); if (userData.mCurEditorInfo != null) { Loading Loading @@ -4854,8 +4846,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. .setImeVisibility(false, statsToken); } } else { hideCurrentInputLocked(mLastImeTargetWindow, statsToken, flags, null /* resultReceiver */, reason, userId); hideCurrentInputLocked(mVisibilityStateComputer.getLastImeTargetWindow(), statsToken, flags, null /* resultReceiver */, reason, userId); } } finally { Binder.restoreCallingIdentity(ident); Loading Loading @@ -4893,9 +4885,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. .setImeVisibility(true, statsToken); } } else { showCurrentInputLocked(mLastImeTargetWindow, statsToken, flags, MotionEvent.TOOL_TYPE_UNKNOWN, null /* resultReceiver */, reason, userId); showCurrentInputLocked(mVisibilityStateComputer.getLastImeTargetWindow(), statsToken, flags, MotionEvent.TOOL_TYPE_UNKNOWN, null /* resultReceiver */, reason, userId); } } finally { Binder.restoreCallingIdentity(ident); Loading Loading @@ -5911,7 +5903,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. // Hide the IME method menu only when the IME surface parent is changed by the // input target changed, in case seeing the dialog dismiss flickering during // the next focused window starting the input connection. if (mLastImeTargetWindow != userData.mImeBindingState.mFocusedWindow) { if (mVisibilityStateComputer.getLastImeTargetWindow() != userData.mImeBindingState.mFocusedWindow) { if (Flags.imeSwitcherRevamp()) { final var bindingController = getInputMethodBindingController(userId); mMenuControllerNew.hide(bindingController.getCurTokenDisplayId(), userId); Loading
services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/ImeVisibilityStateComputerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -251,7 +251,7 @@ public class ImeVisibilityStateComputerTest extends InputMethodManagerServiceTes synchronized (ImfLock.class) { // Assume the last IME targeted window has requested IME visible final IBinder lastImeTargetWindowToken = new Binder(); mInputMethodManagerService.mLastImeTargetWindow = lastImeTargetWindowToken; mComputer.setLastImeTargetWindow(lastImeTargetWindowToken); mComputer.requestImeVisibility(lastImeTargetWindowToken, true); final ImeTargetWindowState lastState = mComputer.getWindowStateOrNull( lastImeTargetWindowToken); Loading