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

Commit c8a71f3b authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Create memory safe overload of

BluetoothGattServer#notifyCharacteristicChanged

Tag: #feature
Bug: 195157393
Test: Manual
Change-Id: Iba25ddb456298dc9b9d8d82bbdc1b66327c540fc
parent 98cad5a2
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -940,13 +940,14 @@ public class GattService extends ProfileService {
        }

        @Override
        public void sendNotification(int serverIf, String address, int handle, boolean confirm,
        public int sendNotification(int serverIf, String address, int handle, boolean confirm,
                byte[] value, AttributionSource attributionSource) {
            GattService service = getService();
            if (service == null) {
                return;
                return BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND;
            }
            service.sendNotification(serverIf, address, handle, confirm, value, attributionSource);
            return service.sendNotification(serverIf, address, handle, confirm, value,
                attributionSource);
        }

        @Override
@@ -3669,11 +3670,11 @@ public class GattService extends ProfileService {
    }

    @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
    void sendNotification(int serverIf, String address, int handle, boolean confirm, byte[] value,
    int sendNotification(int serverIf, String address, int handle, boolean confirm, byte[] value,
            AttributionSource attributionSource) {
        if (!Utils.checkConnectPermissionForDataDelivery(
                this, attributionSource, "GattService sendNotification")) {
            return;
            return BluetoothStatusCodes.ERROR_MISSING_BLUETOOTH_CONNECT_PERMISSION;
        }

        if (VDBG) {
@@ -3682,7 +3683,7 @@ public class GattService extends ProfileService {

        Integer connId = mServerMap.connIdByAddress(serverIf, address);
        if (connId == null || connId == 0) {
            return;
            return BluetoothStatusCodes.ERROR_DEVICE_NOT_CONNECTED;
        }

        if (confirm) {
@@ -3690,6 +3691,8 @@ public class GattService extends ProfileService {
        } else {
            gattServerSendNotificationNative(serverIf, handle, connId, value);
        }

        return BluetoothStatusCodes.SUCCESS;
    }


+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ interface IBluetoothGatt {
    void sendResponse(in int serverIf, in String address, in int requestId,
                            in int status, in int offset, in byte[] value, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    void sendNotification(in int serverIf, in String address, in int handle,
    int sendNotification(in int serverIf, in String address, in int handle,
                            in boolean confirm, in byte[] value, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    void disconnectAll(in AttributionSource attributionSource);