diff --git a/core/java/android/hardware/input/IInputManager.aidl b/core/java/android/hardware/input/IInputManager.aidl index eef0f421d29f2..6314cabd298dd 100644 --- a/core/java/android/hardware/input/IInputManager.aidl +++ b/core/java/android/hardware/input/IInputManager.aidl @@ -120,8 +120,8 @@ interface IInputManager { in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor); - String[] getKeyboardLayoutListForInputDevice(in InputDeviceIdentifier identifier, int userId, - in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype); + KeyboardLayout[] getKeyboardLayoutListForInputDevice(in InputDeviceIdentifier identifier, + int userId, in InputMethodInfo imeInfo, in InputMethodSubtype imeSubtype); // Modifier key remapping APIs. @EnforcePermission("REMAP_MODIFIER_KEYS") diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index a616014b1b84e..2eeae46645c5d 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -986,7 +986,7 @@ public final class InputManager { @Nullable public String getKeyboardLayoutForInputDevice(@NonNull InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, - @NonNull InputMethodSubtype imeSubtype) { + @Nullable InputMethodSubtype imeSubtype) { try { return mIm.getKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype); } catch (RemoteException ex) { @@ -1014,7 +1014,7 @@ public final class InputManager { @RequiresPermission(Manifest.permission.SET_KEYBOARD_LAYOUT) public void setKeyboardLayoutForInputDevice(@NonNull InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, - @NonNull InputMethodSubtype imeSubtype, @NonNull String keyboardLayoutDescriptor) { + @Nullable InputMethodSubtype imeSubtype, @NonNull String keyboardLayoutDescriptor) { if (identifier == null) { throw new IllegalArgumentException("identifier must not be null"); } @@ -1031,8 +1031,8 @@ public final class InputManager { } /** - * Gets all keyboard layout descriptors that are enabled for the specified input device, userId, - * imeInfo and imeSubtype. + * Gets all keyboard layouts 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 @@ -1042,9 +1042,9 @@ public final class InputManager { * * @hide */ - public String[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, + public KeyboardLayout[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, - @NonNull InputMethodSubtype imeSubtype) { + @Nullable InputMethodSubtype imeSubtype) { if (identifier == null) { throw new IllegalArgumentException("inputDeviceDescriptor must not be null"); } diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index 0da04a22d31f6..c62abf004daae 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -1193,7 +1193,7 @@ public class InputManagerService extends IInputManager.Stub @Override // Binder call public String getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, - @NonNull InputMethodSubtype imeSubtype) { + @Nullable InputMethodSubtype imeSubtype) { return mKeyboardLayoutManager.getKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype); } @@ -1202,16 +1202,16 @@ public class InputManagerService extends IInputManager.Stub @Override // Binder call public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, - @NonNull InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor) { + @Nullable InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor) { super.setKeyboardLayoutForInputDevice_enforcePermission(); mKeyboardLayoutManager.setKeyboardLayoutForInputDevice(identifier, userId, imeInfo, imeSubtype, keyboardLayoutDescriptor); } @Override // Binder call - public String[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, + public KeyboardLayout[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, - @NonNull InputMethodSubtype imeSubtype) { + @Nullable InputMethodSubtype imeSubtype) { return mKeyboardLayoutManager.getKeyboardLayoutListForInputDevice(identifier, userId, imeInfo, imeSubtype); } diff --git a/services/core/java/com/android/server/input/KeyboardLayoutManager.java b/services/core/java/com/android/server/input/KeyboardLayoutManager.java index 1bb14aa6c4388..d76da8326335f 100644 --- a/services/core/java/com/android/server/input/KeyboardLayoutManager.java +++ b/services/core/java/com/android/server/input/KeyboardLayoutManager.java @@ -17,6 +17,7 @@ package com.android.server.input; import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.Notification; import android.app.NotificationManager; @@ -550,7 +551,7 @@ final class KeyboardLayoutManager implements InputManager.InputDeviceListener { public String getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, - @NonNull InputMethodSubtype imeSubtype) { + @Nullable InputMethodSubtype imeSubtype) { // TODO(b/259530132): Implement the new keyboard layout API: Returning non-IME specific // layout for now. return getCurrentKeyboardLayoutForInputDevice(identifier); @@ -558,23 +559,18 @@ final class KeyboardLayoutManager implements InputManager.InputDeviceListener { public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, - @NonNull InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor) { + @Nullable 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, + public KeyboardLayout[] getKeyboardLayoutListForInputDevice(InputDeviceIdentifier identifier, @UserIdInt int userId, @NonNull InputMethodInfo imeInfo, - @NonNull InputMethodSubtype imeSubtype) { + @Nullable 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; + return getKeyboardLayouts(); } public void switchKeyboardLayout(int deviceId, int direction) {