Merge "Change API to return KeyboardLayout[] to reduce IPC calls"

This commit is contained in:
Vaibhav Devmurari
2022-12-13 12:37:29 +00:00
committed by Android (Google) Code Review
4 changed files with 18 additions and 22 deletions

View File

@@ -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")

View File

@@ -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");
}

View File

@@ -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);
}

View File

@@ -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) {