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

Commit 8a99d67d authored by Phil Burk's avatar Phil Burk Committed by android-build-merger
Browse files

Merge "BluetoothMidi: request higher priority, for lower latency" into oc-dev

am: e49ad6c7

Change-Id: Idcece5b34d81cdeb43eb9196d7d29c3023605782
parents 25e893c7 e49ad6c7
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -100,8 +100,8 @@ public final class BluetoothMidiDevice {
                int newState) {
            String intentAction;
            if (newState == BluetoothProfile.STATE_CONNECTED) {
                Log.i(TAG, "Connected to GATT server.");
                Log.i(TAG, "Attempting to start service discovery:" +
                Log.d(TAG, "Connected to GATT server.");
                Log.d(TAG, "Attempting to start service discovery:" +
                        mBluetoothGatt.discoverServices());
            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                Log.i(TAG, "Disconnected from GATT server.");
@@ -112,24 +112,24 @@ public final class BluetoothMidiDevice {
        @Override
        public void onServicesDiscovered(BluetoothGatt gatt, int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                List<BluetoothGattService> services = mBluetoothGatt.getServices();
                for (BluetoothGattService service : services) {
                    if (MIDI_SERVICE.equals(service.getUuid())) {
                BluetoothGattService service = gatt.getService(MIDI_SERVICE);
                if (service != null) {
                    Log.d(TAG, "found MIDI_SERVICE");
                        List<BluetoothGattCharacteristic> characteristics
                            = service.getCharacteristics();
                        for (BluetoothGattCharacteristic characteristic : characteristics) {
                            if (MIDI_CHARACTERISTIC.equals(characteristic.getUuid())) {
                    BluetoothGattCharacteristic characteristic
                            = service.getCharacteristic(MIDI_CHARACTERISTIC);
                    if (characteristic != null) {
                        Log.d(TAG, "found MIDI_CHARACTERISTIC");
                        mCharacteristic = characteristic;

                        // Request a lower Connection Interval for better latency.
                        boolean result = gatt.requestConnectionPriority(
                                BluetoothGatt.CONNECTION_PRIORITY_HIGH);
                        Log.d(TAG, "requestConnectionPriority(CONNECTION_PRIORITY_HIGH):"
                            + result);

                        // Specification says to read the characteristic first and then
                        // switch to receiving notifications
                        mBluetoothGatt.readCharacteristic(characteristic);
                                break;
                            }
                        }
                        break;
                    }
                }
            } else {