Skip to content

Commit

Permalink
Thread annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Oct 30, 2018
1 parent 92fffad commit 9d0dea7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ble/src/main/java/no/nordicsemi/android/ble/BleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ public final ConnectRequest connect(@NonNull final BluetoothDevice device, @PhyM
.setManager(this);
}

@MainThread
private boolean internalConnect(@NonNull final BluetoothDevice device,
@Nullable final ConnectRequest connectRequest) {
final boolean bluetoothEnabled = BluetoothAdapter.getDefaultAdapter().isEnabled();
Expand Down Expand Up @@ -720,6 +721,7 @@ public final DisconnectRequest disconnect() {
return Request.disconnect().setManager(this);
}

@MainThread
private boolean internalDisconnect() {
mUserDisconnected = true;
mInitialConnection = false;
Expand Down Expand Up @@ -911,6 +913,7 @@ protected final Request createBond() {
return Request.createBond().setManager(this);
}

@MainThread
private boolean internalCreateBond() {
final BluetoothDevice device = mBluetoothDevice;
if (device == null)
Expand Down Expand Up @@ -963,6 +966,7 @@ protected final Request removeBond() {
}

@SuppressWarnings("JavaReflectionMemberAccess")
@MainThread
private boolean internalRemoveBond() {
final BluetoothDevice device = mBluetoothDevice;
if (device == null)
Expand Down Expand Up @@ -1036,6 +1040,7 @@ private boolean ensureServiceChangedEnabled() {
* callback will not be null, but will not be used.
* @return The callback.
*/
@MainThread
@NonNull
protected final ValueChangedCallback setNotificationCallback(@Nullable final BluetoothGattCharacteristic characteristic) {
ValueChangedCallback callback = mNotificationCallbacks.get(characteristic);
Expand Down Expand Up @@ -1121,6 +1126,7 @@ protected final WriteRequest enableNotifications(
return Request.newEnableNotificationsRequest(characteristic).setManager(this);
}

@MainThread
private boolean internalEnableNotifications(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null || !mConnected)
Expand Down Expand Up @@ -1155,6 +1161,7 @@ protected final WriteRequest disableNotifications(@Nullable final BluetoothGattC
return Request.newDisableNotificationsRequest(characteristic).setManager(this);
}

@MainThread
private boolean internalDisableNotifications(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null || !mConnected)
Expand Down Expand Up @@ -1189,6 +1196,7 @@ protected final WriteRequest enableIndications(@Nullable final BluetoothGattChar
return Request.newEnableIndicationsRequest(characteristic).setManager(this);
}

@MainThread
private boolean internalEnableIndications(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null || !mConnected)
Expand Down Expand Up @@ -1223,6 +1231,7 @@ protected final WriteRequest disableIndications(@Nullable final BluetoothGattCha
return Request.newDisableIndicationsRequest(characteristic).setManager(this);
}

@MainThread
private boolean internalDisableIndications(final BluetoothGattCharacteristic characteristic) {
// This writes exactly the same settings so do not duplicate code.
return internalDisableNotifications(characteristic);
Expand Down Expand Up @@ -1267,6 +1276,7 @@ protected final ReadRequest readCharacteristic(@Nullable final BluetoothGattChar
return Request.newReadRequest(characteristic).setManager(this);
}

@MainThread
private boolean internalReadCharacteristic(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null || !mConnected)
Expand Down Expand Up @@ -1352,6 +1362,7 @@ protected final WriteRequest writeCharacteristic(@Nullable final BluetoothGattCh
return Request.newWriteRequest(characteristic, data, offset, length).setManager(this);
}

@MainThread
private boolean internalWriteCharacteristic(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null || !mConnected)
Expand Down Expand Up @@ -1385,6 +1396,7 @@ protected final ReadRequest readDescriptor(@Nullable final BluetoothGattDescript
return Request.newReadRequest(descriptor).setManager(this);
}

@MainThread
private boolean internalReadDescriptor(final BluetoothGattDescriptor descriptor) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || descriptor == null || !mConnected)
Expand Down Expand Up @@ -1465,6 +1477,7 @@ protected final WriteRequest writeDescriptor(@Nullable final BluetoothGattDescri
return Request.newWriteRequest(descriptor, data, offset, length).setManager(this);
}

@MainThread
private boolean internalWriteDescriptor(final BluetoothGattDescriptor descriptor) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || descriptor == null || !mConnected)
Expand Down Expand Up @@ -1499,6 +1512,7 @@ protected void readBatteryLevel() {
.enqueue();
}

@MainThread
@Deprecated
private boolean internalReadBatteryLevel() {
final BluetoothGatt gatt = mBluetoothGatt;
Expand Down Expand Up @@ -1554,6 +1568,7 @@ protected void disableBatteryLevelNotifications() {
.enqueue();
}

@MainThread
@Deprecated
private boolean internalSetBatteryNotifications(final boolean enable) {
final BluetoothGatt gatt = mBluetoothGatt;
Expand Down Expand Up @@ -1581,6 +1596,7 @@ private boolean internalSetBatteryNotifications(final boolean enable) {
* @param descriptor the descriptor to be written
* @return the result of {@link BluetoothGatt#writeDescriptor(BluetoothGattDescriptor)}
*/
@MainThread
private boolean internalWriteDescriptorWorkaround(final BluetoothGattDescriptor descriptor) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || descriptor == null || !mConnected)
Expand Down Expand Up @@ -1641,6 +1657,7 @@ protected final void overrideMtu(@IntRange(from = 23, to = 517) final int mtu) {
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@MainThread
private boolean internalRequestMtu(@IntRange(from = 23, to = 517) final int mtu) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || !mConnected)
Expand Down Expand Up @@ -1683,6 +1700,7 @@ protected final ConnectionPriorityRequest requestConnectionPriority(
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@MainThread
private boolean internalRequestConnectionPriority(@ConnectionPriority final int priority) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || !mConnected)
Expand Down Expand Up @@ -1737,6 +1755,7 @@ protected final PhyRequest setPreferredPhy(@PhyMask final int txPhy, @PhyMask fi
}

@RequiresApi(api = Build.VERSION_CODES.O)
@MainThread
private boolean internalSetPreferredPhy(@PhyMask final int txPhy, @PhyMask final int rxPhy,
@PhyOption final int phyOptions) {
final BluetoothGatt gatt = mBluetoothGatt;
Expand Down Expand Up @@ -1768,6 +1787,7 @@ protected final PhyRequest readPhy() {
}

@RequiresApi(api = Build.VERSION_CODES.O)
@MainThread
private boolean internalReadPhy() {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || !mConnected)
Expand All @@ -1791,6 +1811,7 @@ protected final ReadRssiRequest readRssi() {
return Request.newReadRssiRequest().setManager(this);
}

@MainThread
private boolean internalReadRssi() {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || !mConnected)
Expand Down Expand Up @@ -1827,6 +1848,7 @@ protected final Request refreshDeviceCache() {
* Clears the device cache.
*/
@SuppressWarnings("JavaReflectionMemberAccess")
@MainThread
private boolean internalRefreshDeviceCache() {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null) // no need to be connected
Expand Down Expand Up @@ -2859,6 +2881,7 @@ protected void cancelQueue() {
* been executed the {@link #onDeviceReady()} callback is called.
*/
@SuppressWarnings("ConstantConditions")
@MainThread
private synchronized void nextRequest(final boolean force) {
// Is the manager closed()?
if (mGattCallback == null) {
Expand Down

0 comments on commit 9d0dea7

Please sign in to comment.