diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java index 1dd480156..e62dd0596 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java @@ -664,11 +664,14 @@ public static String packageNameToPebbleMsgSender(String packageName) { deviceSharedPrefsEdit.putString("disconnect_notification_end", prefs.getString("disconnect_notification_end", "22:00")); } if (deviceType == MIBAND2 || deviceType == MIBAND3) { - deviceSharedPrefsEdit.putString("mi2_do_not_disturb", prefs.getString("do_not_disturb", "off")); - deviceSharedPrefsEdit.putString("mi2_do_not_disturb_start", prefs.getString("do_not_disturb_start", "1:00")); - deviceSharedPrefsEdit.putString("mi2_do_not_disturb_end", prefs.getString("do_not_disturb_end", "6:00")); + deviceSharedPrefsEdit.putString("do_not_disturb", prefs.getString("mi2_do_not_disturb", "off")); + deviceSharedPrefsEdit.putString("do_not_disturb_start", prefs.getString("mi2_do_not_disturb_start", "1:00")); + deviceSharedPrefsEdit.putString("do_not_disturb_end", prefs.getString("mi2_do_not_disturb_end", "6:00")); } switch (deviceType) { + case MIBAND: + deviceSharedPrefsEdit.putBoolean("low_latency_fw_update", prefs.getBoolean("mi_low_latency_fw_update", true)); + break; case AMAZFITCOR: displayItems = prefs.getStringSet("cor_display_items", null); break; @@ -705,6 +708,7 @@ public static String packageNameToPebbleMsgSender(String packageName) { editor.remove("disconnect_notification"); editor.remove("disconnect_notification_start"); editor.remove("disconnect_notification_end"); + editor.remove("mi_low_latency_fw_update"); editor.remove("mi2_do_not_disturb"); editor.remove("mi2_do_not_disturb_start"); editor.remove("mi2_do_not_disturb_end"); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandCoordinator.java index 68806ea59..803eff9d8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandCoordinator.java @@ -36,6 +36,7 @@ import androidx.annotation.NonNull; import de.greenrobot.dao.query.QueryBuilder; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBException; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; @@ -256,6 +257,13 @@ public class MiBandCoordinator extends AbstractDeviceCoordinator { return isMi1S(hwVersion) || isMiPro(hwVersion); } + @Override + public int[] getSupportedDeviceSpecificSettings(GBDevice device) { + return new int[]{ + R.xml.devicesettings_lowlatency_fwupdate + }; + } + private boolean isMi1S(String hardwareVersion) { return MiBandConst.MI_1S.equals(hardwareVersion); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/UpdateFirmwareOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/UpdateFirmwareOperation.java index 035ef65a3..05f99a398 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/UpdateFirmwareOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/UpdateFirmwareOperation.java @@ -33,6 +33,7 @@ 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.MiBandConst; import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandService; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; @@ -187,7 +188,6 @@ public class UpdateFirmwareOperation extends AbstractMiBand1Operation { * The Mi Band will send a notification after receiving these data to confirm if the metadata looks good to it. * * @param newFwVersion - * @see MiBandSupport#handleNotificationNotif */ private UpdateCoordinator prepareFirmwareInfo(byte[] fwBytes, int newFwVersion) throws IOException { int newFwSize = fwBytes.length; @@ -297,7 +297,6 @@ public class UpdateFirmwareOperation extends AbstractMiBand1Operation { * * @param fwbytes * @return whether the transfer succeeded or not. Only a BT layer exception will cause the transmission to fail. - * @see MiBandSupport#handleNotificationNotif */ private boolean sendFirmwareData(byte[] fwbytes) { int len = fwbytes.length; @@ -311,7 +310,7 @@ public class UpdateFirmwareOperation extends AbstractMiBand1Operation { int firmwareProgress = 0; TransactionBuilder builder = performInitialized("send firmware packet"); - if (prefs.getBoolean("mi_low_latency_fw_update", true)) { + if (GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress()).getBoolean("low_latency_fw_update", true)) { getSupport().setLowLatency(builder); } for (int i = 0; i < packets; i++) { diff --git a/app/src/main/res/xml/miband_preferences.xml b/app/src/main/res/xml/miband_preferences.xml index 442e19691..7eac6d9fa 100644 --- a/app/src/main/res/xml/miband_preferences.xml +++ b/app/src/main/res/xml/miband_preferences.xml @@ -464,10 +464,5 @@ android:title="@string/pref_title_keep_data_on_device" android:summary="@string/pref_summary_keep_data_on_device" android:defaultValue="false" /> - \ No newline at end of file