Loading services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java +37 −0 Original line number Diff line number Diff line Loading @@ -237,6 +237,33 @@ public abstract class InputMethodManagerInternal { @ImfLockFree public abstract void removeImeSurface(int displayId); /** * Called when a non-IME-focusable overlay window being the IME layering target (e.g. a * window with {@link android.view.WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} and * {@link android.view.WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM} flags) * has changed its window visibility. * * @param hasVisibleOverlay whether such an overlay window exists or not * @param displayId the display ID where the overlay window exists */ public abstract void setHasVisibleImeLayeringOverlay(boolean hasVisibleOverlay, int displayId); /** * Called when the visibility of IME input target window has changed. * * @param imeInputTarget the window token of the IME input target window * @param visibleAndNotRemoved {@code true} when the new window is made visible by * {@code imeInputTarget} and the IME input target window has not * been removed. The new window is considered to be visible when * switching to the new visible IME input target window and * starting input, or the existing input target becomes visible. * In contrast, {@code false} when closing the input target, or the * existing input target becomes invisible * @param displayId the display for which to update the IME window status */ public abstract void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget, boolean visibleAndNotRemoved, int displayId); /** * Updates the IME visibility, back disposition and show IME picker status for SystemUI. * TODO(b/189923292): Making SystemUI to be true IME icon controller vs. presenter that Loading Loading @@ -389,6 +416,16 @@ public abstract class InputMethodManagerInternal { public void removeImeSurface(int displayId) { } @Override public void setHasVisibleImeLayeringOverlay(boolean hasVisibleOverlay, int displayId) { } @Override public void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget, boolean visibleAndNotRemoved, int displayId) { } @ImfLockFree @Override public void updateImeWindowStatus(boolean disableImeIcon, int displayId) { Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +19 −33 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.view.WindowManager.DISPLAY_IME_POLICY_HIDE; import static android.view.WindowManager.DISPLAY_IME_POLICY_LOCAL; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.inputmethod.ConnectionlessHandwritingCallback.CONNECTIONLESS_HANDWRITING_ERROR_OTHER; import static android.view.inputmethod.ConnectionlessHandwritingCallback.CONNECTIONLESS_HANDWRITING_ERROR_UNSUPPORTED; Loading Loading @@ -188,7 +187,6 @@ import com.android.server.inputmethod.InputMethodSubtypeSwitchingController.ImeS import com.android.server.pm.UserManagerInternal; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.utils.PriorityDump; import com.android.server.wm.ImeTargetChangeListener; import com.android.server.wm.WindowManagerInternal; import java.io.FileDescriptor; Loading Loading @@ -964,37 +962,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. InputMethodDrawsNavBarResourceMonitor.registerCallback(context, mService.mIoHandler, mService::onUpdateResourceOverlay); // Also hook up ImeTargetChangeListener. // TODO(b/356876005): Merge this into InputMethodManagerInternal. final var windowManagerInternal = mService.mWindowManagerInternal; windowManagerInternal.setInputMethodTargetChangeListener(new ImeTargetChangeListener() { @Override public void onImeTargetOverlayVisibilityChanged(@NonNull IBinder overlayWindowToken, @WindowManager.LayoutParams.WindowType int windowType, boolean visible, boolean removed, int displayId) { // Ignoring the starting window since it's ok to cover the IME target // window in temporary without affecting the IME visibility. final boolean hasOverlay = visible && !removed && windowType != TYPE_APPLICATION_STARTING; synchronized (ImfLock.class) { final var userId = mService.resolveImeUserIdFromDisplayIdLocked(displayId); mService.getUserData(userId).mVisibilityStateComputer .setHasVisibleImeLayeringOverlay(hasOverlay); } } @Override public void onImeInputTargetVisibilityChanged(IBinder imeInputTarget, boolean visibleRequested, boolean removed, int displayId) { final boolean visibleAndNotRemoved = visibleRequested && !removed; synchronized (ImfLock.class) { final var userId = mService.resolveImeUserIdFromDisplayIdLocked(displayId); mService.getUserData(userId).mVisibilityStateComputer .onImeInputTargetVisibilityChanged(imeInputTarget, visibleAndNotRemoved); } } }); // Also schedule user init tasks onto an I/O thread. initializeUsersAsync(mService.mUserManagerInternal.getUserIds()); } Loading Loading @@ -5982,6 +5949,25 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE).sendToTarget(); } @Override public void setHasVisibleImeLayeringOverlay(boolean hasVisibleOverlay, int displayId) { synchronized (ImfLock.class) { final var userId = resolveImeUserIdFromDisplayIdLocked(displayId); getUserData(userId).mVisibilityStateComputer.setHasVisibleImeLayeringOverlay( hasVisibleOverlay); } } @Override public void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget, boolean visibleAndNotRemoved, int displayId) { synchronized (ImfLock.class) { final var userId = resolveImeUserIdFromDisplayIdLocked(displayId); getUserData(userId).mVisibilityStateComputer.onImeInputTargetVisibilityChanged( imeInputTarget, visibleAndNotRemoved); } } @ImfLockFree @Override public void updateImeWindowStatus(boolean disableImeIcon, int displayId) { Loading services/core/java/com/android/server/wm/ImeTargetChangeListener.javadeleted 100644 → 0 +0 −63 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.wm; import android.annotation.NonNull; import android.os.IBinder; import android.view.WindowManager; /** * Callback the IME targeting window visibility change state for * {@link com.android.server.inputmethod.InputMethodManagerService} to manage the IME surface * visibility and z-ordering. */ public interface ImeTargetChangeListener { /** * Called when a non-IME-focusable overlay window being the IME layering target (e.g. a * window with {@link android.view.WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} and * {@link android.view.WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM} flags) * has changed its window visibility. * * @param overlayWindowToken the window token of the overlay window. * @param windowType the window type of the overlay window. * @param visible the visibility of the overlay window, {@code true} means visible * and {@code false} otherwise. * @param removed Whether the IME target overlay window has being removed. * @param displayId display ID where the overlay window exists. */ default void onImeTargetOverlayVisibilityChanged(@NonNull IBinder overlayWindowToken, @WindowManager.LayoutParams.WindowType int windowType, boolean visible, boolean removed, int displayId) { } /** * Called when the visibility of IME input target window has changed. * * @param imeInputTarget the window token of the IME input target window. * @param visible the new window visibility made by {@code imeInputTarget}. visible is * {@code true} when switching to the new visible IME input target * window and started input, or the same input target relayout to * visible from invisible. In contrast, visible is {@code false} when * closing the input target, or the same input target relayout to * invisible from visible. * @param removed Whether the IME input target window has being removed. * @param displayId display ID where the overlay window exists. */ default void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget, boolean visible, boolean removed, int displayId) { } } services/core/java/com/android/server/wm/WindowManagerInternal.java +0 −10 Original line number Diff line number Diff line Loading @@ -989,16 +989,6 @@ public abstract class WindowManagerInternal { } } /** * Sets by the {@link com.android.server.inputmethod.InputMethodManagerService} to monitor * the visibility change of the IME targeted windows. * * @see ImeTargetChangeListener#onImeTargetOverlayVisibilityChanged * @see ImeTargetChangeListener#onImeInputTargetVisibilityChanged */ public abstract void setInputMethodTargetChangeListener( @NonNull ImeTargetChangeListener listener); /** * Moves the {@link WindowToken} {@code binder} to the display specified by {@code displayId}. */ Loading services/core/java/com/android/server/wm/WindowManagerService.java +16 −25 Original line number Diff line number Diff line Loading @@ -789,7 +789,6 @@ public class WindowManagerService extends IWindowManager.Stub boolean mHardKeyboardAvailable; WindowManagerInternal.OnHardKeyboardStatusChangeListener mHardKeyboardStatusChangeListener; WindowManagerInternal.OnImeRequestedChangedListener mOnImeRequestedChangedListener; @Nullable ImeTargetChangeListener mImeTargetChangeListener; SettingsObserver mSettingsObserver; final EmbeddedWindowController mEmbeddedWindowController; Loading Loading @@ -3517,29 +3516,28 @@ public class WindowManagerService extends IWindowManager.Stub void dispatchImeTargetOverlayVisibilityChanged(@NonNull IBinder token, @WindowManager.LayoutParams.WindowType int windowType, boolean visible, boolean removed, int displayId) { if (mImeTargetChangeListener != null) { if (DEBUG_INPUT_METHOD) { Slog.d(TAG, "onImeTargetOverlayVisibilityChanged, win=" + mWindowMap.get(token) + ", type=" + ViewDebug.intToString(WindowManager.LayoutParams.class, "type", windowType) + "visible=" + visible + ", removed=" + removed + ", displayId=" + displayId); } mH.post(() -> mImeTargetChangeListener.onImeTargetOverlayVisibilityChanged(token, windowType, visible, removed, displayId)); } // Ignoring the starting window since it's ok to cover the IME target // window in temporary without affecting the IME visibility. final boolean hasOverlay = visible && !removed && windowType != TYPE_APPLICATION_STARTING; mH.post(() -> InputMethodManagerInternal.get().setHasVisibleImeLayeringOverlay(hasOverlay, displayId)); } void dispatchImeInputTargetVisibilityChanged(@NonNull IBinder token, boolean visible, boolean removed, int displayId) { if (mImeTargetChangeListener != null) { if (DEBUG_INPUT_METHOD) { Slog.d(TAG, "onImeInputTargetVisibilityChanged, win=" + mWindowMap.get(token) + "visible=" + visible + ", removed=" + removed + ", displayId" + displayId); } mH.post(() -> mImeTargetChangeListener.onImeInputTargetVisibilityChanged(token, visible, removed, displayId)); + "visible=" + visible + ", removed=" + removed + ", displayId=" + displayId); } final boolean visibleAndNotRemoved = visible && !removed; mH.post(() -> InputMethodManagerInternal.get().onImeInputTargetVisibilityChanged(token, visibleAndNotRemoved, displayId)); } @Override Loading Loading @@ -8674,13 +8672,6 @@ public class WindowManagerService extends IWindowManager.Stub return WindowManagerService.this.hasNavigationBar(displayId); } @Override public void setInputMethodTargetChangeListener(@NonNull ImeTargetChangeListener listener) { synchronized (mGlobalLock) { mImeTargetChangeListener = listener; } } @Override public void setOrientationRequestPolicy(boolean respected, int[] fromOrientations, int[] toOrientations) { Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java +37 −0 Original line number Diff line number Diff line Loading @@ -237,6 +237,33 @@ public abstract class InputMethodManagerInternal { @ImfLockFree public abstract void removeImeSurface(int displayId); /** * Called when a non-IME-focusable overlay window being the IME layering target (e.g. a * window with {@link android.view.WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} and * {@link android.view.WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM} flags) * has changed its window visibility. * * @param hasVisibleOverlay whether such an overlay window exists or not * @param displayId the display ID where the overlay window exists */ public abstract void setHasVisibleImeLayeringOverlay(boolean hasVisibleOverlay, int displayId); /** * Called when the visibility of IME input target window has changed. * * @param imeInputTarget the window token of the IME input target window * @param visibleAndNotRemoved {@code true} when the new window is made visible by * {@code imeInputTarget} and the IME input target window has not * been removed. The new window is considered to be visible when * switching to the new visible IME input target window and * starting input, or the existing input target becomes visible. * In contrast, {@code false} when closing the input target, or the * existing input target becomes invisible * @param displayId the display for which to update the IME window status */ public abstract void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget, boolean visibleAndNotRemoved, int displayId); /** * Updates the IME visibility, back disposition and show IME picker status for SystemUI. * TODO(b/189923292): Making SystemUI to be true IME icon controller vs. presenter that Loading Loading @@ -389,6 +416,16 @@ public abstract class InputMethodManagerInternal { public void removeImeSurface(int displayId) { } @Override public void setHasVisibleImeLayeringOverlay(boolean hasVisibleOverlay, int displayId) { } @Override public void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget, boolean visibleAndNotRemoved, int displayId) { } @ImfLockFree @Override public void updateImeWindowStatus(boolean disableImeIcon, int displayId) { Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +19 −33 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.view.WindowManager.DISPLAY_IME_POLICY_HIDE; import static android.view.WindowManager.DISPLAY_IME_POLICY_LOCAL; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.inputmethod.ConnectionlessHandwritingCallback.CONNECTIONLESS_HANDWRITING_ERROR_OTHER; import static android.view.inputmethod.ConnectionlessHandwritingCallback.CONNECTIONLESS_HANDWRITING_ERROR_UNSUPPORTED; Loading Loading @@ -188,7 +187,6 @@ import com.android.server.inputmethod.InputMethodSubtypeSwitchingController.ImeS import com.android.server.pm.UserManagerInternal; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.utils.PriorityDump; import com.android.server.wm.ImeTargetChangeListener; import com.android.server.wm.WindowManagerInternal; import java.io.FileDescriptor; Loading Loading @@ -964,37 +962,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. InputMethodDrawsNavBarResourceMonitor.registerCallback(context, mService.mIoHandler, mService::onUpdateResourceOverlay); // Also hook up ImeTargetChangeListener. // TODO(b/356876005): Merge this into InputMethodManagerInternal. final var windowManagerInternal = mService.mWindowManagerInternal; windowManagerInternal.setInputMethodTargetChangeListener(new ImeTargetChangeListener() { @Override public void onImeTargetOverlayVisibilityChanged(@NonNull IBinder overlayWindowToken, @WindowManager.LayoutParams.WindowType int windowType, boolean visible, boolean removed, int displayId) { // Ignoring the starting window since it's ok to cover the IME target // window in temporary without affecting the IME visibility. final boolean hasOverlay = visible && !removed && windowType != TYPE_APPLICATION_STARTING; synchronized (ImfLock.class) { final var userId = mService.resolveImeUserIdFromDisplayIdLocked(displayId); mService.getUserData(userId).mVisibilityStateComputer .setHasVisibleImeLayeringOverlay(hasOverlay); } } @Override public void onImeInputTargetVisibilityChanged(IBinder imeInputTarget, boolean visibleRequested, boolean removed, int displayId) { final boolean visibleAndNotRemoved = visibleRequested && !removed; synchronized (ImfLock.class) { final var userId = mService.resolveImeUserIdFromDisplayIdLocked(displayId); mService.getUserData(userId).mVisibilityStateComputer .onImeInputTargetVisibilityChanged(imeInputTarget, visibleAndNotRemoved); } } }); // Also schedule user init tasks onto an I/O thread. initializeUsersAsync(mService.mUserManagerInternal.getUserIds()); } Loading Loading @@ -5982,6 +5949,25 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE).sendToTarget(); } @Override public void setHasVisibleImeLayeringOverlay(boolean hasVisibleOverlay, int displayId) { synchronized (ImfLock.class) { final var userId = resolveImeUserIdFromDisplayIdLocked(displayId); getUserData(userId).mVisibilityStateComputer.setHasVisibleImeLayeringOverlay( hasVisibleOverlay); } } @Override public void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget, boolean visibleAndNotRemoved, int displayId) { synchronized (ImfLock.class) { final var userId = resolveImeUserIdFromDisplayIdLocked(displayId); getUserData(userId).mVisibilityStateComputer.onImeInputTargetVisibilityChanged( imeInputTarget, visibleAndNotRemoved); } } @ImfLockFree @Override public void updateImeWindowStatus(boolean disableImeIcon, int displayId) { Loading
services/core/java/com/android/server/wm/ImeTargetChangeListener.javadeleted 100644 → 0 +0 −63 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.wm; import android.annotation.NonNull; import android.os.IBinder; import android.view.WindowManager; /** * Callback the IME targeting window visibility change state for * {@link com.android.server.inputmethod.InputMethodManagerService} to manage the IME surface * visibility and z-ordering. */ public interface ImeTargetChangeListener { /** * Called when a non-IME-focusable overlay window being the IME layering target (e.g. a * window with {@link android.view.WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} and * {@link android.view.WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM} flags) * has changed its window visibility. * * @param overlayWindowToken the window token of the overlay window. * @param windowType the window type of the overlay window. * @param visible the visibility of the overlay window, {@code true} means visible * and {@code false} otherwise. * @param removed Whether the IME target overlay window has being removed. * @param displayId display ID where the overlay window exists. */ default void onImeTargetOverlayVisibilityChanged(@NonNull IBinder overlayWindowToken, @WindowManager.LayoutParams.WindowType int windowType, boolean visible, boolean removed, int displayId) { } /** * Called when the visibility of IME input target window has changed. * * @param imeInputTarget the window token of the IME input target window. * @param visible the new window visibility made by {@code imeInputTarget}. visible is * {@code true} when switching to the new visible IME input target * window and started input, or the same input target relayout to * visible from invisible. In contrast, visible is {@code false} when * closing the input target, or the same input target relayout to * invisible from visible. * @param removed Whether the IME input target window has being removed. * @param displayId display ID where the overlay window exists. */ default void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget, boolean visible, boolean removed, int displayId) { } }
services/core/java/com/android/server/wm/WindowManagerInternal.java +0 −10 Original line number Diff line number Diff line Loading @@ -989,16 +989,6 @@ public abstract class WindowManagerInternal { } } /** * Sets by the {@link com.android.server.inputmethod.InputMethodManagerService} to monitor * the visibility change of the IME targeted windows. * * @see ImeTargetChangeListener#onImeTargetOverlayVisibilityChanged * @see ImeTargetChangeListener#onImeInputTargetVisibilityChanged */ public abstract void setInputMethodTargetChangeListener( @NonNull ImeTargetChangeListener listener); /** * Moves the {@link WindowToken} {@code binder} to the display specified by {@code displayId}. */ Loading
services/core/java/com/android/server/wm/WindowManagerService.java +16 −25 Original line number Diff line number Diff line Loading @@ -789,7 +789,6 @@ public class WindowManagerService extends IWindowManager.Stub boolean mHardKeyboardAvailable; WindowManagerInternal.OnHardKeyboardStatusChangeListener mHardKeyboardStatusChangeListener; WindowManagerInternal.OnImeRequestedChangedListener mOnImeRequestedChangedListener; @Nullable ImeTargetChangeListener mImeTargetChangeListener; SettingsObserver mSettingsObserver; final EmbeddedWindowController mEmbeddedWindowController; Loading Loading @@ -3517,29 +3516,28 @@ public class WindowManagerService extends IWindowManager.Stub void dispatchImeTargetOverlayVisibilityChanged(@NonNull IBinder token, @WindowManager.LayoutParams.WindowType int windowType, boolean visible, boolean removed, int displayId) { if (mImeTargetChangeListener != null) { if (DEBUG_INPUT_METHOD) { Slog.d(TAG, "onImeTargetOverlayVisibilityChanged, win=" + mWindowMap.get(token) + ", type=" + ViewDebug.intToString(WindowManager.LayoutParams.class, "type", windowType) + "visible=" + visible + ", removed=" + removed + ", displayId=" + displayId); } mH.post(() -> mImeTargetChangeListener.onImeTargetOverlayVisibilityChanged(token, windowType, visible, removed, displayId)); } // Ignoring the starting window since it's ok to cover the IME target // window in temporary without affecting the IME visibility. final boolean hasOverlay = visible && !removed && windowType != TYPE_APPLICATION_STARTING; mH.post(() -> InputMethodManagerInternal.get().setHasVisibleImeLayeringOverlay(hasOverlay, displayId)); } void dispatchImeInputTargetVisibilityChanged(@NonNull IBinder token, boolean visible, boolean removed, int displayId) { if (mImeTargetChangeListener != null) { if (DEBUG_INPUT_METHOD) { Slog.d(TAG, "onImeInputTargetVisibilityChanged, win=" + mWindowMap.get(token) + "visible=" + visible + ", removed=" + removed + ", displayId" + displayId); } mH.post(() -> mImeTargetChangeListener.onImeInputTargetVisibilityChanged(token, visible, removed, displayId)); + "visible=" + visible + ", removed=" + removed + ", displayId=" + displayId); } final boolean visibleAndNotRemoved = visible && !removed; mH.post(() -> InputMethodManagerInternal.get().onImeInputTargetVisibilityChanged(token, visibleAndNotRemoved, displayId)); } @Override Loading Loading @@ -8674,13 +8672,6 @@ public class WindowManagerService extends IWindowManager.Stub return WindowManagerService.this.hasNavigationBar(displayId); } @Override public void setInputMethodTargetChangeListener(@NonNull ImeTargetChangeListener listener) { synchronized (mGlobalLock) { mImeTargetChangeListener = listener; } } @Override public void setOrientationRequestPolicy(boolean respected, int[] fromOrientations, int[] toOrientations) { Loading