()
| 199 | } |
| 200 | |
| 201 | @Override |
| 202 | public void close() { |
| 203 | safeDestruct.beginShutdown(); |
| 204 | |
| 205 | shutdown = true; |
| 206 | writeBuffer.clear(); |
| 207 | gatt.disconnect(); |
| 208 | synchronized (gattStateSync) { |
| 209 | long waitUntil = System.currentTimeMillis() + DISCONNECT_TIMEOUT; |
| 210 | while (gattState != BluetoothGatt.STATE_DISCONNECTED) { |
| 211 | long timeToWait = waitUntil - System.currentTimeMillis(); |
| 212 | if (timeToWait <= 0) { |
| 213 | break; |
| 214 | } |
| 215 | try { |
| 216 | gattStateSync.wait(timeToWait); |
| 217 | } catch (InterruptedException e) { |
| 218 | break; |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | gatt.close(); |
| 223 | |
| 224 | safeDestruct.finishShutdown(); |
| 225 | } |
| 226 | |
| 227 | @Override |
| 228 | public int getState() { |
nothing calls this directly
no test coverage detected