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

Commit 8d0e8ad6 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Fix a deadlock in service discovery callbacks

onSearchCompleted calling gattClientGetGattDbNative directly, might
cause deadlock if the jni_workqueue is full.

Bug: 30835367
Change-Id: I05de735aa189dd2d250f2c5816d38c2ddcabb864
parent 2cbe6783
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -727,8 +727,16 @@ public class GattService extends ProfileService {
    void onSearchCompleted(int connId, int status) throws RemoteException {
        if (DBG) Log.d(TAG, "onSearchCompleted() - connId=" + connId+ ", status=" + status);
        // Gatt DB is ready!

        // This callback was called from the jni_workqueue thread. If we make request to the stack
        // on the same thread, it might cause deadlock. Schedule request on a new thread instead.
        Thread t = new Thread(new Runnable() {
            public void run() {
                gattClientGetGattDbNative(connId);
            }
        });
        t.start();
    }

    GattDbElement GetSampleGattDbElement() {
        return new GattDbElement();