Merge "Handle cached bluetooth device with stylus pref" into main

This commit is contained in:
Treehugger Robot
2023-11-21 12:59:39 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 8 deletions

View File

@@ -108,10 +108,15 @@ public class StylusDevicesController extends AbstractPreferenceController implem
return null;
}
boolean doesStylusSupportTailButton = mInputDevice.hasKeys(
KeyEvent.KEYCODE_STYLUS_BUTTON_TAIL)[0];
if (!doesStylusSupportTailButton) {
return null;
// Check if the connected stylus supports the tail button. A connected device is when input
// device is available (mInputDevice != null). For a cached device (mInputDevice == null)
// there isn't way to check if the device supports the button so assume it does.
if (mInputDevice != null) {
boolean doesStylusSupportTailButton =
mInputDevice.hasKeys(KeyEvent.KEYCODE_STYLUS_BUTTON_TAIL)[0];
if (!doesStylusSupportTailButton) {
return null;
}
}
Preference pref = preference == null ? new Preference(mContext) : preference;