Show touchpad entry when input device is detected as touchpad.
1. Remove the redundant part about active ime. 2. Add a NPE detector to fix bug. 3. Check if input device is detected as touchpad. Bug: 247080509 Bug: 267092726 Test: manual Change-Id: I40640e42abd471efde6d1f9166b8999243499c62
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
package com.android.settings.inputmethod;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.view.InputDevice;
|
||||
import android.view.inputmethod.InputMethodInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
@@ -38,17 +38,18 @@ public class NewKeyboardSettingsUtils {
|
||||
static final String EXTRA_INPUT_METHOD_INFO = "input_method_info";
|
||||
static final String EXTRA_INPUT_METHOD_SUBTYPE = "input_method_subtype";
|
||||
|
||||
static InputMethodInfo getActiveIme(Context context, InputMethodManager imm) {
|
||||
InputMethodInfo activeIme = null;
|
||||
List<InputMethodInfo> infoList = imm.getEnabledInputMethodList();
|
||||
String imeId = Settings.Secure.getStringForUser(context.getContentResolver(),
|
||||
Settings.Secure.DEFAULT_INPUT_METHOD, context.getUserId());
|
||||
for (InputMethodInfo method : infoList) {
|
||||
if (method.getId().equals(imeId)) {
|
||||
activeIme = method;
|
||||
static boolean isTouchpad() {
|
||||
for (int deviceId : InputDevice.getDeviceIds()) {
|
||||
final InputDevice device = InputDevice.getDevice(deviceId);
|
||||
if (device == null) {
|
||||
continue;
|
||||
}
|
||||
if ((device.getSources() & InputDevice.SOURCE_TOUCHPAD)
|
||||
== InputDevice.SOURCE_TOUCHPAD) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return activeIme;
|
||||
return false;
|
||||
}
|
||||
|
||||
static List<String> getSuitableImeLabels(Context context, InputMethodManager imm, int userId) {
|
||||
|
||||
Reference in New Issue
Block a user