Send the progress updates from the actual BT transfer, which is where most of the time is spent.
This commit is contained in:
parent
23f752dc20
commit
1bef702485
|
@ -0,0 +1,35 @@
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.btle;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothGatt;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GB;
|
||||||
|
|
||||||
|
public class SetProgressAction extends PlainAction {
|
||||||
|
|
||||||
|
private String text;
|
||||||
|
private boolean ongoing;
|
||||||
|
private int percentage;
|
||||||
|
private final Context context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When run, will update the progress notification.
|
||||||
|
* @param text
|
||||||
|
* @param ongoing
|
||||||
|
* @param percentage
|
||||||
|
* @param context
|
||||||
|
*/
|
||||||
|
|
||||||
|
public SetProgressAction(String text, boolean ongoing, int percentage, Context context) {
|
||||||
|
this.text = text;
|
||||||
|
this.ongoing = ongoing;
|
||||||
|
this.percentage = percentage;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(BluetoothGatt gatt) {
|
||||||
|
GB.updateInstallNotification(this.text, this.ongoing, this.percentage, this.context);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,7 @@ import nodomain.freeyourgadget.gadgetbridge.btle.AbortTransactionAction;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.btle.AbstractBTLEDeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.btle.AbstractBTLEDeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.btle.BtLEAction;
|
import nodomain.freeyourgadget.gadgetbridge.btle.BtLEAction;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.btle.SetDeviceBusyAction;
|
import nodomain.freeyourgadget.gadgetbridge.btle.SetDeviceBusyAction;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.btle.SetProgressAction;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.btle.TransactionBuilder;
|
import nodomain.freeyourgadget.gadgetbridge.btle.TransactionBuilder;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.ActivityDatabaseHandler;
|
import nodomain.freeyourgadget.gadgetbridge.database.ActivityDatabaseHandler;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.SampleProvider;
|
import nodomain.freeyourgadget.gadgetbridge.model.SampleProvider;
|
||||||
|
@ -906,7 +907,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
if ((i > 0) && (i % 50 == 0)) {
|
if ((i > 0) && (i % 50 == 0)) {
|
||||||
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), new byte[]{MiBandService.COMMAND_SYNC});
|
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), new byte[]{MiBandService.COMMAND_SYNC});
|
||||||
GB.updateInstallNotification("Firmware update in progress", true, (firmwareProgress / len) * 100, getContext());
|
builder.add(new SetProgressAction("Firmware update in progress", true, (firmwareProgress / len) * 100, getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Firmware update progress:" + firmwareProgress + " total len:" + len + " progress:" + (firmwareProgress / len));
|
LOG.info("Firmware update progress:" + firmwareProgress + " total len:" + len + " progress:" + (firmwareProgress / len));
|
||||||
|
@ -922,7 +923,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||||
LOG.info("Firmware update progress:" + firmwareProgress + " total len:" + len + " progress:" + (firmwareProgress / len));
|
LOG.info("Firmware update progress:" + firmwareProgress + " total len:" + len + " progress:" + (firmwareProgress / len));
|
||||||
if (firmwareProgress >= len) {
|
if (firmwareProgress >= len) {
|
||||||
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), new byte[]{MiBandService.COMMAND_SYNC});
|
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), new byte[]{MiBandService.COMMAND_SYNC});
|
||||||
GB.updateInstallNotification("Firmware installation complete", false, 100, getContext());
|
builder.add(new SetProgressAction("Firmware installation complete", false, 100, getContext()));
|
||||||
} else {
|
} else {
|
||||||
GB.updateInstallNotification("Firmware write failed", false, 0, getContext());
|
GB.updateInstallNotification("Firmware write failed", false, 0, getContext());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue