From c4874de11aa0808ecd6fff07d072dc61bfa9d152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Fri, 24 Dec 2021 14:20:57 +0000 Subject: [PATCH] Sony WF-SP800N: Initial Support --- README.md | 2 +- .../DeviceSettingsPreferenceConst.java | 3 + .../DeviceSpecificSettingsFragment.java | 6 + .../adapter/GBDeviceAdapterv2.java | 27 ++- .../devices/AbstractDeviceCoordinator.java | 5 +- .../devices/DeviceCoordinator.java | 1 + .../gadgetbridge/devices/EventHandler.java | 2 + .../coordinators/SonyWFSP800NCoordinator.java | 76 +++++++++ .../SonyWH1000XM3Coordinator.java | 2 +- .../sony/headphones/prefs/ButtonModes.java | 74 ++++++++ .../headphones/prefs/PauseWhenTakenOff.java | 46 +++++ .../gadgetbridge/impl/GBDeviceService.java | 6 + .../gadgetbridge/model/DeviceService.java | 1 + .../gadgetbridge/model/DeviceType.java | 1 + .../service/DeviceCommunicationService.java | 4 + .../service/DeviceSupportFactory.java | 3 + .../service/ServiceDeviceSupport.java | 8 + .../btle/AbstractBTLEDeviceSupport.java | 6 + .../headphones/SonyHeadphonesIoThread.java | 1 + .../headphones/SonyHeadphonesProtocol.java | 22 +++ .../impl/AbstractSonyProtocolImpl.java | 12 ++ .../protocol/impl/v1/PayloadType.java | 2 + .../protocol/impl/v1/SonyProtocolImplV1.java | 159 +++++++++++++++++- .../serial/AbstractSerialDeviceSupport.java | 6 + .../service/serial/GBDeviceProtocol.java | 4 + .../gadgetbridge/util/DeviceHelper.java | 2 + app/src/main/res/drawable/ic_pause.xml | 10 ++ app/src/main/res/layout/device_itemv2.xml | 14 ++ app/src/main/res/values-pt/strings.xml | 4 + app/src/main/res/values/arrays.xml | 40 ++++- app/src/main/res/values/strings.xml | 11 ++ ...ent_sound_control_wind_noise_reduction.xml | 31 ++++ ...ony_headphones_button_modes_left_right.xml | 20 +++ ...s_sony_headphones_pause_when_taken_off.xml | 8 + .../res/xml/devicesettings_sony_wf_sp800n.xml | 11 ++ 35 files changed, 619 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/coordinators/SonyWFSP800NCoordinator.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/prefs/ButtonModes.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/prefs/PauseWhenTakenOff.java create mode 100644 app/src/main/res/drawable/ic_pause.xml create mode 100644 app/src/main/res/xml/devicesettings_sony_headphones_ambient_sound_control_wind_noise_reduction.xml create mode 100644 app/src/main/res/xml/devicesettings_sony_headphones_button_modes_left_right.xml create mode 100644 app/src/main/res/xml/devicesettings_sony_headphones_pause_when_taken_off.xml create mode 100644 app/src/main/res/xml/devicesettings_sony_wf_sp800n.xml diff --git a/README.md b/README.md index c71a4bab5..96fa952ea 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ vendor's servers. - PineTime (InfiniTime Firmware) - Roidmi, Roidmi 3, Mojietu 3 (Bluetooth FM Transmitters) - [SMA](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/SMA) Q2 (SMA-Q2-OSS Firmware) -- Sony WH-1000XM3 +- Sony WH-1000XM3, WF-SP800N - Teclast H10, H30 - TLW64 - Vibratissimo (Experimental) 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 cda7bf042..231912ae6 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 @@ -127,6 +127,9 @@ public class DeviceSettingsPreferenceConst { public static final String PREF_SONY_EQUALIZER_BAND_16000 = "pref_sony_equalizer_band_16000"; public static final String PREF_SONY_EQUALIZER_BASS = "pref_sony_equalizer_bass"; public static final String PREF_SONY_TOUCH_SENSOR = "pref_sony_touch_sensor"; + public static final String PREF_SONY_PAUSE_WHEN_TAKEN_OFF = "sony_pause_when_taken_off"; + public static final String PREF_SONY_BUTTON_MODE_LEFT = "pref_sony_button_mode_left"; + public static final String PREF_SONY_BUTTON_MODE_RIGHT = "pref_sony_button_mode_right"; public static final String PREF_SONY_AUTOMATIC_POWER_OFF = "pref_sony_automatic_power_off"; public static final String PREF_SONY_NOTIFICATION_VOICE_GUIDE = "pref_sony_notification_voice_guide"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java index b3258de1d..e0371502e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java @@ -121,6 +121,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONYSWR12_LOW_VIBRATION; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONYSWR12_SMART_INTERVAL; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONYSWR12_STAMINA; +import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_PAUSE_WHEN_TAKEN_OFF; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SOUNDS; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_VIBRATION_STRENGH_PERCENTAGE; @@ -142,6 +143,8 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BASS; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_UPSAMPLING; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_TOUCH_SENSOR; +import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_BUTTON_MODE_RIGHT; +import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_BUTTON_MODE_LEFT; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AUTOMATIC_POWER_OFF; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_NOTIFICATION_VOICE_GUIDE; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREFS_ACTIVITY_IN_DEVICE_CARD; @@ -560,6 +563,9 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat imp addPreferenceHandlerFor(PREF_SONY_EQUALIZER_BASS); addPreferenceHandlerFor(PREF_SONY_AUDIO_UPSAMPLING); addPreferenceHandlerFor(PREF_SONY_TOUCH_SENSOR); + addPreferenceHandlerFor(PREF_SONY_PAUSE_WHEN_TAKEN_OFF); + addPreferenceHandlerFor(PREF_SONY_BUTTON_MODE_LEFT); + addPreferenceHandlerFor(PREF_SONY_BUTTON_MODE_RIGHT); addPreferenceHandlerFor(PREF_SONY_AUTOMATIC_POWER_OFF); addPreferenceHandlerFor(PREF_SONY_NOTIFICATION_VOICE_GUIDE); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java index 51edd2a75..c31ae60fd 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java @@ -139,7 +139,7 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter