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

Commit 5682be9e authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Add server-side callback for change in MTU (4/4)

When a client requests to update the LE transport MTU, the server
currently does not get notified and can therefor not properly size
notifications appropriate to the current MTU.

Bug: 18388114
Change-Id: I515bfc2cc9846490d57de71860f41ea9a61fa243
parent 0f5abcc5
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -284,6 +284,24 @@ public final class BluetoothGattServer implements BluetoothProfile {
                    Log.w(TAG, "Unhandled exception: " + ex);
                }
            }

            /**
             * The MTU for a connection has changed
             * @hide
             */
            public void onMtuChanged(String address, int mtu) {
                if (DBG) Log.d(TAG, "onMtuChanged() - "
                    + "device=" + address + ", mtu=" + mtu);

                BluetoothDevice device = mAdapter.getRemoteDevice(address);
                if (device == null) return;

                try {
                    mCallback.onMtuChanged(device, mtu);
                } catch (Exception ex) {
                    Log.w(TAG, "Unhandled exception: " + ex);
                }
            }
        };

    /**
+12 −0
Original line number Diff line number Diff line
@@ -145,4 +145,16 @@ public abstract class BluetoothGattServerCallback {
     */
    public void onNotificationSent(BluetoothDevice device, int status) {
    }

    /**
     * Callback indicating the MTU for a given device connection has changed.
     *
     * <p>This callback will be invoked if a remote client has requested to change
     * the MTU for a given connection.
     *
     * @param device The remote device that requested the MTU change
     * @param mtu The new MTU size
     */
    public void onMtuChanged(BluetoothDevice device, int mtu) {
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -59,4 +59,5 @@ oneway interface IBluetoothGattServerCallback {
                                     in byte[] value);
    void onExecuteWrite(in String address, in int transId, in boolean execWrite);
    void onNotificationSent(in String address, in int status);
    void onMtuChanged(in String address, in int mtu);
}