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

Commit c3ee99d9 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Set initial HID profile preference.

Change-Id: I804089cbea4ad25b87ade60fa8a905ddb167bff4
parent d1f4a17e
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -676,6 +676,10 @@ public class BluetoothService extends IBluetooth.Stub {
                removeProfileState(address);
            }

            // HID is handled by BluetoothService, other profiles
            // will be handled by their respective services.
            setInitialInputDevicePriority(mAdapter.getRemoteDevice(address), state);

            if (DBG) log(address + " bond state " + oldState + " -> " + state + " (" +
                         reason + ")");
            Intent intent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
@@ -1347,6 +1351,19 @@ public class BluetoothService extends IBluetooth.Stub {
        handleInputDeviceStateChange(device, state);
    }

    private void setInitialInputDevicePriority(BluetoothDevice device, int state) {
        switch (state) {
            case BluetoothDevice.BOND_BONDED:
                if (getInputDevicePriority(device) == BluetoothInputDevice.PRIORITY_UNDEFINED) {
                    setInputDevicePriority(device, BluetoothInputDevice.PRIORITY_ON);
                }
                break;
            case BluetoothDevice.BOND_NONE:
                setInputDevicePriority(device, BluetoothInputDevice.PRIORITY_UNDEFINED);
                break;
        }
    }

    /*package*/ boolean isRemoteDeviceInCache(String address) {
        return (mDeviceProperties.get(address) != null);
    }