Merge "Accept null subtype in InputMethodSubtypeHandle." into nyc-dev

This commit is contained in:
Yohei Yukawa
2016-04-21 17:11:53 +00:00
committed by Android (Google) Code Review
3 changed files with 12 additions and 8 deletions

View File

@@ -19,6 +19,7 @@ package android.hardware.input;
import com.android.internal.os.SomeArgs; import com.android.internal.os.SomeArgs;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.SdkConstant; import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context; import android.content.Context;
@@ -644,14 +645,16 @@ public final class InputManager {
* *
* @param identifier The identifier for the input device. * @param identifier The identifier for the input device.
* @param inputMethodInfo The input method. * @param inputMethodInfo The input method.
* @param inputMethodSubtype The input method subtype. * @param inputMethodSubtype The input method subtype. {@code null} if this input method does
* not support any subtype.
* *
* @return The associated {@link KeyboardLayout}, or null if one has not been set. * @return The associated {@link KeyboardLayout}, or null if one has not been set.
* *
* @hide * @hide
*/ */
@Nullable
public KeyboardLayout getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, public KeyboardLayout getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
InputMethodInfo inputMethodInfo, InputMethodSubtype inputMethodSubtype) { InputMethodInfo inputMethodInfo, @Nullable InputMethodSubtype inputMethodSubtype) {
try { try {
return mIm.getKeyboardLayoutForInputDevice( return mIm.getKeyboardLayoutForInputDevice(
identifier, inputMethodInfo, inputMethodSubtype); identifier, inputMethodInfo, inputMethodSubtype);
@@ -666,13 +669,13 @@ public final class InputManager {
* @param identifier The identifier for the input device. * @param identifier The identifier for the input device.
* @param inputMethodInfo The input method with which to associate the keyboard layout. * @param inputMethodInfo The input method with which to associate the keyboard layout.
* @param inputMethodSubtype The input method subtype which which to associate the keyboard * @param inputMethodSubtype The input method subtype which which to associate the keyboard
* layout. * layout. {@code null} if this input method does not support any subtype.
* @param keyboardLayoutDescriptor The descriptor of the keyboard layout to set * @param keyboardLayoutDescriptor The descriptor of the keyboard layout to set
* *
* @hide * @hide
*/ */
public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
InputMethodInfo inputMethodInfo, InputMethodSubtype inputMethodSubtype, InputMethodInfo inputMethodInfo, @Nullable InputMethodSubtype inputMethodSubtype,
String keyboardLayoutDescriptor) { String keyboardLayoutDescriptor) {
try { try {
mIm.setKeyboardLayoutForInputDevice(identifier, inputMethodInfo, mIm.setKeyboardLayoutForInputDevice(identifier, inputMethodInfo,

View File

@@ -16,6 +16,7 @@
package com.android.internal.inputmethod; package com.android.internal.inputmethod;
import android.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
@@ -26,12 +27,12 @@ public class InputMethodSubtypeHandle {
private final String mInputMethodId; private final String mInputMethodId;
private final int mSubtypeId; private final int mSubtypeId;
public InputMethodSubtypeHandle(InputMethodInfo info, InputMethodSubtype subtype) { public InputMethodSubtypeHandle(InputMethodInfo info, @Nullable InputMethodSubtype subtype) {
mInputMethodId = info.getId(); mInputMethodId = info.getId();
if (subtype != null) { if (subtype != null) {
mSubtypeId = subtype.hashCode(); mSubtypeId = subtype.hashCode();
} else { } else {
mSubtypeId = 0; mSubtypeId = InputMethodUtils.NOT_A_SUBTYPE_ID;
} }
} }

View File

@@ -1349,8 +1349,8 @@ public class InputManagerService extends IInputManager.Stub
if (keyboardLayoutDescriptor == null) { if (keyboardLayoutDescriptor == null) {
throw new IllegalArgumentException("keyboardLayoutDescriptor must not be null"); throw new IllegalArgumentException("keyboardLayoutDescriptor must not be null");
} }
if (imeInfo == null || imeSubtype == null) { if (imeInfo == null) {
throw new IllegalArgumentException("imeInfo and imeSubtype must not be null"); throw new IllegalArgumentException("imeInfo must not be null");
} }
InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(imeInfo, imeSubtype); InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(imeInfo, imeSubtype);
setKeyboardLayoutForInputDeviceInner(identifier, handle, keyboardLayoutDescriptor); setKeyboardLayoutForInputDeviceInner(identifier, handle, keyboardLayoutDescriptor);