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