Search in sources :

Example 6 with InputDeviceIdentifier

use of android.hardware.input.InputDeviceIdentifier 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 7 with InputDeviceIdentifier

use of android.hardware.input.InputDeviceIdentifier in project android_frameworks_base by ResurrectionRemix.

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 8 with InputDeviceIdentifier

use of android.hardware.input.InputDeviceIdentifier in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndLanguageSettings method updateHardKeyboards.

private void updateHardKeyboards() {
    if (mHardKeyboardCategory == null) {
        return;
    }
    mHardKeyboardPreferenceList.clear();
    final int[] devices = InputDevice.getDeviceIds();
    for (int i = 0; i < devices.length; i++) {
        InputDevice device = InputDevice.getDevice(devices[i]);
        if (device != null && !device.isVirtual() && device.isFullKeyboard()) {
            final InputDeviceIdentifier identifier = device.getIdentifier();
            final String keyboardLayoutDescriptor = mIm.getCurrentKeyboardLayoutForInputDevice(identifier);
            final KeyboardLayout keyboardLayout = keyboardLayoutDescriptor != null ? mIm.getKeyboardLayout(keyboardLayoutDescriptor) : null;
            final PreferenceScreen pref = new PreferenceScreen(getPrefContext(), null);
            pref.setTitle(device.getName());
            if (keyboardLayout != null) {
                pref.setSummary(keyboardLayout.toString());
            } else {
                pref.setSummary(R.string.keyboard_layout_default_label);
            }
            pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    showKeyboardLayoutDialog(identifier);
                    return true;
                }
            });
            mHardKeyboardPreferenceList.add(pref);
        }
    }
    if (!mHardKeyboardPreferenceList.isEmpty()) {
        for (int i = mHardKeyboardCategory.getPreferenceCount(); i-- > 0; ) {
            final Preference pref = mHardKeyboardCategory.getPreference(i);
            if (pref.getOrder() < 1000) {
                mHardKeyboardCategory.removePreference(pref);
            }
        }
        Collections.sort(mHardKeyboardPreferenceList);
        final int count = mHardKeyboardPreferenceList.size();
        for (int i = 0; i < count; i++) {
            final Preference pref = mHardKeyboardPreferenceList.get(i);
            pref.setOrder(i);
            mHardKeyboardCategory.addPreference(pref);
        }
        getPreferenceScreen().addPreference(mHardKeyboardCategory);
    } else {
        getPreferenceScreen().removePreference(mHardKeyboardCategory);
    }
}
Also used : InputDeviceIdentifier(android.hardware.input.InputDeviceIdentifier) InputDevice(android.view.InputDevice) PreferenceScreen(android.support.v7.preference.PreferenceScreen) OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) KeyboardLayout(android.hardware.input.KeyboardLayout)

Aggregations

InputDeviceIdentifier (android.hardware.input.InputDeviceIdentifier)8 InputMethodSubtypeHandle (com.android.internal.inputmethod.InputMethodSubtypeHandle)5 SwitchPreference (android.support.v14.preference.SwitchPreference)2 ListPreference (android.support.v7.preference.ListPreference)2 Preference (android.support.v7.preference.Preference)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 KeyboardLayout (android.hardware.input.KeyboardLayout)1 Handler (android.os.Handler)1 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 InputDevice (android.view.InputDevice)1 KeyboardLayoutPickerActivity (com.android.settings.Settings.KeyboardLayoutPickerActivity)1 SettingsActivity (com.android.settings.SettingsActivity)1 VoiceInputOutputSettings (com.android.settings.VoiceInputOutputSettings)1