mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Sony: WH-1000XM3 add support for LDAC and NC/AMBIENT button switch (#5990)
Implements missing features from [WH-1000XM3](https://gadgetbridge.org/gadgets/headphones/sony/#device__sony_wh-1000xm3): - Sound Quality Mode (SBC Codec / HD codecs) - Added as a switch (boolean) in UI - Note that LDAC option can appear in Andoid Bluetooth Device settings as well as unselected. Some Android devices (eg. Samsung) will also allow changing the BT Codec in Developer Settings, but if this is not enabled, the change won't apply. - Function of NC/AMBIENT button - Allows using either Google Assistant or Alexa Assistant. - This model does not support "system assistant", used for other non-Google/Alexa assistants. Reviewed-on: https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/5990 Co-authored-by: duhow <contacto@duhowpi.net> Co-committed-by: duhow <contacto@duhowpi.net>
This commit is contained in:
+2
@@ -552,6 +552,8 @@ public class DeviceSettingsPreferenceConst {
|
|||||||
public static final String PREF_SONY_SURROUND_MODE = "pref_sony_surround_mode";
|
public static final String PREF_SONY_SURROUND_MODE = "pref_sony_surround_mode";
|
||||||
public static final String PREF_SONY_EQUALIZER = "pref_sony_equalizer";
|
public static final String PREF_SONY_EQUALIZER = "pref_sony_equalizer";
|
||||||
public static final String PREF_SONY_EQUALIZER_MODE = "pref_sony_equalizer_mode";
|
public static final String PREF_SONY_EQUALIZER_MODE = "pref_sony_equalizer_mode";
|
||||||
|
public static final String PREF_SONY_AUDIO_HD = "pref_sony_audio_hd";
|
||||||
|
public static final String PREF_SONY_BUTTON_FUNCTION_NC_AMBIENT = "pref_sony_button_function_nc_ambient";
|
||||||
public static final String PREF_SONY_AUDIO_UPSAMPLING = "pref_sony_audio_upsampling";
|
public static final String PREF_SONY_AUDIO_UPSAMPLING = "pref_sony_audio_upsampling";
|
||||||
public static final String PREF_SONY_EQUALIZER_BAND_400 = "pref_sony_equalizer_band_400";
|
public static final String PREF_SONY_EQUALIZER_BAND_400 = "pref_sony_equalizer_band_400";
|
||||||
public static final String PREF_SONY_EQUALIZER_BAND_1000 = "pref_sony_equalizer_band_1000";
|
public static final String PREF_SONY_EQUALIZER_BAND_1000 = "pref_sony_equalizer_band_1000";
|
||||||
|
|||||||
+2
@@ -840,6 +840,8 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
|||||||
addPreferenceHandlerFor(PREF_SONY_EQUALIZER_BAND_6300);
|
addPreferenceHandlerFor(PREF_SONY_EQUALIZER_BAND_6300);
|
||||||
addPreferenceHandlerFor(PREF_SONY_EQUALIZER_BAND_16000);
|
addPreferenceHandlerFor(PREF_SONY_EQUALIZER_BAND_16000);
|
||||||
addPreferenceHandlerFor(PREF_SONY_EQUALIZER_BASS);
|
addPreferenceHandlerFor(PREF_SONY_EQUALIZER_BASS);
|
||||||
|
addPreferenceHandlerFor(PREF_SONY_AUDIO_HD);
|
||||||
|
addPreferenceHandlerFor(PREF_SONY_BUTTON_FUNCTION_NC_AMBIENT);
|
||||||
addPreferenceHandlerFor(PREF_SONY_AUDIO_UPSAMPLING);
|
addPreferenceHandlerFor(PREF_SONY_AUDIO_UPSAMPLING);
|
||||||
addPreferenceHandlerFor(PREF_SONY_TOUCH_SENSOR);
|
addPreferenceHandlerFor(PREF_SONY_TOUCH_SENSOR);
|
||||||
addPreferenceHandlerFor(PREF_SONY_PAUSE_WHEN_TAKEN_OFF);
|
addPreferenceHandlerFor(PREF_SONY_PAUSE_WHEN_TAKEN_OFF);
|
||||||
|
|||||||
+2
@@ -23,6 +23,7 @@ public enum SonyHeadphonesCapabilities {
|
|||||||
AmbientSoundControlButtonMode,
|
AmbientSoundControlButtonMode,
|
||||||
AncOptimizer,
|
AncOptimizer,
|
||||||
AudioSettingsOnlyOnSbcCodec,
|
AudioSettingsOnlyOnSbcCodec,
|
||||||
|
AudioLDAC,
|
||||||
AudioUpsampling,
|
AudioUpsampling,
|
||||||
AutomaticPowerOffByTime,
|
AutomaticPowerOffByTime,
|
||||||
AutomaticPowerOffWhenTakenOff,
|
AutomaticPowerOffWhenTakenOff,
|
||||||
@@ -31,6 +32,7 @@ public enum SonyHeadphonesCapabilities {
|
|||||||
BatteryDual2,
|
BatteryDual2,
|
||||||
BatterySingle,
|
BatterySingle,
|
||||||
ButtonModesLeftRight,
|
ButtonModesLeftRight,
|
||||||
|
ButtonFunctionNcAmbient,
|
||||||
EqualizerSimple,
|
EqualizerSimple,
|
||||||
EqualizerWithCustomBands,
|
EqualizerWithCustomBands,
|
||||||
NoNoiseCancelling,
|
NoNoiseCancelling,
|
||||||
|
|||||||
+2
@@ -146,6 +146,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
|
|
||||||
addSettingsUnderHeader(deviceSpecificSettings, device, R.xml.devicesettings_header_other, new LinkedHashMap<>() {{
|
addSettingsUnderHeader(deviceSpecificSettings, device, R.xml.devicesettings_header_other, new LinkedHashMap<>() {{
|
||||||
put(SonyHeadphonesCapabilities.AudioSettingsOnlyOnSbcCodec, R.xml.devicesettings_sony_warning_wh1000xm3);
|
put(SonyHeadphonesCapabilities.AudioSettingsOnlyOnSbcCodec, R.xml.devicesettings_sony_warning_wh1000xm3);
|
||||||
|
put(SonyHeadphonesCapabilities.AudioLDAC, R.xml.devicesettings_sony_headphones_audio_hd);
|
||||||
put(SonyHeadphonesCapabilities.EqualizerSimple, R.xml.devicesettings_sony_headphones_equalizer);
|
put(SonyHeadphonesCapabilities.EqualizerSimple, R.xml.devicesettings_sony_headphones_equalizer);
|
||||||
put(SonyHeadphonesCapabilities.EqualizerWithCustomBands, R.xml.devicesettings_sony_headphones_equalizer_with_custom_bands);
|
put(SonyHeadphonesCapabilities.EqualizerWithCustomBands, R.xml.devicesettings_sony_headphones_equalizer_with_custom_bands);
|
||||||
put(SonyHeadphonesCapabilities.SoundPosition, R.xml.devicesettings_sony_headphones_sound_position);
|
put(SonyHeadphonesCapabilities.SoundPosition, R.xml.devicesettings_sony_headphones_sound_position);
|
||||||
@@ -162,6 +163,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
|||||||
put(SonyHeadphonesCapabilities.ButtonModesLeftRight, R.xml.devicesettings_sony_headphones_button_modes_left_right);
|
put(SonyHeadphonesCapabilities.ButtonModesLeftRight, R.xml.devicesettings_sony_headphones_button_modes_left_right);
|
||||||
put(SonyHeadphonesCapabilities.AmbientSoundControlButtonMode, R.xml.devicesettings_sony_headphones_ambient_sound_control_button_modes);
|
put(SonyHeadphonesCapabilities.AmbientSoundControlButtonMode, R.xml.devicesettings_sony_headphones_ambient_sound_control_button_modes);
|
||||||
put(SonyHeadphonesCapabilities.QuickAccess, R.xml.devicesettings_sony_headphones_quick_access);
|
put(SonyHeadphonesCapabilities.QuickAccess, R.xml.devicesettings_sony_headphones_quick_access);
|
||||||
|
put(SonyHeadphonesCapabilities.ButtonFunctionNcAmbient, R.xml.devicesettings_sony_headphones_button_function_nc_ambient);
|
||||||
put(SonyHeadphonesCapabilities.TouchSensorSingle, R.xml.devicesettings_sony_headphones_touch_sensor_single);
|
put(SonyHeadphonesCapabilities.TouchSensorSingle, R.xml.devicesettings_sony_headphones_touch_sensor_single);
|
||||||
put(SonyHeadphonesCapabilities.PauseWhenTakenOff, R.xml.devicesettings_sony_headphones_pause_when_taken_off);
|
put(SonyHeadphonesCapabilities.PauseWhenTakenOff, R.xml.devicesettings_sony_headphones_pause_when_taken_off);
|
||||||
put(SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff, R.xml.devicesettings_automatic_power_off_when_taken_off);
|
put(SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff, R.xml.devicesettings_automatic_power_off_when_taken_off);
|
||||||
|
|||||||
+2
@@ -47,6 +47,8 @@ public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
|||||||
SonyHeadphonesCapabilities.WindNoiseReduction,
|
SonyHeadphonesCapabilities.WindNoiseReduction,
|
||||||
SonyHeadphonesCapabilities.AncOptimizer,
|
SonyHeadphonesCapabilities.AncOptimizer,
|
||||||
SonyHeadphonesCapabilities.AudioSettingsOnlyOnSbcCodec,
|
SonyHeadphonesCapabilities.AudioSettingsOnlyOnSbcCodec,
|
||||||
|
SonyHeadphonesCapabilities.AudioLDAC,
|
||||||
|
SonyHeadphonesCapabilities.ButtonFunctionNcAmbient,
|
||||||
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
||||||
SonyHeadphonesCapabilities.SoundPosition,
|
SonyHeadphonesCapabilities.SoundPosition,
|
||||||
SonyHeadphonesCapabilities.SurroundMode,
|
SonyHeadphonesCapabilities.SurroundMode,
|
||||||
|
|||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
/* Copyright (C) 2026
|
||||||
|
|
||||||
|
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 <https://www.gnu.org/licenses/>. */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||||
|
|
||||||
|
public class AudioLDAC {
|
||||||
|
private final boolean enabled;
|
||||||
|
|
||||||
|
public AudioLDAC(final boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> toPreferences() {
|
||||||
|
return new HashMap<String, Object>() {{
|
||||||
|
put(DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_HD, enabled);
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AudioLDAC fromPreferences(final SharedPreferences prefs) {
|
||||||
|
return new AudioLDAC(prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_HD, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
+83
@@ -0,0 +1,83 @@
|
|||||||
|
/* Copyright (C) 2026
|
||||||
|
|
||||||
|
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 <https://www.gnu.org/licenses/>. */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||||
|
|
||||||
|
public class ButtonFunctionNcAmbient {
|
||||||
|
public enum Mode {
|
||||||
|
SWITCH_AMBIENT_SOUND("switch_ambient_sound", 0x00),
|
||||||
|
GOOGLE_ASSISTANT("google_assistant", 0x01),
|
||||||
|
ALEXA_ASSISTANT("alexa_assistant", 0x02);
|
||||||
|
|
||||||
|
private final String prefValue;
|
||||||
|
private final byte code;
|
||||||
|
|
||||||
|
Mode(final String prefValue, final int code) {
|
||||||
|
this.prefValue = prefValue;
|
||||||
|
this.code = (byte) code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefValue() {
|
||||||
|
return prefValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Mode fromPrefValue(final String prefValue) {
|
||||||
|
for (final Mode mode : values()) {
|
||||||
|
if (mode.prefValue.equals(prefValue)) {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SWITCH_AMBIENT_SOUND;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Mode mode;
|
||||||
|
|
||||||
|
public ButtonFunctionNcAmbient(final Mode mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mode getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> toPreferences() {
|
||||||
|
return new HashMap<String, Object>() {{
|
||||||
|
put(DeviceSettingsPreferenceConst.PREF_SONY_BUTTON_FUNCTION_NC_AMBIENT, mode.getPrefValue());
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ButtonFunctionNcAmbient fromPreferences(final SharedPreferences prefs) {
|
||||||
|
final String pref = prefs.getString(
|
||||||
|
DeviceSettingsPreferenceConst.PREF_SONY_BUTTON_FUNCTION_NC_AMBIENT,
|
||||||
|
Mode.SWITCH_AMBIENT_SOUND.getPrefValue()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new ButtonFunctionNcAmbient(Mode.fromPrefValue(pref));
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -22,6 +22,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
@@ -35,8 +36,10 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePref
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioLDAC;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonFunctionNcAmbient;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
||||||
@@ -228,6 +231,16 @@ public class SonyHeadphonesProtocol extends GBDeviceProtocol {
|
|||||||
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BASS:
|
case DeviceSettingsPreferenceConst.PREF_SONY_EQUALIZER_BASS:
|
||||||
configRequest = protocolImpl.setEqualizerCustomBands(EqualizerCustomBands.fromPreferences(prefs));
|
configRequest = protocolImpl.setEqualizerCustomBands(EqualizerCustomBands.fromPreferences(prefs));
|
||||||
break;
|
break;
|
||||||
|
case DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_HD:
|
||||||
|
configRequest = protocolImpl.setAudioLDAC(AudioLDAC.fromPreferences(prefs));
|
||||||
|
break;
|
||||||
|
case DeviceSettingsPreferenceConst.PREF_SONY_BUTTON_FUNCTION_NC_AMBIENT:
|
||||||
|
configRequest = protocolImpl.setButtonFunctionNcAmbient(ButtonFunctionNcAmbient.fromPreferences(prefs));
|
||||||
|
final Request rebootRequest = protocolImpl.reboot();
|
||||||
|
if (rebootRequest != null) {
|
||||||
|
enqueueRequests(Collections.singletonList(rebootRequest));
|
||||||
|
}
|
||||||
|
break;
|
||||||
case DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_UPSAMPLING:
|
case DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_UPSAMPLING:
|
||||||
configRequest = protocolImpl.setAudioUpsampling(AudioUpsampling.fromPreferences(prefs));
|
configRequest = protocolImpl.setAudioUpsampling(AudioUpsampling.fromPreferences(prefs));
|
||||||
break;
|
break;
|
||||||
@@ -302,6 +315,28 @@ public class SonyHeadphonesProtocol extends GBDeviceProtocol {
|
|||||||
return super.encodePowerOff();
|
return super.encodePowerOff();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] encodeReset(final int flags) {
|
||||||
|
if ((flags & RESET_FLAGS_REBOOT) == 0) {
|
||||||
|
return super.encodeReset(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (protocolImpl == null) {
|
||||||
|
LOG.error("No protocol implementation, ignoring reboot request");
|
||||||
|
return super.encodeReset(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Request rebootRequest = protocolImpl.reboot();
|
||||||
|
if (rebootRequest == null) {
|
||||||
|
LOG.warn("Failed to encode reboot request");
|
||||||
|
return super.encodeReset(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
pendingAcks++;
|
||||||
|
|
||||||
|
return rebootRequest.encode(sequenceNumber);
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] encodeAck(byte sequenceNumber) {
|
public byte[] encodeAck(byte sequenceNumber) {
|
||||||
return new Message(MessageType.ACK, (byte) (1 - sequenceNumber), new byte[0]).encode();
|
return new Message(MessageType.ACK, (byte) (1 - sequenceNumber), new byte[0]).encode();
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -24,8 +24,10 @@ import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphon
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioLDAC;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonFunctionNcAmbient;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
||||||
@@ -86,6 +88,10 @@ public abstract class AbstractSonyProtocolImpl {
|
|||||||
|
|
||||||
public abstract Request getAudioUpsampling();
|
public abstract Request getAudioUpsampling();
|
||||||
|
|
||||||
|
public abstract Request setAudioLDAC(final AudioLDAC config);
|
||||||
|
|
||||||
|
public abstract Request setButtonFunctionNcAmbient(final ButtonFunctionNcAmbient config);
|
||||||
|
|
||||||
public abstract Request setAudioUpsampling(final AudioUpsampling config);
|
public abstract Request setAudioUpsampling(final AudioUpsampling config);
|
||||||
|
|
||||||
public abstract Request getAutomaticPowerOff();
|
public abstract Request getAutomaticPowerOff();
|
||||||
@@ -138,6 +144,8 @@ public abstract class AbstractSonyProtocolImpl {
|
|||||||
|
|
||||||
public abstract Request powerOff();
|
public abstract Request powerOff();
|
||||||
|
|
||||||
|
public abstract Request reboot();
|
||||||
|
|
||||||
public abstract Request getVolume();
|
public abstract Request getVolume();
|
||||||
|
|
||||||
public abstract Request setVolume(final int volume);
|
public abstract Request setVolume(final int volume);
|
||||||
|
|||||||
+41
@@ -42,8 +42,10 @@ import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphon
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioLDAC;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonFunctionNcAmbient;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
||||||
@@ -259,6 +261,32 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Request setAudioLDAC(final AudioLDAC config) {
|
||||||
|
return new Request(
|
||||||
|
PayloadTypeV1.AUDIO_UPSAMPLING_SET.getMessageType(),
|
||||||
|
new byte[]{
|
||||||
|
PayloadTypeV1.AUDIO_UPSAMPLING_SET.getCode(),
|
||||||
|
(byte) 0x01,
|
||||||
|
(byte) 0x00,
|
||||||
|
(byte) (config.isEnabled() ? 0x00 : 0x01)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Request setButtonFunctionNcAmbient(final ButtonFunctionNcAmbient config) {
|
||||||
|
return new Request(
|
||||||
|
PayloadTypeV1.TOUCH_SENSOR_SET.getMessageType(),
|
||||||
|
new byte[]{
|
||||||
|
PayloadTypeV1.TOUCH_SENSOR_SET.getCode(),
|
||||||
|
(byte) 0xd1,
|
||||||
|
(byte) 0x02,
|
||||||
|
config.getMode().getCode()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Request setAudioUpsampling(final AudioUpsampling config) {
|
public Request setAudioUpsampling(final AudioUpsampling config) {
|
||||||
return new Request(
|
return new Request(
|
||||||
@@ -546,6 +574,19 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Request reboot() {
|
||||||
|
return new Request(
|
||||||
|
MessageType.COMMAND_1,
|
||||||
|
new byte[]{
|
||||||
|
(byte) 0x98,
|
||||||
|
(byte) 0x01,
|
||||||
|
(byte) 0x02,
|
||||||
|
(byte) 0x01
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Request getVolume() {
|
public Request getVolume() {
|
||||||
return new Request(
|
return new Request(
|
||||||
|
|||||||
+27
@@ -33,8 +33,10 @@ import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphon
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioLDAC;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonFunctionNcAmbient;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
||||||
@@ -223,6 +225,18 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Request setAudioLDAC(final AudioLDAC config) {
|
||||||
|
LOG.warn("Audio LDAC not implemented for V2");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Request setButtonFunctionNcAmbient(final ButtonFunctionNcAmbient config) {
|
||||||
|
LOG.warn("Button function NC ambient not implemented for V2");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Request setAudioUpsampling(final AudioUpsampling config) {
|
public Request setAudioUpsampling(final AudioUpsampling config) {
|
||||||
return new Request(
|
return new Request(
|
||||||
@@ -504,6 +518,19 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Request reboot() {
|
||||||
|
return new Request(
|
||||||
|
MessageType.COMMAND_1,
|
||||||
|
new byte[]{
|
||||||
|
(byte) 0x98,
|
||||||
|
(byte) 0x00,
|
||||||
|
(byte) 0x16,
|
||||||
|
(byte) 0x01
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Request getVolume() {
|
public Request getVolume() {
|
||||||
LOG.warn("Volume not implemented for V2");
|
LOG.warn("Volume not implemented for V2");
|
||||||
|
|||||||
@@ -4473,6 +4473,18 @@
|
|||||||
<item>as_off</item>
|
<item>as_off</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="sony_button_function_nc_ambient_names">
|
||||||
|
<item>@string/sony_button_function_nc_ambient_switch_ambient_sound</item>
|
||||||
|
<item>@string/sony_button_function_nc_ambient_google_assistant</item>
|
||||||
|
<item>@string/sony_button_function_nc_ambient_alexa_assistant</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="sony_button_function_nc_ambient_values">
|
||||||
|
<item>switch_ambient_sound</item>
|
||||||
|
<item>google_assistant</item>
|
||||||
|
<item>alexa_assistant</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string-array name="oppo_touch_tap_names">
|
<string-array name="oppo_touch_tap_names">
|
||||||
<!-- superset of values, unsupported are hidden by the coordinator -->
|
<!-- superset of values, unsupported are hidden by the coordinator -->
|
||||||
<item>@string/sony_button_mode_off</item>
|
<item>@string/sony_button_mode_off</item>
|
||||||
|
|||||||
@@ -3384,7 +3384,12 @@
|
|||||||
<string name="sony_equalizer_band_6300">6.3k</string>
|
<string name="sony_equalizer_band_6300">6.3k</string>
|
||||||
<string name="sony_equalizer_band_16000">16k</string>
|
<string name="sony_equalizer_band_16000">16k</string>
|
||||||
<string name="sony_equalizer_clear_bass">Clear Bass</string>
|
<string name="sony_equalizer_clear_bass">Clear Bass</string>
|
||||||
|
<string name="sony_audio_hd">Audio HD</string>
|
||||||
<string name="sony_audio_upsampling">Audio Upsampling</string>
|
<string name="sony_audio_upsampling">Audio Upsampling</string>
|
||||||
|
<string name="sony_button_function_nc_ambient">NC/Ambient Button Function</string>
|
||||||
|
<string name="sony_button_function_nc_ambient_switch_ambient_sound">Switch ambient sound</string>
|
||||||
|
<string name="sony_button_function_nc_ambient_google_assistant">Google Assistant</string>
|
||||||
|
<string name="sony_button_function_nc_ambient_alexa_assistant">Alexa Assistant</string>
|
||||||
<string name="sony_touch_sensor">Touch sensor control</string>
|
<string name="sony_touch_sensor">Touch sensor control</string>
|
||||||
<string name="pref_wide_area_tap_summary">Recognize taps between cheeks and ears</string>
|
<string name="pref_wide_area_tap_summary">Recognize taps between cheeks and ears</string>
|
||||||
<string name="pref_wide_area_tap_title">Wide area tap</string>
|
<string name="pref_wide_area_tap_title">Wide area tap</string>
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/ic_extension"
|
||||||
|
android:key="pref_sony_audio_hd"
|
||||||
|
android:layout="@layout/preference_checkbox"
|
||||||
|
android:title="@string/sony_audio_hd" />
|
||||||
|
</androidx.preference.PreferenceScreen>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="switch_ambient_sound"
|
||||||
|
android:entries="@array/sony_button_function_nc_ambient_names"
|
||||||
|
android:entryValues="@array/sony_button_function_nc_ambient_values"
|
||||||
|
android:icon="@drawable/ic_touch"
|
||||||
|
android:key="pref_sony_button_function_nc_ambient"
|
||||||
|
app:useSimpleSummaryProvider="true"
|
||||||
|
android:title="@string/sony_button_function_nc_ambient" />
|
||||||
|
</androidx.preference.PreferenceScreen>
|
||||||
+25
@@ -34,8 +34,10 @@ import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphon
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioLDAC;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonFunctionNcAmbient;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonModes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
||||||
@@ -221,6 +223,29 @@ public class SonyProtocolImplV1Test {
|
|||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setAudioLDAC() {
|
||||||
|
assertRequests(protocol::setAudioLDAC, new LinkedHashMap<AudioLDAC, String>() {{
|
||||||
|
put(new AudioLDAC(false), "e8:01:00:01");
|
||||||
|
put(new AudioLDAC(true), "e8:01:00:00");
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setButtonFunctionNcAmbient() {
|
||||||
|
assertRequests(protocol::setButtonFunctionNcAmbient, new LinkedHashMap<ButtonFunctionNcAmbient, String>() {{
|
||||||
|
put(new ButtonFunctionNcAmbient(ButtonFunctionNcAmbient.Mode.SWITCH_AMBIENT_SOUND), "d8:d1:02:00");
|
||||||
|
put(new ButtonFunctionNcAmbient(ButtonFunctionNcAmbient.Mode.GOOGLE_ASSISTANT), "d8:d1:02:01");
|
||||||
|
put(new ButtonFunctionNcAmbient(ButtonFunctionNcAmbient.Mode.ALEXA_ASSISTANT), "d8:d1:02:02");
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void reboot() {
|
||||||
|
final Request request = protocol.reboot();
|
||||||
|
assertRequest(request, 0x0c, "98:01:02:01");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAutomaticPowerOff() {
|
public void getAutomaticPowerOff() {
|
||||||
final Request request = protocol.getAutomaticPowerOff();
|
final Request request = protocol.getAutomaticPowerOff();
|
||||||
|
|||||||
+18
@@ -40,8 +40,10 @@ import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphon
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM4Coordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWF1000XM4Coordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControlButtonMode;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioLDAC;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AudioUpsampling;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AutomaticPowerOff;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.ButtonFunctionNcAmbient;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerCustomBands;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.EqualizerPreset;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.PauseWhenTakenOff;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.PauseWhenTakenOff;
|
||||||
@@ -174,6 +176,22 @@ public class SonyProtocolImplV2Test {
|
|||||||
assertRequest(requestDisabled, "3e:0c:01:00:00:00:03:e8:01:00:f9:3c");
|
assertRequest(requestDisabled, "3e:0c:01:00:00:00:03:e8:01:00:f9:3c");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setAudioLDAC() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setButtonFunctionNcAmbient() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void reboot() {
|
||||||
|
final Request request = protocol.reboot();
|
||||||
|
assertRequest(request, 0x0c, "98:00:16:01");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAutomaticPowerOff() {
|
public void getAutomaticPowerOff() {
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
Reference in New Issue
Block a user