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

Commit 334b7721 authored by Kihong Seong's avatar Kihong Seong Committed by Gerrit Code Review
Browse files

Merge "Throw error when notification is larger than max attribute value" into main

parents 1434d775 59c19fa4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ public final class BluetoothGattServer implements BluetoothProfile {
    private List<BluetoothGattService> mServices;

    private static final int CALLBACK_REG_TIMEOUT = 10000;
    // Max length of an attribute value, defined in gatt_api.h
    private static final int GATT_MAX_ATTR_LEN = 512;

    /**
     * Bluetooth GATT interface callbacks
@@ -829,6 +831,10 @@ public final class BluetoothGattServer implements BluetoothProfile {
        if (device == null) {
            throw new IllegalArgumentException("device must not be null");
        }
        if (value.length > GATT_MAX_ATTR_LEN) {
            throw new IllegalArgumentException(
                    "notification should not be longer than max length of an attribute value");
        }
        BluetoothGattService service = characteristic.getService();
        if (service == null) {
            throw new IllegalArgumentException("Characteristic must have a non-null service");