summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@google.com>2015-05-08 22:19:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-08 22:19:56 +0000
commit5759a8a9cfef08b7f9485c67b07be9ae268dea0a (patch)
treeda009a9d2a8be8741da59b16f01af6a8f4f26cdc /media
parented1ef7d4eb8934f6940a2e828ebd0e6878e1af89 (diff)
parent9490eae3aa6b20cbd3c1557fd3a7eb927e12907f (diff)
downloadframeworks_base-5759a8a9cfef08b7f9485c67b07be9ae268dea0a.zip
frameworks_base-5759a8a9cfef08b7f9485c67b07be9ae268dea0a.tar.gz
frameworks_base-5759a8a9cfef08b7f9485c67b07be9ae268dea0a.tar.bz2
Merge "BluetoothMidiDevice: Cleanup and error handling improvements" into mnc-dev
Diffstat (limited to 'media')
-rw-r--r--media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java34
1 files changed, 19 insertions, 15 deletions
diff --git a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java
index 63a8da7..0ccbf6a 100644
--- a/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java
+++ b/media/packages/BluetoothMidiService/src/com/android/bluetoothmidiservice/BluetoothMidiDevice.java
@@ -92,7 +92,6 @@ public final class BluetoothMidiDevice {
mBluetoothGatt.discoverServices());
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
Log.i(TAG, "Disconnected from GATT server.");
- // FIXME synchronize?
close();
}
}
@@ -121,8 +120,8 @@ public final class BluetoothMidiDevice {
}
}
} else {
- Log.w(TAG, "onServicesDiscovered received: " + status);
- // FIXME - report error back to client?
+ Log.e(TAG, "onServicesDiscovered received: " + status);
+ close();
}
}
@@ -137,9 +136,12 @@ public final class BluetoothMidiDevice {
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
CLIENT_CHARACTERISTIC_CONFIG);
- // FIXME null check
- descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
- mBluetoothGatt.writeDescriptor(descriptor);
+ if (descriptor != null) {
+ descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
+ mBluetoothGatt.writeDescriptor(descriptor);
+ } else {
+ Log.e(TAG, "No CLIENT_CHARACTERISTIC_CONFIG for device " + mBluetoothDevice);
+ }
}
@Override
@@ -244,16 +246,18 @@ public final class BluetoothMidiDevice {
}.start();
}
- void close() {
+ private void close() {
+ synchronized (mBluetoothDevice) {
mEventScheduler.close();
- if (mDeviceServer != null) {
- IoUtils.closeQuietly(mDeviceServer);
- mDeviceServer = null;
- mService.deviceClosed(mBluetoothDevice);
- }
- if (mBluetoothGatt != null) {
- mBluetoothGatt.close();
- mBluetoothGatt = null;
+ if (mDeviceServer != null) {
+ IoUtils.closeQuietly(mDeviceServer);
+ mDeviceServer = null;
+ mService.deviceClosed(mBluetoothDevice);
+ }
+ if (mBluetoothGatt != null) {
+ mBluetoothGatt.close();
+ mBluetoothGatt = null;
+ }
}
}