From 5f05a0d88f5229da4ad0b1a40d925c0a9a0cb202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 28 Sep 2023 23:49:19 +0100 Subject: [PATCH] Sony WF-1000XM5: Experimental support --- README.md | 2 +- .../headphones/SonyHeadphonesCoordinator.java | 2 +- .../SonyWF1000XM5Coordinator.java | 89 +++++++++++++++++++ .../gadgetbridge/model/DeviceType.java | 2 + .../headphones/SonyHeadphonesProtocol.java | 1 + .../protocol/impl/v2/SonyProtocolImplV2.java | 2 +- .../protocol/impl/v3/SonyProtocolImplV3.java | 2 +- app/src/main/res/values/strings.xml | 1 + 8 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/coordinators/SonyWF1000XM5Coordinator.java diff --git a/README.md b/README.md index 4e5bccafc..ce2c148a3 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ vendor's servers. - LinkBuds S - WH-1000XM2, WH-1000XM3, WH-1000XM4, WH-1000XM5 - WF-SP800N - - WF-1000XM3, WF-1000XM4 + - WF-1000XM3, WF-1000XM4, WF-1000XM5 (experimental) - [Wena 3](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Sony-Wena-3) - Teclast H10, H30 - TLW64 diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/SonyHeadphonesCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/SonyHeadphonesCoordinator.java index d69a2ff22..4cedffcaf 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/SonyHeadphonesCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/SonyHeadphonesCoordinator.java @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 José Rebelo +/* Copyright (C) 2023 José Rebelo This file is part of Gadgetbridge. diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/coordinators/SonyWF1000XM5Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/coordinators/SonyWF1000XM5Coordinator.java new file mode 100644 index 000000000..23d757408 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/sony/headphones/coordinators/SonyWF1000XM5Coordinator.java @@ -0,0 +1,89 @@ +/* Copyright (C) 2022 José Rebelo + + This file is part of Gadgetbridge. + + Gadgetbridge is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Gadgetbridge is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . */ +package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators; + +import androidx.annotation.NonNull; + +import java.util.Arrays; +import java.util.List; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities; +import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; +import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; + +public class SonyWF1000XM5Coordinator extends SonyHeadphonesCoordinator { + + @NonNull + @Override + public DeviceType getSupportedType(GBDeviceCandidate candidate) { + if (candidate.getName().contains("WF-1000XM5")) { + return DeviceType.SONY_WF_1000XM5; + } + + return DeviceType.UNKNOWN; + } + + @Override + public BatteryConfig[] getBatteryConfig() { + final BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_tws_case, R.string.battery_case); + final BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_galaxy_buds_l, R.string.left_earbud); + final BatteryConfig battery3 = new BatteryConfig(2, R.drawable.ic_galaxy_buds_r, R.string.right_earbud); + + return new BatteryConfig[]{battery1, battery2, battery3}; + } + + @Override + public List getCapabilities() { + return Arrays.asList( + SonyHeadphonesCapabilities.BatteryDual, + SonyHeadphonesCapabilities.BatteryCase, + SonyHeadphonesCapabilities.AmbientSoundControl, + SonyHeadphonesCapabilities.WindNoiseReduction, + SonyHeadphonesCapabilities.EqualizerSimple, + SonyHeadphonesCapabilities.AudioUpsampling, + SonyHeadphonesCapabilities.ButtonModesLeftRight, + SonyHeadphonesCapabilities.PauseWhenTakenOff, + SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff + ); + } + + + @Override + public int getDeviceNameResource() { + return R.string.devicetype_sony_wf_1000xm5; + } + + @Override + public int getDefaultIconResource() { + return R.drawable.ic_device_galaxy_buds; + } + + @Override + public int getDisabledIconResource() { + return R.drawable.ic_device_galaxy_buds_disabled; + } + + @Override + public boolean isExperimental() { + // Ambient Sound Control is not 100% working + // Volume control from headphones is not working? + return true; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java index a57d439ac..a7651a9b8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -122,6 +122,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.soflow.SoFlowCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyLinkBudsSCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM3Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM4Coordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM5Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWFSP800NCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWH1000XM2Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWH1000XM3Coordinator; @@ -254,6 +255,7 @@ public enum DeviceType { SONY_WF_1000XM4(435, SonyWF1000XM4Coordinator.class), SONY_LINKBUDS_S(436, SonyLinkBudsSCoordinator.class), SONY_WH_1000XM5(437, SonyWH1000XM5Coordinator.class), + SONY_WF_1000XM5(438, SonyWF1000XM5Coordinator.class), BOSE_QC35(440, QC35Coordinator.class), VESC_NRF(500, VescCoordinator.class), VESC_HM10(501, VescCoordinator.class), diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/SonyHeadphonesProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/SonyHeadphonesProtocol.java index ae99063e2..b6cf44e18 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/SonyHeadphonesProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/SonyHeadphonesProtocol.java @@ -118,6 +118,7 @@ public class SonyHeadphonesProtocol extends GBDeviceProtocol { case 0x03: // LinkBuds S 2.0.2: 01:00:03:00:00:07:00:00 // WH-1000XM5 1.1.3: 01:00:03:00:00:00:00:00 + // WF-1000XM5 2.0.1: 01:00:03:00:10:04:00:00 protocolImpl = new SonyProtocolImplV3(getDevice()); break; default: diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v2/SonyProtocolImplV2.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v2/SonyProtocolImplV2.java index 1ab83ba75..8120f2bc4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v2/SonyProtocolImplV2.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v2/SonyProtocolImplV2.java @@ -460,7 +460,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 { final AmbientSoundControl ambientSoundControl = new AmbientSoundControl(mode, focusOnVoice, ambientSound); - LOG.warn("Ambient sound control: {}", ambientSoundControl); + LOG.debug("Ambient sound control: {}", ambientSoundControl); final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences() .withPreferences(ambientSoundControl.toPreferences()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v3/SonyProtocolImplV3.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v3/SonyProtocolImplV3.java index 9584e8361..aba528fa8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v3/SonyProtocolImplV3.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/sony/headphones/protocol/impl/v3/SonyProtocolImplV3.java @@ -285,7 +285,7 @@ public class SonyProtocolImplV3 extends SonyProtocolImplV2 { final AmbientSoundControl ambientSoundControl = new AmbientSoundControl(mode, focusOnVoice, ambientSound); - LOG.warn("Ambient sound control: {}", ambientSoundControl); + LOG.debug("Ambient sound control: {}", ambientSoundControl); final GBDeviceEventUpdatePreferences eventUpdatePreferences = new GBDeviceEventUpdatePreferences() .withPreferences(ambientSoundControl.toPreferences()); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 23da5e57d..a8314b1a4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1367,6 +1367,7 @@ Sony WF-SP800N Sony WF-1000XM3 Sony WF-1000XM4 + Sony WF-1000XM5 Sony LinkBuds S Binary sensor Choose export location