Mi Bands+Bip: when an operation finishes, unset the gatt callback on the BtLEQeue

Otherwise it will continue to receive events until another transaction is being executed.
This commit is contained in:
cpfeiffer 2017-09-02 22:45:21 +02:00
parent c91e14f644
commit c468e7f521
2 changed files with 4 additions and 0 deletions

View File

@ -85,6 +85,9 @@ public abstract class AbstractBTLEOperation<T extends AbstractBTLEDeviceSupport>
* You MUST call this method when the operation has finished, either
* successfully or unsuccessfully.
*
* Subclasses must ensure that the {@link BtLEQueue queue's}'s gatt callback (set on the transaction builder by {@link #performInitialized(String)})
* is being unset, otherwise it will continue to receive events until another transaction is being executed by the queue.
*
* @throws IOException
*/
protected void operationFinished() throws IOException {

View File

@ -48,6 +48,7 @@ public abstract class AbstractMiBandOperation<T extends AbstractBTLEDeviceSuppor
try {
TransactionBuilder builder = performInitialized("reenabling disabled notifications");
handleFinished(builder);
builder.setGattCallback(null); // unset ourselves from being the queue's gatt callback
builder.queue(getQueue());
} catch (IOException ex) {
GB.toast(getContext(), "Error enabling Mi Band notifications, you may need to connect and disconnect", Toast.LENGTH_LONG, GB.ERROR, ex);