Loading core/java/android/hardware/input/IInputManager.aidl +16 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.hardware.lights.LightState; import android.os.IBinder; import android.os.IVibratorStateListener; import android.os.VibrationEffect; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import android.view.InputDevice; import android.view.InputEvent; import android.view.InputMonitor; Loading Loading @@ -107,6 +109,20 @@ interface IInputManager { void removeKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, String keyboardLayoutDescriptor); // New Keyboard layout config APIs String getKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype); @EnforcePermission("SET_KEYBOARD_LAYOUT") @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " + "android.Manifest.permission.SET_KEYBOARD_LAYOUT)") void setKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor); String[] getKeyboardLayoutListForInputDevice(in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype); // Registers an input devices changed listener. void registerInputDevicesChangedListener(IInputDevicesChangedListener listener); Loading core/java/android/hardware/input/InputManager.java +88 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemService; import android.annotation.TestApi; import android.annotation.UserIdInt; import android.app.ActivityThread; import android.compat.annotation.ChangeId; import android.compat.annotation.UnsupportedAppUsage; Loading Loading @@ -66,6 +67,8 @@ import android.view.MotionEvent; import android.view.PointerIcon; import android.view.VerifiedInputEvent; import android.view.WindowManager.LayoutParams; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -888,6 +891,91 @@ public final class InputManager { } } /** * Gets the keyboard layout descriptor for the specified input device, userId, imeInfo and * imeSubtype. * * @param identifier Identifier for the input device * @param userId user profile ID * @param imeInfo contains IME information like imeId, etc. * @param imeSubtype contains IME subtype information like input languageTag, layoutType, etc. * @return The keyboard layout descriptor, or null if no keyboard layout has been set. * * @hide */ @Nullable public String getKeyboardLayoutForInputDevice(@NonNull InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { try { return mIm.getKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * Sets the keyboard layout descriptor for the specified input device, userId, imeInfo and * imeSubtype. * * <p> * This method may have the side-effect of causing the input device in question to be * reconfigured. * </p> * * @param identifier The identifier for the input device. * @param userId user profile ID * @param imeInfo contains IME information like imeId, etc. * @param imeSubtype contains IME subtype information like input languageTag, layoutType, etc. * @param keyboardLayoutDescriptor The keyboard layout descriptor to use, must not be null. * * @hide */ @RequiresPermission(Manifest.permission.SET_KEYBOARD_LAYOUT) public void setKeyboardLayoutForInputDevice(@NonNull InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype, @NonNull String keyboardLayoutDescriptor) { if (identifier == null) { throw new IllegalArgumentException("identifier must not be null"); } if (keyboardLayoutDescriptor == null) { throw new IllegalArgumentException("keyboardLayoutDescriptor must not be null"); } try { mIm.setKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype, keyboardLayoutDescriptor); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * Gets all keyboard layout descriptors that are enabled for the specified input device, userId, * imeInfo and imeSubtype. * * @param identifier The identifier for the input device. * @param userId user profile ID * @param imeInfo contains IME information like imeId, etc. * @param imeSubtype contains IME subtype information like input languageTag, layoutType, etc. * @return The keyboard layout descriptors. * * @hide */ public String[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { if (identifier == null) { throw new IllegalArgumentException("inputDeviceDescriptor must not be null"); } try { return mIm.getKeyboardLayoutListForInputDevice(identifier, userId, imeInfo, imeSubtype); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * Gets the mouse pointer speed. * <p> Loading services/core/java/com/android/server/input/InputManagerService.java +28 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ import android.view.Surface; import android.view.SurfaceControl; import android.view.VerifiedInputEvent; import android.view.ViewConfiguration; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.R; Loading Loading @@ -1184,6 +1185,33 @@ public class InputManagerService extends IInputManager.Stub keyboardLayoutDescriptor); } @Override // Binder call public String getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { return mKeyboardLayoutManager.getKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype); } @EnforcePermission(Manifest.permission.SET_KEYBOARD_LAYOUT) @Override // Binder call public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor) { super.setKeyboardLayoutForInputDevice_enforcePermission(); mKeyboardLayoutManager.setKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype, keyboardLayoutDescriptor); } @Override // Binder call public String[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { return mKeyboardLayoutManager.getKeyboardLayoutListForInputDevice(identifier, userId, imeInfo, imeSubtype); } public void switchKeyboardLayout(int deviceId, int direction) { mKeyboardLayoutManager.switchKeyboardLayout(deviceId, direction); } Loading services/core/java/com/android/server/input/KeyboardLayoutManager.java +32 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.input; import android.annotation.NonNull; import android.annotation.UserIdInt; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; Loading Loading @@ -46,6 +47,8 @@ import android.text.TextUtils; import android.util.Log; import android.util.Slog; import android.view.InputDevice; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import android.widget.Toast; import com.android.internal.R; Loading Loading @@ -545,6 +548,35 @@ final class KeyboardLayoutManager implements InputManager.InputDeviceListener { } } public String getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { // TODO(b/259530132): Implement the new keyboard layout API: Returning non-IME specific // layout for now. return getCurrentKeyboardLayoutForInputDevice(identifier); } public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor) { // TODO(b/259530132): Implement the new keyboard layout API: setting non-IME specific // layout for now. setCurrentKeyboardLayoutForInputDevice(identifier, keyboardLayoutDescriptor); } public String[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { // TODO(b/259530132): Implement the new keyboard layout API: Returning list of all // layouts for now. KeyboardLayout[] allLayouts = getKeyboardLayouts(); String[] allLayoutDesc = new String[allLayouts.length]; for (int i = 0; i < allLayouts.length; i++) { allLayoutDesc[i] = allLayouts[i].getDescriptor(); } return allLayoutDesc; } public void switchKeyboardLayout(int deviceId, int direction) { mHandler.obtainMessage(MSG_SWITCH_KEYBOARD_LAYOUT, deviceId, direction).sendToTarget(); } Loading Loading
core/java/android/hardware/input/IInputManager.aidl +16 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.hardware.lights.LightState; import android.os.IBinder; import android.os.IVibratorStateListener; import android.os.VibrationEffect; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import android.view.InputDevice; import android.view.InputEvent; import android.view.InputMonitor; Loading Loading @@ -107,6 +109,20 @@ interface IInputManager { void removeKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, String keyboardLayoutDescriptor); // New Keyboard layout config APIs String getKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype); @EnforcePermission("SET_KEYBOARD_LAYOUT") @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " + "android.Manifest.permission.SET_KEYBOARD_LAYOUT)") void setKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor); String[] getKeyboardLayoutListForInputDevice(in InputDeviceIdentifier identifier, int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype); // Registers an input devices changed listener. void registerInputDevicesChangedListener(IInputDevicesChangedListener listener); Loading
core/java/android/hardware/input/InputManager.java +88 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemService; import android.annotation.TestApi; import android.annotation.UserIdInt; import android.app.ActivityThread; import android.compat.annotation.ChangeId; import android.compat.annotation.UnsupportedAppUsage; Loading Loading @@ -66,6 +67,8 @@ import android.view.MotionEvent; import android.view.PointerIcon; import android.view.VerifiedInputEvent; import android.view.WindowManager.LayoutParams; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -888,6 +891,91 @@ public final class InputManager { } } /** * Gets the keyboard layout descriptor for the specified input device, userId, imeInfo and * imeSubtype. * * @param identifier Identifier for the input device * @param userId user profile ID * @param imeInfo contains IME information like imeId, etc. * @param imeSubtype contains IME subtype information like input languageTag, layoutType, etc. * @return The keyboard layout descriptor, or null if no keyboard layout has been set. * * @hide */ @Nullable public String getKeyboardLayoutForInputDevice(@NonNull InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { try { return mIm.getKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * Sets the keyboard layout descriptor for the specified input device, userId, imeInfo and * imeSubtype. * * <p> * This method may have the side-effect of causing the input device in question to be * reconfigured. * </p> * * @param identifier The identifier for the input device. * @param userId user profile ID * @param imeInfo contains IME information like imeId, etc. * @param imeSubtype contains IME subtype information like input languageTag, layoutType, etc. * @param keyboardLayoutDescriptor The keyboard layout descriptor to use, must not be null. * * @hide */ @RequiresPermission(Manifest.permission.SET_KEYBOARD_LAYOUT) public void setKeyboardLayoutForInputDevice(@NonNull InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype, @NonNull String keyboardLayoutDescriptor) { if (identifier == null) { throw new IllegalArgumentException("identifier must not be null"); } if (keyboardLayoutDescriptor == null) { throw new IllegalArgumentException("keyboardLayoutDescriptor must not be null"); } try { mIm.setKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype, keyboardLayoutDescriptor); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * Gets all keyboard layout descriptors that are enabled for the specified input device, userId, * imeInfo and imeSubtype. * * @param identifier The identifier for the input device. * @param userId user profile ID * @param imeInfo contains IME information like imeId, etc. * @param imeSubtype contains IME subtype information like input languageTag, layoutType, etc. * @return The keyboard layout descriptors. * * @hide */ public String[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { if (identifier == null) { throw new IllegalArgumentException("inputDeviceDescriptor must not be null"); } try { return mIm.getKeyboardLayoutListForInputDevice(identifier, userId, imeInfo, imeSubtype); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * Gets the mouse pointer speed. * <p> Loading
services/core/java/com/android/server/input/InputManagerService.java +28 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,7 @@ import android.view.Surface; import android.view.SurfaceControl; import android.view.VerifiedInputEvent; import android.view.ViewConfiguration; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.R; Loading Loading @@ -1184,6 +1185,33 @@ public class InputManagerService extends IInputManager.Stub keyboardLayoutDescriptor); } @Override // Binder call public String getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { return mKeyboardLayoutManager.getKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype); } @EnforcePermission(Manifest.permission.SET_KEYBOARD_LAYOUT) @Override // Binder call public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor) { super.setKeyboardLayoutForInputDevice_enforcePermission(); mKeyboardLayoutManager.setKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype, keyboardLayoutDescriptor); } @Override // Binder call public String[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { return mKeyboardLayoutManager.getKeyboardLayoutListForInputDevice(identifier, userId, imeInfo, imeSubtype); } public void switchKeyboardLayout(int deviceId, int direction) { mKeyboardLayoutManager.switchKeyboardLayout(deviceId, direction); } Loading
services/core/java/com/android/server/input/KeyboardLayoutManager.java +32 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.input; import android.annotation.NonNull; import android.annotation.UserIdInt; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; Loading Loading @@ -46,6 +47,8 @@ import android.text.TextUtils; import android.util.Log; import android.util.Slog; import android.view.InputDevice; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; import android.widget.Toast; import com.android.internal.R; Loading Loading @@ -545,6 +548,35 @@ final class KeyboardLayoutManager implements InputManager.InputDeviceListener { } } public String getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { // TODO(b/259530132): Implement the new keyboard layout API: Returning non-IME specific // layout for now. return getCurrentKeyboardLayoutForInputDevice(identifier); } public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor) { // TODO(b/259530132): Implement the new keyboard layout API: setting non-IME specific // layout for now. setCurrentKeyboardLayoutForInputDevice(identifier, keyboardLayoutDescriptor); } public String[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, @NonNull InputMethodSubtype imeSubtype) { // TODO(b/259530132): Implement the new keyboard layout API: Returning list of all // layouts for now. KeyboardLayout[] allLayouts = getKeyboardLayouts(); String[] allLayoutDesc = new String[allLayouts.length]; for (int i = 0; i < allLayouts.length; i++) { allLayoutDesc[i] = allLayouts[i].getDescriptor(); } return allLayoutDesc; } public void switchKeyboardLayout(int deviceId, int direction) { mHandler.obtainMessage(MSG_SWITCH_KEYBOARD_LAYOUT, deviceId, direction).sendToTarget(); } Loading