diff options
| author | Jakub Pawlowski <jpawlowski@google.com> | 2017-09-12 14:48:30 -0700 |
|---|---|---|
| committer | Andre Eisenbach <eisenbach@google.com> | 2017-09-13 17:31:24 +0000 |
| commit | eb6b3da4fc54ca4cfcbb8ee3b927391eed981725 (patch) | |
| tree | d59335a7999f4dfdbf8372f90ca3c835bf2139fb /core/java | |
| parent | 60eae6e621917756da348a2c4ef3185832915383 (diff) | |
Bluetooth: fix GATT race conditions when using Handler
Bug: 65596701
Test: manual
Change-Id: Id703cea0543626bdd5a583da95615b650bbcc331
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothGatt.java | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java index 759d772920ba..3ded05d1a7f1 100644 --- a/core/java/android/bluetooth/BluetoothGatt.java +++ b/core/java/android/bluetooth/BluetoothGatt.java @@ -371,12 +371,11 @@ public final class BluetoothGatt implements BluetoothProfile { return; } - if (status == 0) characteristic.setValue(value); - runOrQueueCallback(new Runnable() { @Override public void run() { if (mCallback != null) { + if (status == 0) characteristic.setValue(value); mCallback.onCharacteristicRead(BluetoothGatt.this, characteristic, status); } @@ -454,12 +453,11 @@ public final class BluetoothGatt implements BluetoothProfile { handle); if (characteristic == null) return; - characteristic.setValue(value); - runOrQueueCallback(new Runnable() { @Override public void run() { if (mCallback != null) { + characteristic.setValue(value); mCallback.onCharacteristicChanged(BluetoothGatt.this, characteristic); } @@ -489,7 +487,6 @@ public final class BluetoothGatt implements BluetoothProfile { BluetoothGattDescriptor descriptor = getDescriptorById(mDevice, handle); if (descriptor == null) return; - if (status == 0) descriptor.setValue(value); if ((status == GATT_INSUFFICIENT_AUTHENTICATION || status == GATT_INSUFFICIENT_ENCRYPTION) @@ -511,6 +508,7 @@ public final class BluetoothGatt implements BluetoothProfile { @Override public void run() { if (mCallback != null) { + if (status == 0) descriptor.setValue(value); mCallback.onDescriptorRead(BluetoothGatt.this, descriptor, status); } } |
