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

Commit 71311596 authored by Emil Lenngren's avatar Emil Lenngren Committed by Jakub Pawlowski
Browse files

Fix cleanup of dead GATT clients

A bug was introduced in commit
307fe304 which causes normal
GATT clients (neither scanners nor advertisers) not being freed
properly when remote process terminates, leading to out of space
of available GATT clients after some time.

This patch adds back a ClientDeathRecipient to handle this.

Test: kill an app that has gatt client, restart it and create new
gatt client, verify the client id is same as before in logcat

Change-Id: I318cb1693984444a172cb81be2023a064dbc02a4
parent 77e22662
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -305,6 +305,19 @@ public class GattService extends ProfileService {
        }
        }
    }
    }


    class ClientDeathRecipient implements IBinder.DeathRecipient {
        int mAppIf;

        public ClientDeathRecipient(int appIf) {
            mAppIf = appIf;
        }

        public void binderDied() {
            if (DBG) Log.d(TAG, "Binder is dead - unregistering client (" + mAppIf + ")!");
            unregisterClient(mAppIf);
        }
    }

    /**
    /**
     * Handlers for incoming service calls
     * Handlers for incoming service calls
     */
     */
@@ -675,6 +688,7 @@ public class GattService extends ProfileService {
        if (app != null) {
        if (app != null) {
            if (status == 0) {
            if (status == 0) {
                app.id = clientIf;
                app.id = clientIf;
                app.linkToDeath(new ClientDeathRecipient(clientIf));
            } else {
            } else {
                mClientMap.remove(uuid);
                mClientMap.remove(uuid);
            }
            }