Loading core/java/android/hardware/input/AidlKeyGestureEvent.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright 2024 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 android.hardware.input; /** @hide */ @JavaDerive(equals=true) parcelable AidlKeyGestureEvent { int deviceId; int[] keycodes; int modifierState; int gestureType; int action; int displayId; int flags; } core/java/android/hardware/input/IInputManager.aidl +11 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.hardware.input.IInputDeviceBatteryState; import android.hardware.input.IKeyboardBacklightListener; import android.hardware.input.IKeyboardBacklightState; import android.hardware.input.IKeyGestureEventListener; import android.hardware.input.IKeyGestureHandler; import android.hardware.input.IStickyModifierStateListener; import android.hardware.input.ITabletModeChangedListener; import android.hardware.input.KeyboardLayoutSelectionResult; Loading Loading @@ -250,4 +251,14 @@ interface IInputManager { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " + "android.Manifest.permission.MANAGE_KEY_GESTURES)") void unregisterKeyGestureEventListener(IKeyGestureEventListener listener); @PermissionManuallyEnforced @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " + "android.Manifest.permission.MANAGE_KEY_GESTURES)") void registerKeyGestureHandler(IKeyGestureHandler handler); @PermissionManuallyEnforced @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " + "android.Manifest.permission.MANAGE_KEY_GESTURES)") void unregisterKeyGestureHandler(IKeyGestureHandler handler); } core/java/android/hardware/input/IKeyGestureEventListener.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ package android.hardware.input; import android.hardware.input.AidlKeyGestureEvent; /** @hide */ oneway interface IKeyGestureEventListener { /** * Called when a key gesture event occurs. */ void onKeyGestureEvent(int deviceId, in int[] keycodes, int modifierState, int shortcut); void onKeyGestureEvent(in AidlKeyGestureEvent event); } core/java/android/hardware/input/IKeyGestureHandler.aidl 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright 2024 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 android.hardware.input; import android.hardware.input.AidlKeyGestureEvent; import android.os.IBinder; /** @hide */ interface IKeyGestureHandler { /** * Called when a key gesture starts, ends, or is cancelled. If a handler returns {@code true}, * it means they intend to handle the full gesture and should handle all the events pertaining * to that gesture. */ boolean handleKeyGesture(in AidlKeyGestureEvent event, in IBinder focusedToken); /** * Called to know if a particular gesture type is supported by the handler. * * TODO(b/358569822): Remove this call to reduce the binder calls to single call for * handleKeyGesture. For this we need to remove dependency of multi-key gestures to identify if * a key gesture is supported on first relevant key down. * Also, for now we prioritize handlers in the system server process above external handlers to * reduce IPC binder calls. */ boolean isKeyGestureSupported(int gestureType); } core/java/android/hardware/input/InputManager.java +58 −0 Original line number Diff line number Diff line Loading @@ -1405,6 +1405,33 @@ public final class InputManager { mGlobal.unregisterKeyGestureEventListener(listener); } /** * Registers a key gesture event handler for {@link KeyGestureEvent} handling. * * @param handler the {@link KeyGestureEventHandler} * @throws IllegalArgumentException if {@code handler} has already been registered previously. * @throws NullPointerException if {@code handler} or {@code executor} is null. * @hide * @see #unregisterKeyGestureEventHandler(KeyGestureEventHandler) */ @RequiresPermission(Manifest.permission.MANAGE_KEY_GESTURES) public void registerKeyGestureEventHandler(@NonNull KeyGestureEventHandler handler) throws IllegalArgumentException { mGlobal.registerKeyGestureEventHandler(handler); } /** * Unregisters a previously added key gesture event handler. * * @param handler the {@link KeyGestureEventHandler} * @hide * @see #registerKeyGestureEventHandler(KeyGestureEventHandler) */ @RequiresPermission(Manifest.permission.MANAGE_KEY_GESTURES) public void unregisterKeyGestureEventHandler(@NonNull KeyGestureEventHandler handler) { mGlobal.unregisterKeyGestureEventHandler(handler); } /** * A callback used to be notified about battery state changes for an input device. The * {@link #onBatteryStateChanged(int, long, BatteryState)} method will be called once after the Loading Loading @@ -1522,4 +1549,35 @@ public final class InputManager { */ void onKeyGestureEvent(@NonNull KeyGestureEvent event); } /** * A callback used to notify about key gesture event start, complete and cancel. Unlike * {@see KeyGestureEventListener} which is to listen to successfully handled key gestures, this * interface allows system components to register handler for handling key gestures. * * @see #registerKeyGestureEventHandler(KeyGestureEventHandler) * @see #unregisterKeyGestureEventHandler(KeyGestureEventHandler) * * <p> NOTE: All callbacks will occur on system main and input threads, so the caller needs * to move time-consuming operations to appropriate handler threads. * @hide */ public interface KeyGestureEventHandler { /** * Called when a key gesture event starts, is completed, or is cancelled. If a handler * returns {@code true}, it implies that the handler intends to handle the key gesture and * only this handler will receive the future events for this key gesture. * * @param event the gesture event */ boolean handleKeyGestureEvent(@NonNull KeyGestureEvent event, @Nullable IBinder focusedToken); /** * Called to identify if a particular gesture is of interest to a handler. * * NOTE: If no active handler supports certain gestures, the gestures will not be captured. */ boolean isKeyGestureSupported(@KeyGestureEvent.KeyGestureType int gestureType); } } Loading
core/java/android/hardware/input/AidlKeyGestureEvent.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * Copyright 2024 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 android.hardware.input; /** @hide */ @JavaDerive(equals=true) parcelable AidlKeyGestureEvent { int deviceId; int[] keycodes; int modifierState; int gestureType; int action; int displayId; int flags; }
core/java/android/hardware/input/IInputManager.aidl +11 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.hardware.input.IInputDeviceBatteryState; import android.hardware.input.IKeyboardBacklightListener; import android.hardware.input.IKeyboardBacklightState; import android.hardware.input.IKeyGestureEventListener; import android.hardware.input.IKeyGestureHandler; import android.hardware.input.IStickyModifierStateListener; import android.hardware.input.ITabletModeChangedListener; import android.hardware.input.KeyboardLayoutSelectionResult; Loading Loading @@ -250,4 +251,14 @@ interface IInputManager { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " + "android.Manifest.permission.MANAGE_KEY_GESTURES)") void unregisterKeyGestureEventListener(IKeyGestureEventListener listener); @PermissionManuallyEnforced @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " + "android.Manifest.permission.MANAGE_KEY_GESTURES)") void registerKeyGestureHandler(IKeyGestureHandler handler); @PermissionManuallyEnforced @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " + "android.Manifest.permission.MANAGE_KEY_GESTURES)") void unregisterKeyGestureHandler(IKeyGestureHandler handler); }
core/java/android/hardware/input/IKeyGestureEventListener.aidl +3 −1 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ package android.hardware.input; import android.hardware.input.AidlKeyGestureEvent; /** @hide */ oneway interface IKeyGestureEventListener { /** * Called when a key gesture event occurs. */ void onKeyGestureEvent(int deviceId, in int[] keycodes, int modifierState, int shortcut); void onKeyGestureEvent(in AidlKeyGestureEvent event); }
core/java/android/hardware/input/IKeyGestureHandler.aidl 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright 2024 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 android.hardware.input; import android.hardware.input.AidlKeyGestureEvent; import android.os.IBinder; /** @hide */ interface IKeyGestureHandler { /** * Called when a key gesture starts, ends, or is cancelled. If a handler returns {@code true}, * it means they intend to handle the full gesture and should handle all the events pertaining * to that gesture. */ boolean handleKeyGesture(in AidlKeyGestureEvent event, in IBinder focusedToken); /** * Called to know if a particular gesture type is supported by the handler. * * TODO(b/358569822): Remove this call to reduce the binder calls to single call for * handleKeyGesture. For this we need to remove dependency of multi-key gestures to identify if * a key gesture is supported on first relevant key down. * Also, for now we prioritize handlers in the system server process above external handlers to * reduce IPC binder calls. */ boolean isKeyGestureSupported(int gestureType); }
core/java/android/hardware/input/InputManager.java +58 −0 Original line number Diff line number Diff line Loading @@ -1405,6 +1405,33 @@ public final class InputManager { mGlobal.unregisterKeyGestureEventListener(listener); } /** * Registers a key gesture event handler for {@link KeyGestureEvent} handling. * * @param handler the {@link KeyGestureEventHandler} * @throws IllegalArgumentException if {@code handler} has already been registered previously. * @throws NullPointerException if {@code handler} or {@code executor} is null. * @hide * @see #unregisterKeyGestureEventHandler(KeyGestureEventHandler) */ @RequiresPermission(Manifest.permission.MANAGE_KEY_GESTURES) public void registerKeyGestureEventHandler(@NonNull KeyGestureEventHandler handler) throws IllegalArgumentException { mGlobal.registerKeyGestureEventHandler(handler); } /** * Unregisters a previously added key gesture event handler. * * @param handler the {@link KeyGestureEventHandler} * @hide * @see #registerKeyGestureEventHandler(KeyGestureEventHandler) */ @RequiresPermission(Manifest.permission.MANAGE_KEY_GESTURES) public void unregisterKeyGestureEventHandler(@NonNull KeyGestureEventHandler handler) { mGlobal.unregisterKeyGestureEventHandler(handler); } /** * A callback used to be notified about battery state changes for an input device. The * {@link #onBatteryStateChanged(int, long, BatteryState)} method will be called once after the Loading Loading @@ -1522,4 +1549,35 @@ public final class InputManager { */ void onKeyGestureEvent(@NonNull KeyGestureEvent event); } /** * A callback used to notify about key gesture event start, complete and cancel. Unlike * {@see KeyGestureEventListener} which is to listen to successfully handled key gestures, this * interface allows system components to register handler for handling key gestures. * * @see #registerKeyGestureEventHandler(KeyGestureEventHandler) * @see #unregisterKeyGestureEventHandler(KeyGestureEventHandler) * * <p> NOTE: All callbacks will occur on system main and input threads, so the caller needs * to move time-consuming operations to appropriate handler threads. * @hide */ public interface KeyGestureEventHandler { /** * Called when a key gesture event starts, is completed, or is cancelled. If a handler * returns {@code true}, it implies that the handler intends to handle the key gesture and * only this handler will receive the future events for this key gesture. * * @param event the gesture event */ boolean handleKeyGestureEvent(@NonNull KeyGestureEvent event, @Nullable IBinder focusedToken); /** * Called to identify if a particular gesture is of interest to a handler. * * NOTE: If no active handler supports certain gestures, the gestures will not be captured. */ boolean isKeyGestureSupported(@KeyGestureEvent.KeyGestureType int gestureType); } }