diff options
author | Jakub Pawlowski <jpawlowski@google.com> | 2016-08-19 04:08:18 -0700 |
---|---|---|
committer | Jakub Pawlowski <jpawlowski@google.com> | 2016-08-22 12:07:39 -0700 |
commit | 3fffb5a79db220b2a870a73d70194e6cb7bc5d6a (patch) | |
tree | cc85f4a9f0c77b26700ba2057d8b3287ce2fce37 | |
parent | 36294bfd684158211f5f4962372c63ddd0f2f859 (diff) | |
download | android_packages_apps_Bluetooth-3fffb5a79db220b2a870a73d70194e6cb7bc5d6a.tar.gz android_packages_apps_Bluetooth-3fffb5a79db220b2a870a73d70194e6cb7bc5d6a.tar.bz2 android_packages_apps_Bluetooth-3fffb5a79db220b2a870a73d70194e6cb7bc5d6a.zip |
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
-rw-r--r-- | src/com/android/bluetooth/gatt/GattService.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java index 854e9ae5a..d231f0fed 100644 --- a/src/com/android/bluetooth/gatt/GattService.java +++ b/src/com/android/bluetooth/gatt/GattService.java @@ -727,7 +727,15 @@ 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! - gattClientGetGattDbNative(connId); + + // 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() { |