Loading services/core/java/com/android/server/input/InputManagerService.java +11 −4 Original line number Diff line number Diff line Loading @@ -197,7 +197,7 @@ public class InputManagerService extends IInputManager.Stub private static native boolean nativeHasKeys(long ptr, int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists); private static native void nativeRegisterInputChannel(long ptr, InputChannel inputChannel, InputWindowHandle inputWindowHandle, boolean monitor); InputWindowHandle inputWindowHandle, int displayId); private static native void nativeUnregisterInputChannel(long ptr, InputChannel inputChannel); private static native void nativeSetInputFilterEnabled(long ptr, boolean enable); private static native int nativeInjectInputEvent(long ptr, InputEvent event, Loading Loading @@ -473,15 +473,21 @@ public class InputManagerService extends IInputManager.Stub /** * Creates an input channel that will receive all input from the input dispatcher. * @param inputChannelName The input channel name. * @param displayId Target display id. * @return The input channel. */ public InputChannel monitorInput(String inputChannelName) { public InputChannel monitorInput(String inputChannelName, int displayId) { if (inputChannelName == null) { throw new IllegalArgumentException("inputChannelName must not be null."); } if (displayId < Display.DEFAULT_DISPLAY) { throw new IllegalArgumentException("displayId must >= 0."); } InputChannel[] inputChannels = InputChannel.openInputChannelPair(inputChannelName); nativeRegisterInputChannel(mPtr, inputChannels[0], null, true); // Register channel for monitor. nativeRegisterInputChannel(mPtr, inputChannels[0], null, displayId); inputChannels[0].dispose(); // don't need to retain the Java object reference return inputChannels[1]; } Loading @@ -498,7 +504,8 @@ public class InputManagerService extends IInputManager.Stub throw new IllegalArgumentException("inputChannel must not be null."); } nativeRegisterInputChannel(mPtr, inputChannel, inputWindowHandle, false); // Register channel for normal. nativeRegisterInputChannel(mPtr, inputChannel, inputWindowHandle, Display.INVALID_DISPLAY); } /** Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +7 −3 Original line number Diff line number Diff line Loading @@ -2061,7 +2061,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } }); mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); //TODO (b/111365687) : make system context per display. mWindowManagerFuncs.registerPointerEventListener(mSystemGestures, DEFAULT_DISPLAY); mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); mLongPressVibePattern = getLongIntArray(mContext.getResources(), Loading Loading @@ -2258,13 +2259,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { WindowManager wm = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; wm.addView(mPointerLocationView, lp); mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView); //TODO (b/111365687) : make system context per display. mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView, DEFAULT_DISPLAY); } } private void disablePointerLocation() { if (mPointerLocationView != null) { mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView); //TODO (b/111365687) : make system context per display. mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView, DEFAULT_DISPLAY); WindowManager wm = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); wm.removeView(mPointerLocationView); mPointerLocationView = null; Loading services/core/java/com/android/server/policy/WindowManagerPolicy.java +2 −2 Original line number Diff line number Diff line Loading @@ -559,10 +559,10 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { public Object getWindowManagerLock(); /** Register a system listener for touch events */ void registerPointerEventListener(PointerEventListener listener); void registerPointerEventListener(PointerEventListener listener, int displayId); /** Unregister a system listener for touch events */ void unregisterPointerEventListener(PointerEventListener listener); void unregisterPointerEventListener(PointerEventListener listener, int displayId); /** * @return The content insets of the docked divider window. Loading services/core/java/com/android/server/wm/DisplayContent.java +42 −7 Original line number Diff line number Diff line Loading @@ -145,12 +145,14 @@ import android.view.Display; import android.view.DisplayCutout; import android.view.DisplayInfo; import android.view.Gravity; import android.view.InputChannel; import android.view.InputDevice; import android.view.MagnificationSpec; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; import android.view.SurfaceSession; import android.view.WindowManagerPolicyConstants.PointerEventListener; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ToBooleanFunction; Loading Loading @@ -454,6 +456,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo */ WindowState mInputMethodWindow; private final PointerEventDispatcher mPointerEventDispatcher; private final Consumer<WindowState> mUpdateWindowsForAnimator = w -> { WindowStateAnimator winAnimator = w.mWinAnimator; final AppWindowToken atoken = w.mAppToken; Loading Loading @@ -833,6 +837,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mDisplayReady = true; mInputMonitor = new InputMonitor(service, mDisplayId); if (mService.mInputManager != null) { final InputChannel inputChannel = mService.mInputManager.monitorInput("Display " + mDisplayId, mDisplayId); mPointerEventDispatcher = inputChannel != null ? new PointerEventDispatcher(inputChannel) : null; } else { mPointerEventDispatcher = null; } } boolean isReady() { Loading Loading @@ -1286,6 +1299,19 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mDisplayFrames.onDisplayInfoUpdated(mDisplayInfo, calculateDisplayCutoutForRotation(mDisplayInfo.rotation)); // Tap Listeners are supported for: // 1. All physical displays (multi-display). // 2. VirtualDisplays on VR, AA (and everything else). if (mPointerEventDispatcher != null && mTapDetector == null) { if (DEBUG_DISPLAY) { Slog.d(TAG, "Registering PointerEventListener for DisplayId: " + mDisplayId); } mTapDetector = new TaskTapPointerEventListener(mService, this); registerPointerEventListener(mTapDetector); registerPointerEventListener(mService.mMousePositionTracker); } } /** Loading Loading @@ -2186,13 +2212,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo try { super.removeImmediately(); if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Removing display=" + this); if (mService.canDispatchPointerEvents()) { if (mTapDetector != null) { mService.unregisterPointerEventListener(mTapDetector); } if (mDisplayId == DEFAULT_DISPLAY && mService.mMousePositionTracker != null) { mService.unregisterPointerEventListener(mService.mMousePositionTracker); } if (mPointerEventDispatcher != null && mTapDetector != null) { unregisterPointerEventListener(mTapDetector); unregisterPointerEventListener(mService.mMousePositionTracker); mTapDetector = null; } mService.mAnimator.removeDisplayLocked(mDisplayId); mWindowingLayer.release(); Loading Loading @@ -4409,4 +4432,16 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo boolean getLastHasContent() { return mLastHasContent; } void registerPointerEventListener(@NonNull PointerEventListener listener) { if (mPointerEventDispatcher != null) { mPointerEventDispatcher.registerInputEventListener(listener); } } void unregisterPointerEventListener(@NonNull PointerEventListener listener) { if (mPointerEventDispatcher != null) { mPointerEventDispatcher.unregisterInputEventListener(listener); } } } services/core/java/com/android/server/wm/RootWindowContainer.java +0 −15 Original line number Diff line number Diff line Loading @@ -228,21 +228,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> { mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager( displayId, dc.getDisplayInfo()); dc.configureDisplayPolicy(); // Tap Listeners are supported for: // 1. All physical displays (multi-display). // 2. VirtualDisplays on VR, AA (and everything else). if (mService.canDispatchPointerEvents()) { if (DEBUG_DISPLAY) { Slog.d(TAG, "Registering PointerEventListener for DisplayId: " + displayId); } dc.mTapDetector = new TaskTapPointerEventListener(mService, dc); mService.registerPointerEventListener(dc.mTapDetector); if (displayId == DEFAULT_DISPLAY) { mService.registerPointerEventListener(mService.mMousePositionTracker); } } } return dc; Loading Loading
services/core/java/com/android/server/input/InputManagerService.java +11 −4 Original line number Diff line number Diff line Loading @@ -197,7 +197,7 @@ public class InputManagerService extends IInputManager.Stub private static native boolean nativeHasKeys(long ptr, int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists); private static native void nativeRegisterInputChannel(long ptr, InputChannel inputChannel, InputWindowHandle inputWindowHandle, boolean monitor); InputWindowHandle inputWindowHandle, int displayId); private static native void nativeUnregisterInputChannel(long ptr, InputChannel inputChannel); private static native void nativeSetInputFilterEnabled(long ptr, boolean enable); private static native int nativeInjectInputEvent(long ptr, InputEvent event, Loading Loading @@ -473,15 +473,21 @@ public class InputManagerService extends IInputManager.Stub /** * Creates an input channel that will receive all input from the input dispatcher. * @param inputChannelName The input channel name. * @param displayId Target display id. * @return The input channel. */ public InputChannel monitorInput(String inputChannelName) { public InputChannel monitorInput(String inputChannelName, int displayId) { if (inputChannelName == null) { throw new IllegalArgumentException("inputChannelName must not be null."); } if (displayId < Display.DEFAULT_DISPLAY) { throw new IllegalArgumentException("displayId must >= 0."); } InputChannel[] inputChannels = InputChannel.openInputChannelPair(inputChannelName); nativeRegisterInputChannel(mPtr, inputChannels[0], null, true); // Register channel for monitor. nativeRegisterInputChannel(mPtr, inputChannels[0], null, displayId); inputChannels[0].dispose(); // don't need to retain the Java object reference return inputChannels[1]; } Loading @@ -498,7 +504,8 @@ public class InputManagerService extends IInputManager.Stub throw new IllegalArgumentException("inputChannel must not be null."); } nativeRegisterInputChannel(mPtr, inputChannel, inputWindowHandle, false); // Register channel for normal. nativeRegisterInputChannel(mPtr, inputChannel, inputWindowHandle, Display.INVALID_DISPLAY); } /** Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +7 −3 Original line number Diff line number Diff line Loading @@ -2061,7 +2061,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } }); mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); //TODO (b/111365687) : make system context per display. mWindowManagerFuncs.registerPointerEventListener(mSystemGestures, DEFAULT_DISPLAY); mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); mLongPressVibePattern = getLongIntArray(mContext.getResources(), Loading Loading @@ -2258,13 +2259,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { WindowManager wm = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; wm.addView(mPointerLocationView, lp); mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView); //TODO (b/111365687) : make system context per display. mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView, DEFAULT_DISPLAY); } } private void disablePointerLocation() { if (mPointerLocationView != null) { mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView); //TODO (b/111365687) : make system context per display. mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView, DEFAULT_DISPLAY); WindowManager wm = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); wm.removeView(mPointerLocationView); mPointerLocationView = null; Loading
services/core/java/com/android/server/policy/WindowManagerPolicy.java +2 −2 Original line number Diff line number Diff line Loading @@ -559,10 +559,10 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { public Object getWindowManagerLock(); /** Register a system listener for touch events */ void registerPointerEventListener(PointerEventListener listener); void registerPointerEventListener(PointerEventListener listener, int displayId); /** Unregister a system listener for touch events */ void unregisterPointerEventListener(PointerEventListener listener); void unregisterPointerEventListener(PointerEventListener listener, int displayId); /** * @return The content insets of the docked divider window. Loading
services/core/java/com/android/server/wm/DisplayContent.java +42 −7 Original line number Diff line number Diff line Loading @@ -145,12 +145,14 @@ import android.view.Display; import android.view.DisplayCutout; import android.view.DisplayInfo; import android.view.Gravity; import android.view.InputChannel; import android.view.InputDevice; import android.view.MagnificationSpec; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; import android.view.SurfaceSession; import android.view.WindowManagerPolicyConstants.PointerEventListener; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ToBooleanFunction; Loading Loading @@ -454,6 +456,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo */ WindowState mInputMethodWindow; private final PointerEventDispatcher mPointerEventDispatcher; private final Consumer<WindowState> mUpdateWindowsForAnimator = w -> { WindowStateAnimator winAnimator = w.mWinAnimator; final AppWindowToken atoken = w.mAppToken; Loading Loading @@ -833,6 +837,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mDisplayReady = true; mInputMonitor = new InputMonitor(service, mDisplayId); if (mService.mInputManager != null) { final InputChannel inputChannel = mService.mInputManager.monitorInput("Display " + mDisplayId, mDisplayId); mPointerEventDispatcher = inputChannel != null ? new PointerEventDispatcher(inputChannel) : null; } else { mPointerEventDispatcher = null; } } boolean isReady() { Loading Loading @@ -1286,6 +1299,19 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mDisplayFrames.onDisplayInfoUpdated(mDisplayInfo, calculateDisplayCutoutForRotation(mDisplayInfo.rotation)); // Tap Listeners are supported for: // 1. All physical displays (multi-display). // 2. VirtualDisplays on VR, AA (and everything else). if (mPointerEventDispatcher != null && mTapDetector == null) { if (DEBUG_DISPLAY) { Slog.d(TAG, "Registering PointerEventListener for DisplayId: " + mDisplayId); } mTapDetector = new TaskTapPointerEventListener(mService, this); registerPointerEventListener(mTapDetector); registerPointerEventListener(mService.mMousePositionTracker); } } /** Loading Loading @@ -2186,13 +2212,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo try { super.removeImmediately(); if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Removing display=" + this); if (mService.canDispatchPointerEvents()) { if (mTapDetector != null) { mService.unregisterPointerEventListener(mTapDetector); } if (mDisplayId == DEFAULT_DISPLAY && mService.mMousePositionTracker != null) { mService.unregisterPointerEventListener(mService.mMousePositionTracker); } if (mPointerEventDispatcher != null && mTapDetector != null) { unregisterPointerEventListener(mTapDetector); unregisterPointerEventListener(mService.mMousePositionTracker); mTapDetector = null; } mService.mAnimator.removeDisplayLocked(mDisplayId); mWindowingLayer.release(); Loading Loading @@ -4409,4 +4432,16 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo boolean getLastHasContent() { return mLastHasContent; } void registerPointerEventListener(@NonNull PointerEventListener listener) { if (mPointerEventDispatcher != null) { mPointerEventDispatcher.registerInputEventListener(listener); } } void unregisterPointerEventListener(@NonNull PointerEventListener listener) { if (mPointerEventDispatcher != null) { mPointerEventDispatcher.unregisterInputEventListener(listener); } } }
services/core/java/com/android/server/wm/RootWindowContainer.java +0 −15 Original line number Diff line number Diff line Loading @@ -228,21 +228,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> { mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager( displayId, dc.getDisplayInfo()); dc.configureDisplayPolicy(); // Tap Listeners are supported for: // 1. All physical displays (multi-display). // 2. VirtualDisplays on VR, AA (and everything else). if (mService.canDispatchPointerEvents()) { if (DEBUG_DISPLAY) { Slog.d(TAG, "Registering PointerEventListener for DisplayId: " + displayId); } dc.mTapDetector = new TaskTapPointerEventListener(mService, dc); mService.registerPointerEventListener(dc.mTapDetector); if (displayId == DEFAULT_DISPLAY) { mService.registerPointerEventListener(mService.mMousePositionTracker); } } } return dc; Loading