mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Add debug setting to override BUSY_CHECKING
This commit is contained in:
+6
-1
@@ -1614,9 +1614,14 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
||||
}
|
||||
}
|
||||
if (BuildConfig.DEBUG) {
|
||||
final int[] debugSettings = coordinator.getSupportedDebugSettings(device);
|
||||
deviceSpecificSettings.addRootScreen(
|
||||
DeviceSpecificSettingsScreen.DEVELOPER,
|
||||
R.xml.devicesettings_stress_test
|
||||
R.xml.devicesettings_header_debug
|
||||
);
|
||||
deviceSpecificSettings.addRootScreen(
|
||||
DeviceSpecificSettingsScreen.DEVELOPER,
|
||||
debugSettings
|
||||
);
|
||||
}
|
||||
if (GBApplication.getPrefs().experimentalSettings()) {
|
||||
|
||||
+8
@@ -969,6 +969,14 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSupportedDebugSettings(final GBDevice device) {
|
||||
return new int[] {
|
||||
R.xml.devicesettings_stress_test,
|
||||
R.xml.devicesettings_disable_busy_checking,
|
||||
};
|
||||
}
|
||||
|
||||
public boolean experimentalSettingEnabled(final GBDevice device, final String key) {
|
||||
return GBApplication.getPrefs().experimentalSettings() && GBApplication.getDevicePrefs(device).getBoolean(key, false);
|
||||
}
|
||||
|
||||
@@ -813,6 +813,11 @@ public interface DeviceCoordinator {
|
||||
*/
|
||||
int[] getSupportedDeviceSpecificAuthenticationSettings();
|
||||
|
||||
/**
|
||||
* Returns device specific debug settings. This section is only shown in debug builds.
|
||||
*/
|
||||
int[] getSupportedDebugSettings(final GBDevice device);
|
||||
|
||||
/**
|
||||
* Returns device specific experimental settings. This screen is only shown when the global experimental settings
|
||||
* is enabled.
|
||||
|
||||
+12
-1
@@ -33,11 +33,14 @@ import androidx.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.EnumSet;
|
||||
@@ -97,7 +100,15 @@ public class DeviceSupportFactory {
|
||||
|
||||
try {
|
||||
final DeviceSupport supportInstance = (DeviceSupport) supportClass.newInstance();
|
||||
return new ServiceDeviceSupport(supportInstance, coordinator.getInitialFlags());
|
||||
final EnumSet<ServiceDeviceSupport.Flags> initialFlags = coordinator.getInitialFlags();
|
||||
if (BuildConfig.DEBUG && initialFlags.contains(ServiceDeviceSupport.Flags.BUSY_CHECKING)) {
|
||||
final DevicePrefs devicePrefs = GBApplication.getDevicePrefs(device);
|
||||
if (devicePrefs.getBoolean("pref_device_debug_remove_busy_checking", false)) {
|
||||
LOG.warn("Removing BUSY_CHECKING flag from {}", device.getAddress());
|
||||
initialFlags.remove(ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
||||
}
|
||||
}
|
||||
return new ServiceDeviceSupport(supportInstance, initialFlags);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
LOG.error("error calling DeviceSupport constructor for {} with zero arguments", device.getAddress());
|
||||
throw new GBException(e);
|
||||
|
||||
+3
-3
@@ -52,7 +52,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.WorldClock;
|
||||
* Wraps another device support instance and supports busy-checking and throttling of events.
|
||||
*/
|
||||
public class ServiceDeviceSupport implements DeviceSupport {
|
||||
public static enum Flags {
|
||||
public enum Flags {
|
||||
THROTTLING,
|
||||
BUSY_CHECKING,
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
||||
return false;
|
||||
}
|
||||
if (getDevice().isBusy()) {
|
||||
LOG.info("Ignoring " + notificationKind + " because we're busy with " + getDevice().getBusyTask());
|
||||
LOG.info("Ignoring {} because we're busy with {}", notificationKind, getDevice().getBusyTask());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -164,7 +164,7 @@ public class ServiceDeviceSupport implements DeviceSupport {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if ((currentTime - lastNotificationTime) < THROTTLING_THRESHOLD) {
|
||||
if (notificationKind != null && notificationKind.equals(lastNotificationKind)) {
|
||||
LOG.info("Ignoring " + notificationKind + " because of throttling threshold reached");
|
||||
LOG.info("Ignoring {} because of throttling threshold reached", notificationKind);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_block"
|
||||
android:key="pref_device_debug_remove_busy_checking"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="Remove the BUSY_CHECKING flag from the ServiceDeviceSupport"
|
||||
android:title="Bypass BUSY_CHECKING" />
|
||||
</PreferenceScreen>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory
|
||||
android:key="pref_header_debug"
|
||||
android:title="@string/action_debug" />
|
||||
</androidx.preference.PreferenceScreen>
|
||||
@@ -1,30 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory android:title="@string/device_stress_test_category" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_skull"
|
||||
android:key="pref_device_stress_test_dispose"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/device_stress_test_dispose_summary"
|
||||
android:title="@string/device_stress_test_dispose_title" />
|
||||
android:key="pref_screen_dangerous_stress_test"
|
||||
android:title="@string/device_stress_test_category">
|
||||
|
||||
<SeekBarPreference
|
||||
android:defaultValue="0"
|
||||
android:icon="@drawable/ic_skull"
|
||||
android:key="pref_device_stress_test_connect_count"
|
||||
android:max="20"
|
||||
android:summary="@string/device_stress_test_connect_count_summary"
|
||||
android:title="@string/device_stress_test_connect_count_title"
|
||||
app:showSeekBarValue="true" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_skull"
|
||||
android:key="pref_device_stress_test_dispose"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/device_stress_test_dispose_summary"
|
||||
android:title="@string/device_stress_test_dispose_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_skull"
|
||||
android:key="pref_device_stress_test_connect_parallel"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/device_stress_test_connect_parallel_summary"
|
||||
android:title="@string/device_stress_test_connect_parallel_title" />
|
||||
<SeekBarPreference
|
||||
android:defaultValue="0"
|
||||
android:icon="@drawable/ic_skull"
|
||||
android:key="pref_device_stress_test_connect_count"
|
||||
android:max="20"
|
||||
android:summary="@string/device_stress_test_connect_count_summary"
|
||||
android:title="@string/device_stress_test_connect_count_title"
|
||||
app:showSeekBarValue="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_skull"
|
||||
android:key="pref_device_stress_test_connect_parallel"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/device_stress_test_connect_parallel_summary"
|
||||
android:title="@string/device_stress_test_connect_parallel_title" />
|
||||
</PreferenceScreen>
|
||||
</PreferenceScreen>
|
||||
|
||||
Reference in New Issue
Block a user