Search in sources :

Example 11 with InputMethodSubtypeHandle

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

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 12 with InputMethodSubtypeHandle

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

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 13 with InputMethodSubtypeHandle

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

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)

Example 14 with InputMethodSubtypeHandle

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

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)

Example 15 with InputMethodSubtypeHandle

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

the class InputManagerService method handleSwitchInputMethodSubtype.

// Must be called on handler.
private void handleSwitchInputMethodSubtype(int userId, @Nullable InputMethodInfo inputMethodInfo, @Nullable InputMethodSubtype subtype) {
    if (DEBUG) {
        Slog.i(TAG, "InputMethodSubtype changed: userId=" + userId + " ime=" + inputMethodInfo + " subtype=" + subtype);
    }
    if (inputMethodInfo == null) {
        Slog.d(TAG, "No InputMethod is running, ignoring change");
        return;
    }
    if (subtype != null && !"keyboard".equals(subtype.getMode())) {
        Slog.d(TAG, "InputMethodSubtype changed to non-keyboard subtype, ignoring change");
        return;
    }
    InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(inputMethodInfo, subtype);
    if (!handle.equals(mCurrentImeHandle)) {
        mCurrentImeHandle = handle;
        handleSwitchKeyboardLayout(null, handle);
    }
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle)

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