diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java
index cc24f2715..8963da73a 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java
@@ -22,4 +22,5 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_WEARLOCATION = "wearlocation";
public static final String PREF_SCREEN_ORIENTATION = "screen_orientation";
public static final String PREF_RESERVER_ALARMS_CALENDAR = "reserve_alarms_calendar";
+ public static final String PREF_ALLOW_HIGH_MTU = "allow_high_mtu";
}
\ No newline at end of file
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java
index 0a00cb149..b1e22b125 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband4/MiBand4Coordinator.java
@@ -97,7 +97,8 @@ public class MiBand4Coordinator extends HuamiCoordinator {
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_swipeunlock,
R.xml.devicesettings_expose_hr_thirdparty,
- R.xml.devicesettings_pairingkey
+ R.xml.devicesettings_pairingkey,
+ R.xml.devicesettings_high_mtu
};
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java
index 9fe2f3004..cee8549e9 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java
@@ -25,7 +25,6 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
-import android.text.format.DateFormat;
import android.widget.Toast;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -55,7 +54,6 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.Logging;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
-import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
@@ -136,6 +134,11 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
import nodomain.freeyourgadget.gadgetbridge.util.Version;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALLOW_HIGH_MTU;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_DATEFORMAT;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
+import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_COUNT;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_PROFILE;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.VIBRATION_COUNT;
@@ -1250,6 +1253,10 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
case HuamiDeviceEvent.MTU_REQUEST:
int mtu = (value[2] & 0xff) << 8 | value[1] & 0xff;
LOG.info("device announced MTU of " + mtu);
+ Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
+ if (!prefs.getBoolean(PREF_ALLOW_HIGH_MTU, false)) {
+ break;
+ }
mMTU = mtu;
/*
* not really sure if this would make sense, is this event already a proof of a successful MTU
@@ -1673,7 +1680,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
BluetoothGattCharacteristic characteristic = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION);
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
- int availableSlots = prefs.getInt(DeviceSettingsPreferenceConst.PREF_RESERVER_ALARMS_CALENDAR, 0);
+ int availableSlots = prefs.getInt(PREF_RESERVER_ALARMS_CALENDAR, 0);
if (availableSlots > 0) {
CalendarEvents upcomingEvents = new CalendarEvents();
@@ -1747,10 +1754,10 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
case MiBandConst.PREF_SWIPE_UNLOCK:
setBandScreenUnlock(builder);
break;
- case DeviceSettingsPreferenceConst.PREF_TIMEFORMAT:
+ case PREF_TIMEFORMAT:
setTimeFormat(builder);
break;
- case DeviceSettingsPreferenceConst.PREF_DATEFORMAT:
+ case PREF_DATEFORMAT:
setDateFormat(builder);
break;
case HuamiConst.PREF_LANGUAGE:
@@ -1759,7 +1766,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
case HuamiConst.PREF_EXPOSE_HR_THIRDPARTY:
setExposeHRThridParty(builder);
break;
- case DeviceSettingsPreferenceConst.PREF_WEARLOCATION:
+ case PREF_WEARLOCATION:
setWearLocation(builder);
break;
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2f900b079..c3b916aa3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -180,6 +180,8 @@
3rd party realtime HR access
Use custom font
Enable this if your device has a custom font firmware for emoji support
+ Allow high MTU
+ Will increase transfer speed, but might not work with some Android devices
Connect new device button
Always visible
Visible only if no device is added
diff --git a/app/src/main/res/xml/devicesettings_high_mtu.xml b/app/src/main/res/xml/devicesettings_high_mtu.xml
new file mode 100644
index 000000000..9751da642
--- /dev/null
+++ b/app/src/main/res/xml/devicesettings_high_mtu.xml
@@ -0,0 +1,8 @@
+
+
+
+