Loading core/java/android/bluetooth/BluetoothGatt.java +60 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ public final class BluetoothGatt implements BluetoothProfile { private boolean mAutoConnect; private int mConnState; private final Object mStateLock = new Object(); private Boolean mDeviceBusy = false; private static final int CONN_STATE_IDLE = 0; private static final int CONN_STATE_CONNECTING = 1; Loading Loading @@ -177,6 +178,10 @@ public final class BluetoothGatt implements BluetoothProfile { mConnState = CONN_STATE_IDLE; } } synchronized(mDeviceBusy) { mDeviceBusy = false; } } /** Loading Loading @@ -312,6 +317,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } if ((status == GATT_INSUFFICIENT_AUTHENTICATION || status == GATT_INSUFFICIENT_ENCRYPTION) && mAuthRetry == false) { Loading Loading @@ -359,6 +369,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } BluetoothGattService service = getService(mDevice, srvcUuid.getUuid(), srvcInstId, srvcType); if (service == null) return; Loading Loading @@ -436,6 +451,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } BluetoothGattService service = getService(mDevice, srvcUuid.getUuid(), srvcInstId, srvcType); if (service == null) return; Loading Loading @@ -485,6 +505,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } BluetoothGattService service = getService(mDevice, srvcUuid.getUuid(), srvcInstId, srvcType); if (service == null) return; Loading Loading @@ -530,6 +555,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } try { mCallback.onReliableWriteCompleted(BluetoothGatt.this, status); } catch (Exception ex) { Loading Loading @@ -862,6 +892,11 @@ public final class BluetoothGatt implements BluetoothProfile { BluetoothDevice device = service.getDevice(); if (device == null) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.readCharacteristic(mClientIf, device.getAddress(), service.getType(), service.getInstanceId(), Loading @@ -869,6 +904,7 @@ public final class BluetoothGatt implements BluetoothProfile { new ParcelUuid(characteristic.getUuid()), AUTHENTICATION_NONE); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading Loading @@ -901,6 +937,11 @@ public final class BluetoothGatt implements BluetoothProfile { BluetoothDevice device = service.getDevice(); if (device == null) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.writeCharacteristic(mClientIf, device.getAddress(), service.getType(), service.getInstanceId(), Loading @@ -910,6 +951,7 @@ public final class BluetoothGatt implements BluetoothProfile { characteristic.getValue()); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading Loading @@ -941,6 +983,11 @@ public final class BluetoothGatt implements BluetoothProfile { BluetoothDevice device = service.getDevice(); if (device == null) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.readDescriptor(mClientIf, device.getAddress(), service.getType(), service.getInstanceId(), new ParcelUuid(service.getUuid()), Loading @@ -949,6 +996,7 @@ public final class BluetoothGatt implements BluetoothProfile { AUTHENTICATION_NONE); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading Loading @@ -979,6 +1027,11 @@ public final class BluetoothGatt implements BluetoothProfile { BluetoothDevice device = service.getDevice(); if (device == null) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.writeDescriptor(mClientIf, device.getAddress(), service.getType(), service.getInstanceId(), new ParcelUuid(service.getUuid()), Loading @@ -988,6 +1041,7 @@ public final class BluetoothGatt implements BluetoothProfile { descriptor.getValue()); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading Loading @@ -1045,10 +1099,16 @@ public final class BluetoothGatt implements BluetoothProfile { if (DBG) Log.d(TAG, "executeReliableWrite() - device: " + mDevice.getAddress()); if (mService == null || mClientIf == 0) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.endReliableWrite(mClientIf, mDevice.getAddress(), true); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading Loading
core/java/android/bluetooth/BluetoothGatt.java +60 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ public final class BluetoothGatt implements BluetoothProfile { private boolean mAutoConnect; private int mConnState; private final Object mStateLock = new Object(); private Boolean mDeviceBusy = false; private static final int CONN_STATE_IDLE = 0; private static final int CONN_STATE_CONNECTING = 1; Loading Loading @@ -177,6 +178,10 @@ public final class BluetoothGatt implements BluetoothProfile { mConnState = CONN_STATE_IDLE; } } synchronized(mDeviceBusy) { mDeviceBusy = false; } } /** Loading Loading @@ -312,6 +317,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } if ((status == GATT_INSUFFICIENT_AUTHENTICATION || status == GATT_INSUFFICIENT_ENCRYPTION) && mAuthRetry == false) { Loading Loading @@ -359,6 +369,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } BluetoothGattService service = getService(mDevice, srvcUuid.getUuid(), srvcInstId, srvcType); if (service == null) return; Loading Loading @@ -436,6 +451,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } BluetoothGattService service = getService(mDevice, srvcUuid.getUuid(), srvcInstId, srvcType); if (service == null) return; Loading Loading @@ -485,6 +505,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } BluetoothGattService service = getService(mDevice, srvcUuid.getUuid(), srvcInstId, srvcType); if (service == null) return; Loading Loading @@ -530,6 +555,11 @@ public final class BluetoothGatt implements BluetoothProfile { if (!address.equals(mDevice.getAddress())) { return; } synchronized(mDeviceBusy) { mDeviceBusy = false; } try { mCallback.onReliableWriteCompleted(BluetoothGatt.this, status); } catch (Exception ex) { Loading Loading @@ -862,6 +892,11 @@ public final class BluetoothGatt implements BluetoothProfile { BluetoothDevice device = service.getDevice(); if (device == null) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.readCharacteristic(mClientIf, device.getAddress(), service.getType(), service.getInstanceId(), Loading @@ -869,6 +904,7 @@ public final class BluetoothGatt implements BluetoothProfile { new ParcelUuid(characteristic.getUuid()), AUTHENTICATION_NONE); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading Loading @@ -901,6 +937,11 @@ public final class BluetoothGatt implements BluetoothProfile { BluetoothDevice device = service.getDevice(); if (device == null) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.writeCharacteristic(mClientIf, device.getAddress(), service.getType(), service.getInstanceId(), Loading @@ -910,6 +951,7 @@ public final class BluetoothGatt implements BluetoothProfile { characteristic.getValue()); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading Loading @@ -941,6 +983,11 @@ public final class BluetoothGatt implements BluetoothProfile { BluetoothDevice device = service.getDevice(); if (device == null) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.readDescriptor(mClientIf, device.getAddress(), service.getType(), service.getInstanceId(), new ParcelUuid(service.getUuid()), Loading @@ -949,6 +996,7 @@ public final class BluetoothGatt implements BluetoothProfile { AUTHENTICATION_NONE); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading Loading @@ -979,6 +1027,11 @@ public final class BluetoothGatt implements BluetoothProfile { BluetoothDevice device = service.getDevice(); if (device == null) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.writeDescriptor(mClientIf, device.getAddress(), service.getType(), service.getInstanceId(), new ParcelUuid(service.getUuid()), Loading @@ -988,6 +1041,7 @@ public final class BluetoothGatt implements BluetoothProfile { descriptor.getValue()); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading Loading @@ -1045,10 +1099,16 @@ public final class BluetoothGatt implements BluetoothProfile { if (DBG) Log.d(TAG, "executeReliableWrite() - device: " + mDevice.getAddress()); if (mService == null || mClientIf == 0) return false; synchronized(mDeviceBusy) { if (mDeviceBusy) return false; mDeviceBusy = true; } try { mService.endReliableWrite(mClientIf, mDevice.getAddress(), true); } catch (RemoteException e) { Log.e(TAG,"",e); mDeviceBusy = false; return false; } Loading