Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55b6b862 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Do Not Merge. Don't connect to non keyboard HID devices.

Bug: 3385950
Change-Id: I2cfb17467c3d2fd383747111cd990d39f10f5136
parent dde68c64
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -648,7 +648,8 @@ class BluetoothEventLoop {
            } else {
                Log.i(TAG, "Rejecting incoming A2DP / AVRCP connection from " + address);
            }
        } else if (BluetoothUuid.isInputDevice(uuid) && !isOtherInputDeviceConnected(address)) {
        } else if (BluetoothUuid.isInputDevice(uuid) && !isOtherInputDeviceConnected(address) &&
                   isKeyboard(address)) {
            BluetoothInputDevice inputDevice = new BluetoothInputDevice(mContext);
            authorized = inputDevice.getInputDevicePriority(device) >
                         BluetoothInputDevice.PRIORITY_OFF;
@@ -667,6 +668,17 @@ class BluetoothEventLoop {
        return authorized;
    }

    private boolean isKeyboard(String address) {
        BluetoothClass btClass = new BluetoothClass(mBluetoothService.getRemoteClass(address));
        int btDeviceClass = btClass.getDeviceClass();
        if (btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD ||
            btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD_POINTING) {
            return true;
        }
        log("Incoming Connect: Input device class: " + btDeviceClass + " Not a keyboard");
        return false;
    }

    private boolean isOtherInputDeviceConnected(String address) {
        List<BluetoothDevice> devices =
            mBluetoothService.lookupInputDevicesMatchingStates(new int[] {
+9 −0
Original line number Diff line number Diff line
@@ -1729,6 +1729,15 @@ public class BluetoothService extends IBluetooth.Stub {
            getInputDevicePriority(device) == BluetoothInputDevice.PRIORITY_OFF) {
            return false;
        }

        BluetoothClass btClass = new BluetoothClass(getRemoteClass(device.getAddress()));
        int btDeviceClass = btClass.getDeviceClass();
        if (btDeviceClass != BluetoothClass.Device.PERIPHERAL_KEYBOARD &&
            btDeviceClass != BluetoothClass.Device.PERIPHERAL_KEYBOARD_POINTING) {
            log("Input device btDeviceClass: " + btDeviceClass + " Not a keyboard");
            return false;
        }

        BluetoothDeviceProfileState state = mDeviceProfileState.get(device.getAddress());
        if (state != null) {
            Message msg = new Message();