1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

Mi Band: Allow setting low-latency FW update mode in Mi Band development settings

This commit is contained in:
Andreas Shimokawa 2016-05-04 13:24:32 +02:00
parent 045d5119ff
commit 65a95366f4
3 changed files with 15 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandFWHelper;
@ -25,6 +26,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.AbstractMiFir
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBandSupport;
import nodomain.freeyourgadget.gadgetbridge.util.CheckSums;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class UpdateFirmwareOperation extends AbstractMiBandOperation {
private static final Logger LOG = LoggerFactory.getLogger(UpdateFirmwareOperation.class);
@ -32,6 +34,7 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
private final Uri uri;
private boolean firmwareInfoSent = false;
private UpdateCoordinator updateCoordinator;
final Prefs prefs = GBApplication.getPrefs();
public UpdateFirmwareOperation(Uri uri, MiBandSupport support) {
super(support);
@ -285,7 +288,9 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation {
int firmwareProgress = 0;
TransactionBuilder builder = performInitialized("send firmware packet");
// getSupport().setLowLatency(builder);
if (prefs.getBoolean("mi_low_latency_fw_update", false)) {
getSupport().setLowLatency(builder);
}
for (int i = 0; i < packets; i++) {
byte[] fwChunk = Arrays.copyOfRange(fwbytes, i * packetLength, i * packetLength + packetLength);

View File

@ -199,9 +199,12 @@
<string name="chart_steps">Steps</string>
<string name="liveactivity_live_activity">Live Activity</string>
<string name="weeksteps_today_steps_description">Steps today, target: %1$s</string>
<string name="pref_title_dont_ack_transfer">Do not ack activity data transfer</string>
<string name="pref_summary_dont_ack_transfers">If the activity data are not acked to the band, they will not be cleared. Useful if GB is used together with other apps.</string>
<string name="pref_summary_keep_data_on_device">Will keep activity data on the Mi Band even after synchronization. Useful if GB is used together with other apps.</string>
<string name="pref_title_dont_ack_transfer">Do not ack activity data transfer</string>
<string name="pref_title_low_latency_fw_update">Use low-latency mode for FW updates</string>
<string name="pref_summary_low_latency_fw_update">This might help on devices where firmware updates fail</string>
<string name="live_activity_steps_history">Steps History</string>
<string name="live_activity_current_steps_per_minute">Current steps/min</string>
<string name="live_activity_total_steps">Total Steps</string>

View File

@ -161,5 +161,10 @@
android:title="@string/pref_title_keep_data_on_device"
android:summary="@string/pref_summary_keep_data_on_device"
android:defaultValue="false" />
<CheckBoxPreference
android:key="mi_low_latency_fw_update"
android:title="@string/pref_title_low_latency_fw_update"
android:summary="@string/pref_summary_low_latency_fw_update"
android:defaultValue="false" />
</PreferenceCategory>
</PreferenceScreen>