Set preference visible to false when there is no keyboard.

1. Physical keyboard settings should only show up if at least one PK is connected.
2. Update tests.
3. Fix NullPointerException.

Bug: 269983475
Bug: 270109384
Bug: 271357910
Test: atest and manual
Change-Id: If7798587fb386dbf669fc249cab304d91a26879b
This commit is contained in:
danielwbhuang
2023-02-24 18:16:30 +08:00
parent fa57dd3f2e
commit 1f3261467d
11 changed files with 93 additions and 48 deletions

View File

@@ -68,6 +68,9 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
}
private void updateCheckedState() {
if (NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
return;
}
PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removeAll();
List<InputMethodInfo> infoList = mImm.getEnabledInputMethodListAsUser(mUserId);
@@ -174,8 +177,8 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
public void onStart() {
super.onStart();
mIm.registerInputDeviceListener(this, null);
final InputDevice inputDevice =
mIm.getInputDeviceByDescriptor(mInputDeviceIdentifier.getDescriptor());
InputDevice inputDevice =
NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
if (inputDevice == null) {
getActivity().finish();
return;