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

Commit 59d9617e authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix included service handling"

parents 4d62e0ac eb5548e7
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -2418,9 +2418,14 @@ public class GattService extends ProfileService {
        }

        for (BluetoothGattService includedService : service.getIncludedServices()) {
            int inclSrvc = mHandleMap.getServiceHandle(includedService.getUuid(),
                    includedService.getType(), includedService.getInstanceId());
            db.add(GattDbElement.createIncludedService(inclSrvc));
            int inclSrvcHandle = includedService.getInstanceId();

            if (mHandleMap.checkServiceExists(includedService.getUuid(), inclSrvcHandle)) {
                db.add(GattDbElement.createIncludedService(inclSrvcHandle));
            } else {
                Log.e(TAG,
                        "included service with UUID " + includedService.getUuid() + " not found!");
            }
        }

        gattServerAddServiceNative(serverIf, db);
+4 −22
Original line number Diff line number Diff line
@@ -131,31 +131,13 @@ class HandleMap {
        return null;
    }

    int getServiceHandle(UUID uuid, int serviceType, int instance) {
    boolean checkServiceExists(UUID uuid, int handle) {
        for(Entry entry : mEntries) {
            if (entry.type == TYPE_SERVICE &&
                entry.serviceType == serviceType &&
                entry.instance == instance &&
                entry.uuid.equals(uuid)) {
                return entry.handle;
            if (entry.type == TYPE_SERVICE && entry.handle == handle && entry.uuid.equals(uuid)) {
                return true;
            }
        }
        Log.e(TAG, "getServiceHandle() - UUID " + uuid + " not found!");
        return 0;
    }

    int getCharacteristicHandle(int serviceHandle, UUID uuid, int instance) {
        for(Entry entry : mEntries) {
            if (entry.type == TYPE_CHARACTERISTIC &&
                entry.serviceHandle == serviceHandle &&
                entry.instance == instance &&
                entry.uuid.equals(uuid)) {
                return entry.handle;
            }
        }
        Log.e(TAG, "getCharacteristicHandle() - Service " + serviceHandle
                    + ", UUID " + uuid + " not found!");
        return 0;
        return false;
    }

    void deleteService(int serverIf, int serviceHandle) {