mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-26 09:37:33 +01:00
Fossil Hybrid HR: Show progress bar during firmware update
This commit is contained in:
parent
1e93a8c1cc
commit
f28feb7b28
@ -1,7 +1,6 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file;
|
||||
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
@ -9,12 +8,9 @@ import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEQueue;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.Request;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.FossilRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class FilePutRawRequest extends FossilRequest {
|
||||
public enum UploadState {INITIALIZED, UPLOADING, CLOSING, UPLOADED}
|
||||
@ -71,8 +67,10 @@ public class FilePutRawRequest extends FossilRequest {
|
||||
|
||||
this.prepareFilePackets(this.file);
|
||||
|
||||
for (byte[] packet : packets) {
|
||||
for (int i = 0, packetCount = packets.size(); i < packetCount; i++) {
|
||||
byte[] packet = packets.get(i);
|
||||
transactionBuilder.write(uploadCharacteristic, packet);
|
||||
onPacketWritten(transactionBuilder, i, packetCount);
|
||||
}
|
||||
|
||||
transactionBuilder.queue(adapter.getDeviceSupport().getQueue());
|
||||
@ -197,6 +195,11 @@ public class FilePutRawRequest extends FossilRequest {
|
||||
}
|
||||
|
||||
public void onFilePut(boolean success) {
|
||||
|
||||
}
|
||||
|
||||
public void onPacketWritten(TransactionBuilder transactionBuilder, int packetNr, int packetCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,9 +1,32 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetProgressAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil_hr.FossilHRWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class FirmwareFilePutRequest extends FilePutRawRequest {
|
||||
public FirmwareFilePutRequest(byte[] firmwareBytes, FossilHRWatchAdapter adapter) {
|
||||
super((short) 0x00FF, firmwareBytes, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketWritten(TransactionBuilder transactionBuilder, int packetNr, int packetCount) {
|
||||
int progressPercent = (int) ((((float) packetNr) / packetCount) * 100);
|
||||
transactionBuilder.add(new SetProgressAction(GBApplication.getContext().getString(R.string.updatefirmwareoperation_update_in_progress), true, progressPercent, GBApplication.getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFilePut(boolean success) {
|
||||
Context context = GBApplication.getContext();
|
||||
if (success) {
|
||||
GB.updateInstallNotification(context.getString(R.string.updatefirmwareoperation_update_complete), false, 100, context);
|
||||
} else {
|
||||
GB.updateInstallNotification(context.getString(R.string.updatefirmwareoperation_write_failed), false, 0, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user