XiaomiHealthService: make GPS timeout configurable

- my miband 9 does not work with the default 5s timeout, increasing the timeout makes the device function properly
This commit is contained in:
Simon Brand 2025-02-12 17:57:41 +00:00 committed by José Rebelo
parent b164397467
commit cdd561c496
5 changed files with 16 additions and 1 deletions

View File

@ -242,6 +242,7 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_WORKOUT_START_ON_PHONE = "workout_start_on_phone";
public static final String PREF_WORKOUT_SEND_GPS_TO_BAND = "workout_send_gps_to_band";
public static final String PREF_WORKOUT_SEND_GPS_TO_BAND_TIMEOUT = "workout_send_gps_to_band_timeout";
public static final String PREF_WORKOUT_DETECTION_CATEGORIES = "workout_detection_categories";
public static final String PREF_WORKOUT_DETECTION_ALERT = "workout_detection_alert";
public static final String PREF_WORKOUT_DETECTION_SENSITIVITY = "workout_detection_sensitivity";

View File

@ -461,6 +461,7 @@ public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
final List<Integer> workout = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.WORKOUT);
workout.add(R.xml.devicesettings_workout_start_on_phone);
workout.add(R.xml.devicesettings_workout_send_gps_to_band);
workout.add(R.xml.devicesettings_workout_send_gps_to_band_timeout);
//
// Notifications

View File

@ -672,6 +672,7 @@ public class XiaomiHealthService extends AbstractXiaomiService {
GBLocationService.start(getSupport().getContext(), getSupport().getDevice(), GBLocationProviderType.GPS, 1000);
}
final int timeout = getDevicePrefs().getInt(DeviceSettingsPreferenceConst.PREF_WORKOUT_SEND_GPS_TO_BAND_TIMEOUT, 5000);
gpsTimeoutHandler.removeCallbacksAndMessages(null);
// Timeout if the watch stops sending workout open
gpsTimeoutHandler.postDelayed(() -> {
@ -679,7 +680,7 @@ public class XiaomiHealthService extends AbstractXiaomiService {
gpsStarted = false;
gpsFixAcquired = false;
GBLocationService.stop(getSupport().getContext(), getSupport().getDevice());
}, 5000);
}, timeout);
}
private void handleWorkoutStatus(final XiaomiProto.WorkoutStatusWatch workoutStatus) {

View File

@ -579,6 +579,8 @@
<string name="pref_workout_start_on_phone_summary">Start/stop fitness app tracking on phone when a GPS workout is started on the band</string>
<string name="pref_workout_send_gps_title">Send GPS during workout</string>
<string name="pref_workout_send_gps_summary">Send the current GPS location to the band during a workout</string>
<string name="pref_workout_send_gps_timeout_title">Send GPS timeout</string>
<string name="pref_workout_send_gps_timeout_summary">Stop sending GPS when device does not send workout is open (milliseconds)</string>
<string name="pref_workout_keep_screen_on_title">Keep screen on during a workout</string>
<string name="pref_workout_keep_screen_on_summary">The screen will stay on during a workout, and brightness will be adjusted to continuously display real-time workout data</string>
<string name="pref_workout_detection_title">Workout Detection</string>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:defaultValue="5000"
android:inputType="number"
android:icon="@drawable/ic_gps_location"
android:key="workout_send_gps_to_band_timeout"
android:title="@string/pref_workout_send_gps_timeout_title"
android:summary="@string/pref_workout_send_gps_timeout_summary" />
</androidx.preference.PreferenceScreen>