mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-24 17:45:50 +01:00
Attempt to fix never finishing activity data fetching #142
(by disabling unrelated notifications)
This commit is contained in:
parent
99470c67ff
commit
dcd776e09a
@ -4,6 +4,7 @@
|
||||
* Support pull down to synchronize activity data (#138)
|
||||
* Display tabs in the Charts activity (#139)
|
||||
* Mi Band: initial support for Mi Band 1a (the one with white LEDs) (thanks @sarg) (#136)
|
||||
* Mi Band: Attempt at fixing problem with never finishing activity data fetching (#141, #142)
|
||||
* Register/unregister BroadcastReceivers instead of enabling/disabling them with PackageManager (#134)
|
||||
(should fix disconnection because the service is being killed)
|
||||
|
||||
|
@ -108,7 +108,7 @@ public final class BtLEQueue {
|
||||
mConnectionLatch = null;
|
||||
LOG.debug("Thread interrupted");
|
||||
} catch (Throwable ex) {
|
||||
LOG.error("Queue Dispatch Thread died: " + ex.getMessage());
|
||||
LOG.error("Queue Dispatch Thread died: " + ex.getMessage(), ex);
|
||||
mCrashed = true;
|
||||
mConnectionLatch = null;
|
||||
} finally {
|
||||
|
@ -15,6 +15,7 @@ public class TransactionBuilder {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TransactionBuilder.class);
|
||||
|
||||
private Transaction mTransaction;
|
||||
private boolean mQueued;
|
||||
|
||||
public TransactionBuilder(String taskName) {
|
||||
mTransaction = new Transaction(taskName);
|
||||
@ -83,6 +84,10 @@ public class TransactionBuilder {
|
||||
* @param queue
|
||||
*/
|
||||
public void queue(BtLEQueue queue) {
|
||||
if (mQueued) {
|
||||
throw new IllegalStateException("This builder had already been queued. You must not reuse it.");
|
||||
}
|
||||
mQueued = true;
|
||||
queue.add(mTransaction);
|
||||
}
|
||||
|
||||
|
@ -124,11 +124,18 @@ public class FetchActivityOperation extends AbstractBTLEOperation<MiBandSupport>
|
||||
public void perform() throws IOException {
|
||||
TransactionBuilder builder = performInitialized("fetch activity data");
|
||||
// builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_LE_PARAMS), getLowLatency());
|
||||
|
||||
enableOtherNotifications(builder, false);
|
||||
builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.busy_task_fetch_activity_data), getContext()));
|
||||
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), fetch);
|
||||
builder.queue(getQueue());
|
||||
}
|
||||
|
||||
private void enableOtherNotifications(TransactionBuilder builder, boolean enable) {
|
||||
builder.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_REALTIME_STEPS), enable)
|
||||
.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_SENSOR_DATA), enable);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCharacteristicChanged(BluetoothGatt gatt,
|
||||
@ -141,9 +148,12 @@ public class FetchActivityOperation extends AbstractBTLEOperation<MiBandSupport>
|
||||
}
|
||||
}
|
||||
|
||||
private void handleActivityFetchFinish() {
|
||||
private void handleActivityFetchFinish() throws IOException {
|
||||
LOG.info("Fetching activity data has finished.");
|
||||
activityStruct = null;
|
||||
TransactionBuilder builder = performInitialized("enabling other notifications again");
|
||||
enableOtherNotifications(builder, true);
|
||||
builder.queue(getQueue());
|
||||
unsetBusy();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user