mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 09:01:55 +01:00
Sony Headphones: Allow overriding supported features
This commit is contained in:
parent
7f439f2a03
commit
be9bf8f214
@ -486,6 +486,9 @@ public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_SONY_ADAPTIVE_VOLUME_CONTROL = "pref_adaptive_volume_control";
|
||||
public static final String PREF_SONY_WIDE_AREA_TAP = "pref_wide_area_tap";
|
||||
|
||||
public static final String PREF_OVERRIDE_FEATURES_ENABLED = "override_features_enabled";
|
||||
public static final String PREF_OVERRIDE_FEATURES_LIST = "override_features_list";
|
||||
|
||||
public static final String PREF_MOONDROP_EQUALIZER_PRESET = "pref_moondrop_equalizer_preset";
|
||||
public static final String PREF_MOONDROP_TOUCH_PLAY_PAUSE_EARBUD = "pref_moondrop_touch_play_pause_earbud";
|
||||
public static final String PREF_MOONDROP_TOUCH_PLAY_PAUSE_TRIGGER = "pref_moondrop_touch_play_pause_trigger";
|
||||
|
@ -1382,7 +1382,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
||||
coordinator.getSupportedDeviceSpecificConnectionSettings()
|
||||
);
|
||||
|
||||
if (coordinator.getBatteryCount() > 0) {
|
||||
if (coordinator.getBatteryCount(device) > 0) {
|
||||
deviceSpecificSettings.addRootScreen(
|
||||
DeviceSpecificSettingsScreen.BATTERY
|
||||
);
|
||||
@ -1398,6 +1398,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
||||
|
||||
deviceSpecificSettings.addRootScreen(
|
||||
DeviceSpecificSettingsScreen.DEVELOPER,
|
||||
R.xml.devicesettings_header_intent_api,
|
||||
R.xml.devicesettings_settings_third_party_apps
|
||||
);
|
||||
if (coordinator.getConnectionType().usesBluetoothLE()) {
|
||||
|
@ -353,15 +353,15 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
|
||||
// multiple battery support: at this point we support up to three batteries
|
||||
// to support more batteries, the battery UI would need to be extended
|
||||
|
||||
holder.batteryStatusBox0.setVisibility(coordinator.getBatteryCount() > 0 ? View.VISIBLE : View.GONE);
|
||||
holder.batteryStatusBox1.setVisibility(coordinator.getBatteryCount() > 1 ? View.VISIBLE : View.GONE);
|
||||
holder.batteryStatusBox2.setVisibility(coordinator.getBatteryCount() > 2 ? View.VISIBLE : View.GONE);
|
||||
holder.batteryStatusBox0.setVisibility(coordinator.getBatteryCount(device) > 0 ? View.VISIBLE : View.GONE);
|
||||
holder.batteryStatusBox1.setVisibility(coordinator.getBatteryCount(device) > 1 ? View.VISIBLE : View.GONE);
|
||||
holder.batteryStatusBox2.setVisibility(coordinator.getBatteryCount(device) > 2 ? View.VISIBLE : View.GONE);
|
||||
|
||||
LinearLayout[] batteryStatusBoxes = {holder.batteryStatusBox0, holder.batteryStatusBox1, holder.batteryStatusBox2};
|
||||
TextView[] batteryStatusLabels = {holder.batteryStatusLabel0, holder.batteryStatusLabel1, holder.batteryStatusLabel2};
|
||||
ImageView[] batteryIcons = {holder.batteryIcon0, holder.batteryIcon1, holder.batteryIcon2};
|
||||
|
||||
for (int batteryIndex = 0; batteryIndex < coordinator.getBatteryCount(); batteryIndex++) {
|
||||
for (int batteryIndex = 0; batteryIndex < coordinator.getBatteryCount(device); batteryIndex++) {
|
||||
|
||||
int batteryLevel = device.getBatteryLevel(batteryIndex);
|
||||
float batteryVoltage = device.getBatteryVoltage(batteryIndex);
|
||||
@ -823,7 +823,7 @@ public class GBDeviceAdapterv2 extends ListAdapter<GBDevice, GBDeviceAdapterv2.V
|
||||
}
|
||||
|
||||
holder.powerOff.setVisibility(View.GONE);
|
||||
if (device.isInitialized() && coordinator.supportsPowerOff()) {
|
||||
if (device.isInitialized() && coordinator.supportsPowerOff(device)) {
|
||||
holder.powerOff.setVisibility(View.VISIBLE);
|
||||
holder.powerOff.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -798,14 +798,14 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 1;
|
||||
} //multiple battery support, default is 1, maximum is 3, 0 will disable the battery in UI
|
||||
|
||||
@Override
|
||||
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
|
||||
final BatteryConfig[] batteryConfigs = new BatteryConfig[getBatteryCount()];
|
||||
for (int i = 0; i < getBatteryCount(); i++) {
|
||||
final BatteryConfig[] batteryConfigs = new BatteryConfig[getBatteryCount(device)];
|
||||
for (int i = 0; i < getBatteryCount(device); i++) {
|
||||
batteryConfigs[i] = new BatteryConfig(i);
|
||||
}
|
||||
return batteryConfigs;
|
||||
@ -817,7 +817,7 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPowerOff() {
|
||||
public boolean supportsPowerOff(final GBDevice device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -745,13 +745,13 @@ public interface DeviceCoordinator {
|
||||
* 1 is default, 3 is maximum at the moment (as per UI layout)
|
||||
* 0 will disable the battery from the UI
|
||||
*/
|
||||
int getBatteryCount();
|
||||
int getBatteryCount(GBDevice device);
|
||||
|
||||
BatteryConfig[] getBatteryConfig(GBDevice device);
|
||||
|
||||
boolean addBatteryPollingSettings();
|
||||
|
||||
boolean supportsPowerOff();
|
||||
boolean supportsPowerOff(GBDevice device);
|
||||
|
||||
PasswordCapabilityImpl.Mode getPasswordCapability();
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class BandWPSeriesDeviceCoordinator extends AbstractBLEDeviceCoordinator
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class BinarySensorCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ public abstract class AbstractColmiR0xCoordinator extends AbstractBLEDeviceCoord
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPowerOff() {
|
||||
public boolean supportsPowerOff(final GBDevice device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class GalaxyBuds2DeviceCoordinator extends GalaxyBudsGenericCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class GalaxyBuds2ProDeviceCoordinator extends GalaxyBudsGenericCoordinato
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class GalaxyBudsDeviceCoordinator extends GalaxyBudsGenericCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class GalaxyBudsLiveDeviceCoordinator extends GalaxyBudsGenericCoordinato
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class GalaxyBudsProDeviceCoordinator extends GalaxyBudsGenericCoordinator
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public abstract class HuaweiFreebudsCoordinator extends AbstractBLClassicDeviceC
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class MiCompositionScaleCoordinator extends AbstractBLEDeviceCoordinator
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class MiSmartScaleCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class MoondropSpaceTravelCoordinator extends AbstractBLClassicDeviceCoord
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public abstract class AbstractEarCoordinator extends AbstractBLClassicDeviceCoor
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public abstract class OppoHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||
@ -47,7 +48,7 @@ public class Roidmi1Coordinator extends RoidmiCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
// Roidmi 1 does not have voltage support
|
||||
return 0;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class ScannableDeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,34 +17,34 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones;
|
||||
|
||||
public enum SonyHeadphonesCapabilities {
|
||||
BatterySingle,
|
||||
BatteryDual,
|
||||
BatteryDual2,
|
||||
BatteryCase,
|
||||
PowerOffFromPhone,
|
||||
AdaptiveVolumeControl,
|
||||
AmbientSoundControl,
|
||||
AmbientSoundControl2,
|
||||
NoNoiseCancelling,
|
||||
WindNoiseReduction,
|
||||
SpeakToChatEnabled,
|
||||
SpeakToChatConfig,
|
||||
SpeakToChatFocusOnVoice,
|
||||
AmbientSoundControlButtonMode,
|
||||
AncOptimizer,
|
||||
AudioSettingsOnlyOnSbcCodec,
|
||||
AudioUpsampling,
|
||||
ButtonModesLeftRight,
|
||||
AmbientSoundControlButtonMode,
|
||||
VoiceNotifications,
|
||||
AutomaticPowerOffWhenTakenOff,
|
||||
AutomaticPowerOffByTime,
|
||||
TouchSensorSingle,
|
||||
AutomaticPowerOffWhenTakenOff,
|
||||
BatteryCase,
|
||||
BatteryDual,
|
||||
BatteryDual2,
|
||||
BatterySingle,
|
||||
ButtonModesLeftRight,
|
||||
EqualizerSimple,
|
||||
EqualizerWithCustomBands,
|
||||
SoundPosition,
|
||||
SurroundMode,
|
||||
QuickAccess,
|
||||
NoNoiseCancelling,
|
||||
PauseWhenTakenOff,
|
||||
PowerOffFromPhone,
|
||||
QuickAccess,
|
||||
SoundPosition,
|
||||
SpeakToChatConfig,
|
||||
SpeakToChatEnabled,
|
||||
SpeakToChatFocusOnVoice,
|
||||
SurroundMode,
|
||||
TouchSensorSingle,
|
||||
VoiceNotifications,
|
||||
Volume,
|
||||
WideAreaTap,
|
||||
AdaptiveVolumeControl,
|
||||
WindNoiseReduction,
|
||||
}
|
||||
|
@ -26,9 +26,12 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsScreen;
|
||||
@ -39,6 +42,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.SonyHeadphonesSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
|
||||
|
||||
public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceCoordinator {
|
||||
@Override
|
||||
@ -61,31 +65,31 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPowerOff() {
|
||||
return supports(SonyHeadphonesCapabilities.PowerOffFromPhone);
|
||||
public boolean supportsPowerOff(final GBDevice device) {
|
||||
return supports(device, SonyHeadphonesCapabilities.PowerOffFromPhone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
if (supports(SonyHeadphonesCapabilities.BatterySingle)) {
|
||||
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.BatterySingle)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.BatteryDual) || supports(device, SonyHeadphonesCapabilities.BatteryDual2)) {
|
||||
throw new IllegalStateException("A device can't have both single and dual battery");
|
||||
} else if (supports(SonyHeadphonesCapabilities.BatteryCase)) {
|
||||
} else if (supports(device, SonyHeadphonesCapabilities.BatteryCase)) {
|
||||
throw new IllegalStateException("Devices with single battery + case are not supported by the protocol");
|
||||
}
|
||||
}
|
||||
|
||||
int batteryCount = 0;
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.BatterySingle)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.BatterySingle)) {
|
||||
batteryCount += 1;
|
||||
}
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.BatteryCase)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.BatteryCase)) {
|
||||
batteryCount += 1;
|
||||
}
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.BatteryDual) || supports(device, SonyHeadphonesCapabilities.BatteryDual2)) {
|
||||
batteryCount += 2;
|
||||
}
|
||||
|
||||
@ -96,15 +100,15 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
||||
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
|
||||
final List<BatteryConfig> batteries = new ArrayList<>(3);
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.BatterySingle)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.BatterySingle)) {
|
||||
batteries.add(new BatteryConfig(batteries.size(), GBDevice.BATTERY_ICON_DEFAULT, GBDevice.BATTERY_LABEL_DEFAULT, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
||||
}
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.BatteryCase)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.BatteryCase)) {
|
||||
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_tws_case, R.string.battery_case, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
||||
}
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.BatteryDual) || supports(SonyHeadphonesCapabilities.BatteryDual2)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.BatteryDual) || supports(device, SonyHeadphonesCapabilities.BatteryDual2)) {
|
||||
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_l, R.string.left_earbud, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
||||
batteries.add(new BatteryConfig(batteries.size(), R.drawable.ic_galaxy_buds_r, R.string.right_earbud, getBatteryDefaultLowThreshold(), getBatteryDefaultFullThreshold()));
|
||||
}
|
||||
@ -116,31 +120,31 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
||||
public DeviceSpecificSettings getDeviceSpecificSettings(final GBDevice device) {
|
||||
final DeviceSpecificSettings deviceSpecificSettings = new DeviceSpecificSettings();
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.AmbientSoundControl) || supports(SonyHeadphonesCapabilities.AmbientSoundControl2)) {
|
||||
if (supports(SonyHeadphonesCapabilities.WindNoiseReduction)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.AmbientSoundControl) || supports(device, SonyHeadphonesCapabilities.AmbientSoundControl2)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.WindNoiseReduction)) {
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control_wind_noise_reduction);
|
||||
} else if (supports(SonyHeadphonesCapabilities.NoNoiseCancelling)) {
|
||||
} else if (supports(device, SonyHeadphonesCapabilities.NoNoiseCancelling)) {
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control_no_noise_cancelling);
|
||||
} else {
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_ambient_sound_control);
|
||||
}
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.AncOptimizer)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.AncOptimizer)) {
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_anc_optimizer);
|
||||
}
|
||||
}
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.AdaptiveVolumeControl)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.AdaptiveVolumeControl)) {
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_adaptive_volume_control);
|
||||
}
|
||||
|
||||
if (supports(SonyHeadphonesCapabilities.SpeakToChatConfig)) {
|
||||
if (supports(device, SonyHeadphonesCapabilities.SpeakToChatConfig)) {
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_speak_to_chat_with_settings);
|
||||
} else if (supports(SonyHeadphonesCapabilities.SpeakToChatEnabled)) {
|
||||
} else if (supports(device, SonyHeadphonesCapabilities.SpeakToChatEnabled)) {
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_speak_to_chat_simple);
|
||||
}
|
||||
|
||||
addSettingsUnderHeader(deviceSpecificSettings, R.xml.devicesettings_header_other, new LinkedHashMap<SonyHeadphonesCapabilities, Integer>() {{
|
||||
addSettingsUnderHeader(deviceSpecificSettings, device, R.xml.devicesettings_header_other, new LinkedHashMap<SonyHeadphonesCapabilities, Integer>() {{
|
||||
put(SonyHeadphonesCapabilities.AudioSettingsOnlyOnSbcCodec, R.xml.devicesettings_sony_warning_wh1000xm3);
|
||||
put(SonyHeadphonesCapabilities.EqualizerSimple, R.xml.devicesettings_sony_headphones_equalizer);
|
||||
put(SonyHeadphonesCapabilities.EqualizerWithCustomBands, R.xml.devicesettings_sony_headphones_equalizer_with_custom_bands);
|
||||
@ -153,7 +157,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
||||
final List<Integer> callsAndNotif = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.CALLS_AND_NOTIFICATIONS);
|
||||
callsAndNotif.add(R.xml.devicesettings_headphones);
|
||||
|
||||
addSettingsUnderHeader(deviceSpecificSettings, R.xml.devicesettings_header_system, new LinkedHashMap<SonyHeadphonesCapabilities, Integer>() {{
|
||||
addSettingsUnderHeader(deviceSpecificSettings, device, R.xml.devicesettings_header_system, new LinkedHashMap<SonyHeadphonesCapabilities, Integer>() {{
|
||||
put(SonyHeadphonesCapabilities.WideAreaTap, R.xml.devicesettings_sony_headphones_wide_area_tap);
|
||||
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);
|
||||
@ -165,20 +169,30 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
||||
put(SonyHeadphonesCapabilities.VoiceNotifications, R.xml.devicesettings_sony_headphones_notifications_voice_guide);
|
||||
}});
|
||||
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_header_developer);
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_protocol_version);
|
||||
|
||||
deviceSpecificSettings.addRootScreen(R.xml.devicesettings_sony_headphones_device_info);
|
||||
final List<Integer> developer = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DEVELOPER);
|
||||
developer.add(R.xml.devicesettings_override_features);
|
||||
developer.add(R.xml.devicesettings_sony_headphones_protocol_version);
|
||||
developer.add(R.xml.devicesettings_sony_headphones_device_info);
|
||||
|
||||
return deviceSpecificSettings;
|
||||
}
|
||||
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Collections.emptyList();
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
public boolean supports(final SonyHeadphonesCapabilities capability) {
|
||||
return getCapabilities().contains(capability);
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities(final GBDevice device) {
|
||||
DevicePrefs devicePrefs = GBApplication.getDevicePrefs(device);
|
||||
final boolean overrideFeatures = devicePrefs.getBoolean(DeviceSettingsPreferenceConst.PREF_OVERRIDE_FEATURES_ENABLED, false);
|
||||
if (overrideFeatures) {
|
||||
final Set<String> stringList = devicePrefs.getStringSet(DeviceSettingsPreferenceConst.PREF_OVERRIDE_FEATURES_LIST, Collections.emptySet());
|
||||
return stringList.stream().map(SonyHeadphonesCapabilities::valueOf).collect(Collectors.toSet());
|
||||
}
|
||||
return getCapabilities();
|
||||
}
|
||||
|
||||
public boolean supports(final GBDevice device, final SonyHeadphonesCapabilities capability) {
|
||||
return getCapabilities(device).contains(capability);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,11 +203,12 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
||||
* @param capabilities the map of capability to preference screen
|
||||
*/
|
||||
private void addSettingsUnderHeader(final DeviceSpecificSettings deviceSpecificSettings,
|
||||
final GBDevice device,
|
||||
final int header,
|
||||
final Map<SonyHeadphonesCapabilities, Integer> capabilities) {
|
||||
final Set<SonyHeadphonesCapabilities> supportedCapabilities = new HashSet<>(capabilities.keySet());
|
||||
for (SonyHeadphonesCapabilities capability : capabilities.keySet()) {
|
||||
if (!supports(capability)) {
|
||||
if (!supports(device, capability)) {
|
||||
supportedCapabilities.remove(capability);
|
||||
}
|
||||
}
|
||||
@ -206,7 +221,7 @@ public abstract class SonyHeadphonesCoordinator extends AbstractBLClassicDeviceC
|
||||
deviceSpecificSettings.addRootScreen(header);
|
||||
|
||||
for (Map.Entry<SonyHeadphonesCapabilities, Integer> capabilitiesSetting : capabilities.entrySet()) {
|
||||
if (supports(capabilitiesSetting.getKey())) {
|
||||
if (supports(device, capabilitiesSetting.getKey())) {
|
||||
deviceSpecificSettings.addRootScreen(capabilitiesSetting.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_OVERRIDE_FEATURES_LIST;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AMBIENT_SOUND_CONTROL;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AMBIENT_SOUND_LEVEL;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_AUDIO_CODEC;
|
||||
@ -40,8 +41,10 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.MultiSelectListPreference;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
@ -75,7 +78,7 @@ public class SonyHeadphonesSettingsCustomizer implements DeviceSpecificSettingsC
|
||||
// Disable equalizer, sound position and surround mode if not in SBC codec, for WH-1000XM3
|
||||
// TODO: Should the coordinator be responsible for this compatibility check?
|
||||
if (preference.getKey().equals(PREF_SONY_AUDIO_CODEC) && device.getType().equals(DeviceType.SONY_WH_1000XM3)) {
|
||||
final boolean isSbcCodec = ((EditTextPreference) preference).getText().equalsIgnoreCase("sbc");
|
||||
final boolean isSbcCodec = "sbc".equalsIgnoreCase(((EditTextPreference) preference).getText());
|
||||
|
||||
final List<Preference> prefsToDisable = Arrays.asList(
|
||||
handler.findPreference(PREF_SONY_EQUALIZER),
|
||||
@ -146,54 +149,81 @@ public class SonyHeadphonesSettingsCustomizer implements DeviceSpecificSettingsC
|
||||
final Preference ancOptimizer = handler.findPreference("pref_sony_anc_optimizer");
|
||||
|
||||
if (ancOptimizer != null) {
|
||||
ancOptimizer.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(final Preference preference) {
|
||||
if (ancOptimizerProgressDialog != null) {
|
||||
// Already optimizing
|
||||
return true;
|
||||
}
|
||||
|
||||
final Context context = preference.getContext();
|
||||
|
||||
new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.sony_anc_optimize_confirmation_title)
|
||||
.setMessage(R.string.sony_anc_optimize_confirmation_description)
|
||||
.setIcon(R.drawable.ic_hearing)
|
||||
.setPositiveButton(R.string.start, new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int whichButton) {
|
||||
handler.notifyPreferenceChanged(PREF_SONY_NOISE_OPTIMIZER_START);
|
||||
|
||||
ancOptimizerProgressDialog = new ProgressDialog(context);
|
||||
ancOptimizerProgressDialog.setCancelable(false);
|
||||
ancOptimizerProgressDialog.setMessage(context.getString(R.string.sony_anc_optimizer_status_starting));
|
||||
ancOptimizerProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
ancOptimizerProgressDialog.setProgress(0);
|
||||
ancOptimizerProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.Cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final DialogInterface dialog, final int which) {
|
||||
dialog.dismiss();
|
||||
ancOptimizerProgressDialog = null;
|
||||
handler.notifyPreferenceChanged(PREF_SONY_NOISE_OPTIMIZER_CANCEL);
|
||||
}
|
||||
});
|
||||
|
||||
ancOptimizerProgressDialog.show();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
|
||||
ancOptimizer.setOnPreferenceClickListener(preference -> {
|
||||
if (ancOptimizerProgressDialog != null) {
|
||||
// Already optimizing
|
||||
return true;
|
||||
}
|
||||
|
||||
final Context context = preference.getContext();
|
||||
|
||||
new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.sony_anc_optimize_confirmation_title)
|
||||
.setMessage(R.string.sony_anc_optimize_confirmation_description)
|
||||
.setIcon(R.drawable.ic_hearing)
|
||||
.setPositiveButton(R.string.start, new DialogInterface.OnClickListener() {
|
||||
public void onClick(final DialogInterface dialog, final int whichButton) {
|
||||
handler.notifyPreferenceChanged(PREF_SONY_NOISE_OPTIMIZER_START);
|
||||
|
||||
ancOptimizerProgressDialog = new ProgressDialog(context);
|
||||
ancOptimizerProgressDialog.setCancelable(false);
|
||||
ancOptimizerProgressDialog.setMessage(context.getString(R.string.sony_anc_optimizer_status_starting));
|
||||
ancOptimizerProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
ancOptimizerProgressDialog.setProgress(0);
|
||||
ancOptimizerProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.Cancel), (dialog1, which) -> {
|
||||
dialog1.dismiss();
|
||||
ancOptimizerProgressDialog = null;
|
||||
handler.notifyPreferenceChanged(PREF_SONY_NOISE_OPTIMIZER_CANCEL);
|
||||
});
|
||||
|
||||
ancOptimizerProgressDialog.show();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
// Hide unsupported preferences
|
||||
final Preference speakToChatFocusVoice = handler.findPreference(PREF_SONY_SPEAK_TO_CHAT_FOCUS_ON_VOICE);
|
||||
if (speakToChatFocusVoice != null && !coordinator.supports(SonyHeadphonesCapabilities.SpeakToChatFocusOnVoice)) {
|
||||
if (speakToChatFocusVoice != null && !coordinator.supports(device, SonyHeadphonesCapabilities.SpeakToChatFocusOnVoice)) {
|
||||
speakToChatFocusVoice.setVisible(false);
|
||||
}
|
||||
|
||||
// Override features
|
||||
final MultiSelectListPreference overrideFeaturesList = handler.findPreference(PREF_OVERRIDE_FEATURES_LIST);
|
||||
if (overrideFeaturesList != null) {
|
||||
final Set<SonyHeadphonesCapabilities> defaultCapabilities = coordinator.getCapabilities();
|
||||
|
||||
// Populate the preference directly from the enum
|
||||
final CharSequence[] entries = new CharSequence[SonyHeadphonesCapabilities.values().length];
|
||||
final CharSequence[] values = new CharSequence[SonyHeadphonesCapabilities.values().length];
|
||||
int i = 0;
|
||||
for (SonyHeadphonesCapabilities capability : SonyHeadphonesCapabilities.values()) {
|
||||
// Defaults first
|
||||
if (defaultCapabilities.contains(capability)) {
|
||||
entries[i] = "*" + capability.name();
|
||||
values[i] = capability.name();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
for (SonyHeadphonesCapabilities capability : SonyHeadphonesCapabilities.values()) {
|
||||
if (!defaultCapabilities.contains(capability)) {
|
||||
entries[i] = capability.name();
|
||||
values[i] = capability.name();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
overrideFeaturesList.setEntries(entries);
|
||||
overrideFeaturesList.setEntryValues(values);
|
||||
|
||||
overrideFeaturesList.setOnPreferenceClickListener(preference -> {
|
||||
device.sendDeviceUpdateIntent(handler.getContext());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +17,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -32,8 +33,8 @@ public class SonyLinkBudsCoordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatteryDual,
|
||||
SonyHeadphonesCapabilities.BatteryCase,
|
||||
SonyHeadphonesCapabilities.SpeakToChatEnabled,
|
||||
@ -48,7 +49,7 @@ public class SonyLinkBudsCoordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.VoiceNotifications
|
||||
// TODO spacial sound optimization
|
||||
// TODO factory reset
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +17,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -31,8 +32,8 @@ public class SonyLinkBudsSCoordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatteryDual,
|
||||
SonyHeadphonesCapabilities.BatteryCase,
|
||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||
@ -47,7 +48,7 @@ public class SonyLinkBudsSCoordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.SpeakToChatConfig,
|
||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||
SonyHeadphonesCapabilities.EqualizerWithCustomBands
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,19 +16,16 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
|
||||
public class SonyWF1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||
@Override
|
||||
@ -46,8 +43,8 @@ public class SonyWF1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatteryDual,
|
||||
SonyHeadphonesCapabilities.BatteryCase,
|
||||
SonyHeadphonesCapabilities.PowerOffFromPhone,
|
||||
@ -59,7 +56,7 @@ public class SonyWF1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff,
|
||||
SonyHeadphonesCapabilities.VoiceNotifications
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -42,8 +43,8 @@ public class SonyWF1000XM4Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatteryDual,
|
||||
SonyHeadphonesCapabilities.BatteryCase,
|
||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||
@ -53,7 +54,7 @@ public class SonyWF1000XM4Coordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.ButtonModesLeftRight,
|
||||
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,19 +16,16 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
|
||||
public class SonyWF1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
||||
@Override
|
||||
@ -46,8 +43,8 @@ public class SonyWF1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatteryDual,
|
||||
SonyHeadphonesCapabilities.BatteryCase,
|
||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||
@ -57,7 +54,7 @@ public class SonyWF1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.ButtonModesLeftRight,
|
||||
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -31,15 +32,15 @@ public class SonyWFC500Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatteryDual2,
|
||||
SonyHeadphonesCapabilities.EqualizerSimple,
|
||||
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
||||
SonyHeadphonesCapabilities.AudioUpsampling,
|
||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||
SonyHeadphonesCapabilities.PowerOffFromPhone
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +17,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -32,8 +33,8 @@ public class SonyWFC510Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatteryDual2,
|
||||
SonyHeadphonesCapabilities.BatteryCase,
|
||||
SonyHeadphonesCapabilities.AmbientSoundControl2,
|
||||
@ -43,7 +44,7 @@ public class SonyWFC510Coordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.AudioUpsampling,
|
||||
SonyHeadphonesCapabilities.ButtonModesLeftRight,
|
||||
SonyHeadphonesCapabilities.PowerOffFromPhone
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +17,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -32,8 +33,8 @@ public class SonyWFC700NCoordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatteryDual2,
|
||||
SonyHeadphonesCapabilities.BatteryCase,
|
||||
SonyHeadphonesCapabilities.AmbientSoundControl2,
|
||||
@ -46,7 +47,7 @@ public class SonyWFC700NCoordinator extends SonyHeadphonesCoordinator {
|
||||
// AutoOff is supported, but current Payload is incorrect.
|
||||
// Available options in Sony App: 15min, 30min, 1h, 3h, off
|
||||
// TODO: SonyHeadphonesCapabilities.AutomaticPowerOffByTime
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,10 +16,9 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -44,8 +43,8 @@ public class SonyWFSP800NCoordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatteryDual,
|
||||
SonyHeadphonesCapabilities.BatteryCase,
|
||||
SonyHeadphonesCapabilities.PowerOffFromPhone,
|
||||
@ -56,7 +55,7 @@ public class SonyWFSP800NCoordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff,
|
||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||
SonyHeadphonesCapabilities.Volume
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,17 +16,14 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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.DeviceType;
|
||||
|
||||
public class SonyWH1000XM2Coordinator extends SonyHeadphonesCoordinator {
|
||||
@Override
|
||||
@ -40,8 +37,8 @@ public class SonyWH1000XM2Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatterySingle,
|
||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||
SonyHeadphonesCapabilities.WindNoiseReduction,
|
||||
@ -51,6 +48,6 @@ public class SonyWH1000XM2Coordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.SoundPosition,
|
||||
SonyHeadphonesCapabilities.SurroundMode,
|
||||
SonyHeadphonesCapabilities.AudioUpsampling
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -16,17 +16,14 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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.DeviceType;
|
||||
|
||||
public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||
@Override
|
||||
@ -39,8 +36,8 @@ public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatterySingle,
|
||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||
SonyHeadphonesCapabilities.WindNoiseReduction,
|
||||
@ -54,6 +51,6 @@ public class SonyWH1000XM3Coordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.AutomaticPowerOffByTime,
|
||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||
SonyHeadphonesCapabilities.Volume
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -36,8 +37,8 @@ public class SonyWH1000XM4Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
// TODO: Function of [CUSTOM] button
|
||||
// TODO R.xml.devicesettings_connect_two_devices,
|
||||
SonyHeadphonesCapabilities.BatterySingle,
|
||||
@ -53,6 +54,6 @@ public class SonyWH1000XM4Coordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.PauseWhenTakenOff,
|
||||
SonyHeadphonesCapabilities.AutomaticPowerOffWhenTakenOff,
|
||||
SonyHeadphonesCapabilities.VoiceNotifications
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -36,8 +37,8 @@ public class SonyWH1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
// TODO R.xml.devicesettings_connect_two_devices,
|
||||
// TODO automatic ANC depending on state (might need phone?)
|
||||
SonyHeadphonesCapabilities.BatterySingle,
|
||||
@ -54,6 +55,6 @@ public class SonyWH1000XM5Coordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
||||
SonyHeadphonesCapabilities.QuickAccess,
|
||||
SonyHeadphonesCapabilities.PauseWhenTakenOff
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -31,15 +32,15 @@ public class SonyWIC100Coordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatterySingle,
|
||||
SonyHeadphonesCapabilities.EqualizerSimple,
|
||||
SonyHeadphonesCapabilities.EqualizerWithCustomBands,
|
||||
SonyHeadphonesCapabilities.AudioUpsampling,
|
||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||
SonyHeadphonesCapabilities.PowerOffFromPhone
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,17 +16,14 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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.DeviceType;
|
||||
|
||||
public class SonyWISP600NCoordinator extends SonyHeadphonesCoordinator {
|
||||
@Override
|
||||
@ -39,8 +36,8 @@ public class SonyWISP600NCoordinator extends SonyHeadphonesCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return Arrays.asList(
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return new HashSet<>(Arrays.asList(
|
||||
SonyHeadphonesCapabilities.BatterySingle,
|
||||
SonyHeadphonesCapabilities.AmbientSoundControl,
|
||||
SonyHeadphonesCapabilities.WindNoiseReduction,
|
||||
@ -51,6 +48,6 @@ public class SonyWISP600NCoordinator extends SonyHeadphonesCoordinator {
|
||||
SonyHeadphonesCapabilities.AutomaticPowerOffByTime,
|
||||
SonyHeadphonesCapabilities.VoiceNotifications,
|
||||
SonyHeadphonesCapabilities.Volume
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class SoundcoreLiberty3ProCoordinator extends AbstractDeviceCoordinator {
|
||||
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class SoundcoreLiberty4NCCoordinator extends AbstractDeviceCoordinator {
|
||||
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -54,12 +54,12 @@ public class SoundcoreMotion300Coordinator extends AbstractBLClassicDeviceCoordi
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPowerOff() {
|
||||
public boolean supportsPowerOff(final GBDevice device) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class SuperCarsCoordinator extends AbstractDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -552,19 +552,19 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return supports(getTestDevice(), TestFeature.BATTERIES_MULTIPLE) ? 3 : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BatteryConfig[] getBatteryConfig(final GBDevice device) {
|
||||
if (getBatteryCount() == 1) {
|
||||
if (getBatteryCount(device) == 1) {
|
||||
return super.getBatteryConfig(device);
|
||||
}
|
||||
|
||||
final BatteryConfig[] ret = new BatteryConfig[getBatteryCount()];
|
||||
final BatteryConfig[] ret = new BatteryConfig[getBatteryCount(device)];
|
||||
|
||||
for (int i = 0; i < getBatteryCount(); i++) {
|
||||
for (int i = 0; i < getBatteryCount(device); i++) {
|
||||
ret[i] = new BatteryConfig(i, R.drawable.ic_battery_full, R.string.battery);
|
||||
}
|
||||
|
||||
@ -572,7 +572,7 @@ public class TestDeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPowerOff() {
|
||||
public boolean supportsPowerOff(final GBDevice device) {
|
||||
return supports(getTestDevice(), TestFeature.POWER_OFF);
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class UM25Coordinator extends AbstractBLEDeviceCoordinator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public abstract class AbstractRedmiBudsCoordinator extends AbstractDeviceCoordin
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatteryCount() {
|
||||
public int getBatteryCount(final GBDevice device) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.pro
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AdaptiveVolumeControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.prefs.AmbientSoundControl;
|
||||
@ -142,4 +143,8 @@ public abstract class AbstractSonyProtocolImpl {
|
||||
public abstract Request setVolume(final int volume);
|
||||
|
||||
public abstract List<? extends GBDeviceEvent> handlePayload(final MessageType messageType, final byte[] payload);
|
||||
|
||||
protected boolean supports(final SonyHeadphonesCapabilities capability) {
|
||||
return getCoordinator().supports(device, capability);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDevi
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCoordinator;
|
||||
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.AmbientSoundControlButtonMode;
|
||||
@ -627,8 +626,6 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
||||
}
|
||||
|
||||
public List<? extends GBDeviceEvent> handleInitResponse(final byte[] payload) {
|
||||
final SonyHeadphonesCoordinator coordinator = getCoordinator();
|
||||
|
||||
// Populate the init requests
|
||||
final List<Request> capabilityRequests = new ArrayList<>();
|
||||
|
||||
@ -664,7 +661,7 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
||||
}};
|
||||
|
||||
for (Map.Entry<SonyHeadphonesCapabilities, Request> capabilityEntry : capabilityRequestMap.entrySet()) {
|
||||
if (coordinator.supports(capabilityEntry.getKey())) {
|
||||
if (supports(capabilityEntry.getKey())) {
|
||||
capabilityRequests.add(capabilityEntry.getValue());
|
||||
}
|
||||
}
|
||||
@ -945,7 +942,7 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
||||
// Dual Battery (L / R)
|
||||
LOG.debug("Battery Level: {}: L: {}, R: {}", batteryType, payload[2], payload[4]);
|
||||
|
||||
boolean hasCaseBattery = getCoordinator().supports(SonyHeadphonesCapabilities.BatteryCase);
|
||||
boolean hasCaseBattery = supports(SonyHeadphonesCapabilities.BatteryCase);
|
||||
|
||||
if (payload[2] != 0) {
|
||||
final GBDeviceEventBatteryInfo gbDeviceEventBatteryInfoLeft = new GBDeviceEventBatteryInfo();
|
||||
@ -1277,9 +1274,7 @@ public class SonyProtocolImplV1 extends AbstractSonyProtocolImpl {
|
||||
}
|
||||
|
||||
protected boolean supportsWindNoiseCancelling() {
|
||||
final SonyHeadphonesCoordinator coordinator = getCoordinator();
|
||||
|
||||
return coordinator.supports(SonyHeadphonesCapabilities.WindNoiseReduction);
|
||||
return supports(SonyHeadphonesCapabilities.WindNoiseReduction);
|
||||
}
|
||||
|
||||
protected BatteryType decodeBatteryType(final byte b) {
|
||||
|
@ -69,7 +69,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
||||
PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getMessageType(),
|
||||
new byte[]{
|
||||
PayloadTypeV1.AMBIENT_SOUND_CONTROL_GET.getCode(),
|
||||
(byte) (supportsWindNoiseCancelling() || getCoordinator().supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15)
|
||||
(byte) (supportsWindNoiseCancelling() || supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15)
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
||||
final ByteBuffer buf = ByteBuffer.allocate(supportsWindNoiseCancelling() ? 8 : 7);
|
||||
|
||||
buf.put(PayloadTypeV1.AMBIENT_SOUND_CONTROL_SET.getCode());
|
||||
buf.put((byte) (supportsWindNoiseCancelling() || getCoordinator().supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15));
|
||||
buf.put((byte) (supportsWindNoiseCancelling() || supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x17 : 0x15));
|
||||
buf.put((byte) 0x01); // 0x00 while dragging the slider?
|
||||
|
||||
if (AmbientSoundControl.Mode.OFF.equals(ambientSoundControl.getMode())) {
|
||||
@ -352,7 +352,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
||||
PayloadTypeV2.AMBIENT_SOUND_CONTROL_BUTTON_MODE_SET.getCode(),
|
||||
(byte) 0x03,
|
||||
(byte) 0x01,
|
||||
(byte) (getCoordinator().supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x00 : 0x35),
|
||||
(byte) (supports(SonyHeadphonesCapabilities.AmbientSoundControl2) ? 0x00 : 0x35),
|
||||
(byte) 0x01,
|
||||
(byte) 0x00,
|
||||
ambientSoundControlButtonMode.getCode()
|
||||
@ -1081,7 +1081,7 @@ public class SonyProtocolImplV2 extends SonyProtocolImplV1 {
|
||||
case OFF:
|
||||
return (byte) 0xff;
|
||||
case AMBIENT_SOUND_CONTROL:
|
||||
return (byte) (supportsWindNoiseCancelling() || getCoordinator().supports(SonyHeadphonesCapabilities.NoNoiseCancelling) ? 0x35 : 0x00); // Seems to be the only one that differs?
|
||||
return (byte) (supportsWindNoiseCancelling() || supports(SonyHeadphonesCapabilities.NoNoiseCancelling) ? 0x35 : 0x00); // Seems to be the only one that differs?
|
||||
case PLAYBACK_CONTROL:
|
||||
return (byte) 0x20;
|
||||
case VOLUME_CONTROL:
|
||||
|
@ -3277,6 +3277,8 @@
|
||||
<string name="pref_force_connection_type_bt_classic_value" translatable="false">BT_CLASSIC</string>
|
||||
<string name="activity_info">Activity info</string>
|
||||
<string name="warning_missing_notification_permission">Could not post ongoing notification due to missing permission</string>
|
||||
<string name="pref_override_features_title">Override supported features</string>
|
||||
<string name="pref_override_features_summary">Enable/disable specific device features. This can cause issues and/or make your device work incorrectly</string>
|
||||
<string name="pref_test_features_title">Features</string>
|
||||
<string name="pref_test_features_summary">Enabled features for this test device</string>
|
||||
<string name="pref_developer_add_test_activities_title">Add test activities</string>
|
||||
|
@ -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_intent_api"
|
||||
android:title="@string/pref_header_intent_api" />
|
||||
</androidx.preference.PreferenceScreen>
|
20
app/src/main/res/xml/devicesettings_override_features.xml
Normal file
20
app/src/main/res/xml/devicesettings_override_features.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_developer_mode"
|
||||
android:key="override_features_enabled"
|
||||
android:summary="@string/pref_override_features_summary"
|
||||
android:title="@string/pref_override_features_title" />
|
||||
|
||||
<!-- the values should be populated by the DeviceSpecificSettingsCustomizer -->
|
||||
<MultiSelectListPreference
|
||||
android:defaultValue="@array/empty_array"
|
||||
android:dependency="override_features_enabled"
|
||||
android:entries="@array/empty_array"
|
||||
android:entryValues="@array/empty_array"
|
||||
android:icon="@drawable/ic_developer_mode"
|
||||
android:key="override_features_list"
|
||||
android:summary="@string/pref_test_features_summary"
|
||||
android:title="@string/pref_test_features_title" />
|
||||
</androidx.preference.PreferenceScreen>
|
@ -16,10 +16,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.protocol.impl;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
|
||||
@ -30,9 +28,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
public class MockSonyCoordinator extends SonyHeadphonesCoordinator {
|
||||
private final DeviceType deviceType = DeviceType.SONY_WH_1000XM3;
|
||||
|
||||
private final List<SonyHeadphonesCapabilities> capabilities = new ArrayList<>();
|
||||
private final Set<SonyHeadphonesCapabilities> capabilities = new LinkedHashSet<>();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public boolean supports(final GBDeviceCandidate candidate) {
|
||||
return true;
|
||||
@ -47,7 +44,7 @@ public class MockSonyCoordinator extends SonyHeadphonesCoordinator {
|
||||
capabilities.add(capability);
|
||||
}
|
||||
|
||||
public List<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
public Set<SonyHeadphonesCapabilities> getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user