Search in sources :

Example 1 with InputMethodSubtypeHandle

use of com.android.internal.inputmethod.InputMethodSubtypeHandle in project platform_frameworks_base by android.

the class InputManagerService method getKeyboardLayoutForInputDevice.

// Binder call
@Override
@Nullable
public KeyboardLayout getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, InputMethodInfo imeInfo, InputMethodSubtype imeSubtype) {
    InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(imeInfo, imeSubtype);
    String key = getLayoutDescriptor(identifier);
    final String keyboardLayoutDescriptor;
    synchronized (mDataStore) {
        keyboardLayoutDescriptor = mDataStore.getKeyboardLayout(key, handle);
    }
    if (keyboardLayoutDescriptor == null) {
        return null;
    }
    final KeyboardLayout[] result = new KeyboardLayout[1];
    visitKeyboardLayout(keyboardLayoutDescriptor, new KeyboardLayoutVisitor() {

        @Override
        public void visitKeyboardLayout(Resources resources, int keyboardLayoutResId, KeyboardLayout layout) {
            result[0] = layout;
        }
    });
    if (result[0] == null) {
        Slog.w(TAG, "Could not get keyboard layout with descriptor '" + keyboardLayoutDescriptor + "'.");
    }
    return result[0];
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle) KeyboardLayout(android.hardware.input.KeyboardLayout) Resources(android.content.res.Resources) Nullable(android.annotation.Nullable)

Example 2 with InputMethodSubtypeHandle

use of com.android.internal.inputmethod.InputMethodSubtypeHandle in project platform_frameworks_base by android.

the class InputManagerService method setKeyboardLayoutForInputDevice.

@Override
public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, InputMethodInfo imeInfo, InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor) {
    if (!checkCallingPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT, "setKeyboardLayoutForInputDevice()")) {
        throw new SecurityException("Requires SET_KEYBOARD_LAYOUT permission");
    }
    if (keyboardLayoutDescriptor == null) {
        throw new IllegalArgumentException("keyboardLayoutDescriptor must not be null");
    }
    if (imeInfo == null) {
        throw new IllegalArgumentException("imeInfo must not be null");
    }
    InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(imeInfo, imeSubtype);
    setKeyboardLayoutForInputDeviceInner(identifier, handle, keyboardLayoutDescriptor);
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle)

Example 3 with InputMethodSubtypeHandle

use of com.android.internal.inputmethod.InputMethodSubtypeHandle in project android_frameworks_base by ResurrectionRemix.

the class InputManagerService method getKeyboardLayoutForInputDevice.

// Binder call
@Override
@Nullable
public KeyboardLayout getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, InputMethodInfo imeInfo, InputMethodSubtype imeSubtype) {
    InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(imeInfo, imeSubtype);
    String key = getLayoutDescriptor(identifier);
    final String keyboardLayoutDescriptor;
    synchronized (mDataStore) {
        keyboardLayoutDescriptor = mDataStore.getKeyboardLayout(key, handle);
    }
    if (keyboardLayoutDescriptor == null) {
        return null;
    }
    final KeyboardLayout[] result = new KeyboardLayout[1];
    visitKeyboardLayout(keyboardLayoutDescriptor, new KeyboardLayoutVisitor() {

        @Override
        public void visitKeyboardLayout(Resources resources, int keyboardLayoutResId, KeyboardLayout layout) {
            result[0] = layout;
        }
    });
    if (result[0] == null) {
        Slog.w(TAG, "Could not get keyboard layout with descriptor '" + keyboardLayoutDescriptor + "'.");
    }
    return result[0];
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle) KeyboardLayout(android.hardware.input.KeyboardLayout) Resources(android.content.res.Resources) Nullable(android.annotation.Nullable)

Example 4 with InputMethodSubtypeHandle

use of com.android.internal.inputmethod.InputMethodSubtypeHandle in project android_frameworks_base by ResurrectionRemix.

the class InputManagerService method setKeyboardLayoutForInputDevice.

@Override
public void setKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, InputMethodInfo imeInfo, InputMethodSubtype imeSubtype, String keyboardLayoutDescriptor) {
    if (!checkCallingPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT, "setKeyboardLayoutForInputDevice()")) {
        throw new SecurityException("Requires SET_KEYBOARD_LAYOUT permission");
    }
    if (keyboardLayoutDescriptor == null) {
        throw new IllegalArgumentException("keyboardLayoutDescriptor must not be null");
    }
    if (imeInfo == null) {
        throw new IllegalArgumentException("imeInfo must not be null");
    }
    InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(imeInfo, imeSubtype);
    setKeyboardLayoutForInputDeviceInner(identifier, handle, keyboardLayoutDescriptor);
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle)

Example 5 with InputMethodSubtypeHandle

use of com.android.internal.inputmethod.InputMethodSubtypeHandle in project android_frameworks_base by DirtyUnicorns.

the class InputManagerService method onShellCommand.

public int onShellCommand(Shell shell, String cmd) {
    if (TextUtils.isEmpty(cmd)) {
        shell.onHelp();
        return 1;
    }
    if (cmd.equals("setlayout")) {
        if (!checkCallingPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT, "onShellCommand()")) {
            throw new SecurityException("Requires SET_KEYBOARD_LAYOUT permission");
        }
        InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(shell.getNextArgRequired(), Integer.parseInt(shell.getNextArgRequired()));
        String descriptor = shell.getNextArgRequired();
        int vid = Integer.decode(shell.getNextArgRequired());
        int pid = Integer.decode(shell.getNextArgRequired());
        InputDeviceIdentifier id = new InputDeviceIdentifier(descriptor, vid, pid);
        setKeyboardLayoutForInputDeviceInner(id, handle, shell.getNextArgRequired());
    }
    return 0;
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle) InputDeviceIdentifier(android.hardware.input.InputDeviceIdentifier)

Aggregations

InputMethodSubtypeHandle (com.android.internal.inputmethod.InputMethodSubtypeHandle)20 Nullable (android.annotation.Nullable)5 Resources (android.content.res.Resources)5 InputDeviceIdentifier (android.hardware.input.InputDeviceIdentifier)5 KeyboardLayout (android.hardware.input.KeyboardLayout)5