diff --git a/app/src/main/assets/ic_device_galaxy_buds_live.svg b/app/src/main/assets/ic_device_galaxy_buds_live.svg new file mode 100644 index 000000000..acb631326 --- /dev/null +++ b/app/src/main/assets/ic_device_galaxy_buds_live.svg @@ -0,0 +1,166 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/assets/ic_device_galaxy_buds_live_disabled.svg b/app/src/main/assets/ic_device_galaxy_buds_live_disabled.svg new file mode 100644 index 000000000..daf6955dd --- /dev/null +++ b/app/src/main/assets/ic_device_galaxy_buds_live_disabled.svg @@ -0,0 +1,218 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/assets/ic_galaxy_buds_live.svg b/app/src/main/assets/ic_galaxy_buds_live.svg new file mode 100644 index 000000000..48c148d10 --- /dev/null +++ b/app/src/main/assets/ic_galaxy_buds_live.svg @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + diff --git a/app/src/main/assets/ic_galaxy_buds_live_l.svg b/app/src/main/assets/ic_galaxy_buds_live_l.svg new file mode 100644 index 000000000..b3111e17c --- /dev/null +++ b/app/src/main/assets/ic_galaxy_buds_live_l.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/assets/ic_galaxy_buds_live_r.svg b/app/src/main/assets/ic_galaxy_buds_live_r.svg new file mode 100644 index 000000000..4f5a90a5e --- /dev/null +++ b/app/src/main/assets/ic_galaxy_buds_live_r.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java index 2b6cbbf0d..57eff46c1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSettingsPreferenceConst.java @@ -108,6 +108,8 @@ public class DeviceSettingsPreferenceConst { public static final String PREF_GALAXY_BUDS_EQUALIZER_MODE = "pref_galaxy_buds_equalizer_mode"; public static final String PREF_GALAXY_BUDS_TOUCH_LEFT = "pref_galaxy_buds_touch_left"; public static final String PREF_GALAXY_BUDS_TOUCH_RIGHT = "pref_galaxy_buds_touch_right"; + public static final String PREF_GALAXY_BUDS_LIVE_ANC = "pref_galaxy_buds_live_anc"; + public static final String PREF_GALAXY_BUDS_PRESSURE_RELIEF = "pref_galaxy_buds_live_pressure_relief"; public static final String PREF_SONY_WH1000XM3_AMBIENT_SOUND_CONTROL = "pref_sony_wh1000xm3_ambient_sound_control"; public static final String PREF_SONY_WH1000XM3_FOCUS_VOICE = "pref_sony_wh1000xm3_focus_voice"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java index deb94e939..21769b35f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/devicesettings/DeviceSpecificSettingsFragment.java @@ -82,6 +82,8 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_LOCK_TOUCH; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_TOUCH_LEFT; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_TOUCH_RIGHT; +import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_LIVE_ANC; +import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_PRESSURE_RELIEF; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HYBRID_HR_DANGEROUS_EXTERNAL_INTENTS; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HYBRID_HR_DRAW_WIDGET_CIRCLES; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_HYBRID_HR_FORCE_WHITE_COLOR; @@ -512,6 +514,9 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat { addPreferenceHandlerFor(PREF_GALAXY_BUDS_EQUALIZER_MODE); addPreferenceHandlerFor(PREF_GALAXY_BUDS_TOUCH_LEFT); addPreferenceHandlerFor(PREF_GALAXY_BUDS_TOUCH_RIGHT); + addPreferenceHandlerFor(PREF_GALAXY_BUDS_LIVE_ANC); + addPreferenceHandlerFor(PREF_GALAXY_BUDS_PRESSURE_RELIEF); + addPreferenceHandlerFor(PREF_SONY_WH1000XM3_AMBIENT_SOUND_CONTROL); addPreferenceHandlerFor(PREF_SONY_WH1000XM3_FOCUS_VOICE); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBudsLiveDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBudsLiveDeviceCoordinator.java new file mode 100644 index 000000000..1b1f85b67 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/galaxy_buds/GalaxyBudsLiveDeviceCoordinator.java @@ -0,0 +1,157 @@ +package nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds; + +import android.app.Activity; +import android.content.Context; +import android.net.Uri; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import nodomain.freeyourgadget.gadgetbridge.GBException; +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; +import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; +import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; +import nodomain.freeyourgadget.gadgetbridge.entities.Device; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; +import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; +import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; + +public class GalaxyBudsLiveDeviceCoordinator extends AbstractDeviceCoordinator { + + @NonNull + @Override + public DeviceType getSupportedType(GBDeviceCandidate candidate) { + + String name = candidate.getName(); + + if (name != null && ( + name.startsWith("Galaxy Buds Live (") + )) { + return DeviceType.GALAXY_BUDS_LIVE; + } + return DeviceType.UNKNOWN; + } + + @Override + public DeviceType getDeviceType() { + return DeviceType.GALAXY_BUDS_LIVE; + } + + @Override + public int getBatteryCount() { + return 3; + } + + @Override + public BatteryConfig[] getBatteryConfig() { + BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_tws_case, R.string.battery_case); + BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_galaxy_buds_live_l, R.string.left_earbud); + BatteryConfig battery3 = new BatteryConfig(2, R.drawable.ic_galaxy_buds_live_r, R.string.right_earbud); + return new BatteryConfig[]{battery1, battery2, battery3}; + } + + @Override + public int getBondingStyle() { + return BONDING_STYLE_BOND; + } + + @Nullable + @Override + public Class getPairingActivity() { + return null; + } + + @Override + public boolean supportsActivityDataFetching() { + return false; + } + + @Override + public boolean supportsActivityTracking() { + return false; + } + + @Override + public SampleProvider getSampleProvider(GBDevice + device, DaoSession session) { + return null; + } + + @Override + public InstallHandler findInstallHandler(Uri uri, Context context) { + return null; + } + + @Override + public boolean supportsScreenshots() { + return false; + } + + @Override + public int getAlarmSlotCount() { + return 0; + } + + @Override + public boolean supportsSmartWakeup(GBDevice device) { + return false; + } + + @Override + public boolean supportsHeartRateMeasurement(GBDevice device) { + return false; + } + + @Override + public String getManufacturer() { + return "Samsung"; + } + + @Override + public boolean supportsAppsManagement() { + return false; + } + + @Override + public Class getAppsManagementActivity() { + return null; + } + + @Override + public boolean supportsCalendarEvents() { + return false; + } + + @Override + public boolean supportsRealtimeData() { + return false; + } + + @Override + public boolean supportsWeather() { + return false; + } + + @Override + public boolean supportsFindDevice() { + return true; + } + + @Override + protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device + device, @NonNull DaoSession session) throws GBException { + + } + + + @Override + public int[] getSupportedDeviceSpecificSettings(GBDevice device) { + return new int[]{ + R.xml.devicesettings_galaxy_buds_live, + }; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java index ced968da1..82d4889fc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -101,6 +101,7 @@ public enum DeviceType { UM25(350, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_um25), DOMYOS_T540(400, R.drawable.ic_device_lovetoy, R.drawable.ic_device_lovetoy_disabled, R.string.devicetype_domyos_t540), NOTHING_EAR1(410, R.drawable.ic_device_nothingear, R.drawable.ic_device_nothingear_disabled, R.string.devicetype_nothingear1), + GALAXY_BUDS_LIVE(419, R.drawable.ic_device_galaxy_buds_live, R.drawable.ic_device_galaxy_buds_live_disabled, R.string.devicetype_galaxybuds_live), GALAXY_BUDS(420, R.drawable.ic_device_galaxy_buds, R.drawable.ic_device_galaxy_buds_disabled, R.string.devicetype_galaxybuds), SONY_WH_1000XM3(430, R.drawable.ic_device_headphones, R.drawable.ic_device_headphones_disabled, R.string.devicetype_sony_wh_1000xm3), TEST(1000, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_test); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java index 275b489fd..5aa9fed15 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java @@ -367,6 +367,9 @@ public class DeviceSupportFactory { case GALAXY_BUDS: deviceSupport = new ServiceDeviceSupport(new GalaxyBudsDeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING)); break; + case GALAXY_BUDS_LIVE: + deviceSupport = new ServiceDeviceSupport(new GalaxyBudsDeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING)); + break; case SONY_WH_1000XM3: deviceSupport = new ServiceDeviceSupport(new SonyWh1000Xm3Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING)); break; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsIOThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsIOThread.java index 53610d1e8..7d8aca91d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsIOThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsIOThread.java @@ -17,22 +17,32 @@ import java.util.Arrays; import java.util.UUID; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.service.btclassic.BtClassicIoThread; public class GalaxyBudsIOThread extends BtClassicIoThread { private static final Logger LOG = LoggerFactory.getLogger(GalaxyBudsIOThread.class); private final GalaxyBudsProtocol galaxyBudsProtocol; + private final GBDevice gbDevice; @NonNull protected UUID getUuidToConnect(@NonNull ParcelUuid[] uuids) { - return galaxyBudsProtocol.UUID_DEVICE_CTRL; + if (gbDevice.getType().equals(DeviceType.GALAXY_BUDS)) { + return galaxyBudsProtocol.UUID_GALAXY_BUDS_DEVICE_CTRL; + } + if (gbDevice.getType().equals(DeviceType.GALAXY_BUDS_LIVE)) { + return galaxyBudsProtocol.UUID_GALAXY_BUDS_LIVE_DEVICE_CTRL; + } + return galaxyBudsProtocol.UUID_GALAXY_BUDS_DEVICE_CTRL; + } public GalaxyBudsIOThread(GBDevice device, Context context, GalaxyBudsProtocol deviceProtocol, GalaxyBudsDeviceSupport galaxyBudsDeviceSupport, BluetoothAdapter bluetoothAdapter) { super(device, context, deviceProtocol, galaxyBudsDeviceSupport, bluetoothAdapter); galaxyBudsProtocol = deviceProtocol; + gbDevice = device; } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsProtocol.java index 8288fa0b8..1e2000217 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/galaxy_buds/GalaxyBudsProtocol.java @@ -23,14 +23,23 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInf import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.BatteryState; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol; public class GalaxyBudsProtocol extends GBDeviceProtocol { private static final Logger LOG = LoggerFactory.getLogger(GalaxyBudsProtocol.class); - final UUID UUID_DEVICE_CTRL = UUID.fromString("00001102-0000-1000-8000-00805f9b34fd"); - private static final byte SOM = (byte) 0xFE; - private static final byte EOM = (byte) 0xEE; + final UUID UUID_GALAXY_BUDS_DEVICE_CTRL = UUID.fromString("00001102-0000-1000-8000-00805f9b34fd"); + final UUID UUID_GALAXY_BUDS_LIVE_DEVICE_CTRL = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); + + private static final byte SOMBuds = (byte) 0xFE; + private static final byte EOMBuds = (byte) 0xEE; + private static final byte SOMPlus = (byte) 0xFD; + private static final byte EOMPlus = (byte) 0xDD; + + private static byte SOM = SOMBuds; + private static byte EOM = EOMBuds; + private boolean isFirstExchange = true; //incoming @@ -58,6 +67,11 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { private static final byte get_debug_get_all_data = (byte) 0x26; private static final byte get_debug_get_version = (byte) 0x24; + //Live + private static final byte set_automatic_noise_cancelling = (byte) 0x98; //0x0/0x1 + private static final byte set_live_game_mode = (byte) 0x85; // 0x0/0x1 no idea if this is doing anything + private static final byte set_pressure_relief = (byte) 0x9f; //0x0/0x1 + @Override public GBDeviceEvent[] decodeResponse(byte[] responseData) { List devEvts = new ArrayList<>(); @@ -72,13 +86,23 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { ByteBuffer incoming = ByteBuffer.wrap(responseData); incoming.order(ByteOrder.LITTLE_ENDIAN); + int length = 9; + byte type = 0; + byte sof = incoming.get(); if (sof != SOM) { LOG.error("Error in message, wrong start of frame: " + hexdump(responseData)); return null; } - byte type = incoming.get(); - int length = (int) (incoming.get() & 0xff); + + if (SOM == SOMPlus) { + length = (int) (incoming.get() & 0xff); + type = incoming.get(); + } else { + type = incoming.get(); + length = (int) (incoming.get() & 0xff); + } + byte message_id = incoming.get(); byte[] payload; try { @@ -90,10 +114,10 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { switch (message_id) { case battery_status: - devEvts.addAll(handleBatteryInfo(Arrays.copyOfRange(payload, 1, 3))); + devEvts.addAll(handleBatteryInfo(Arrays.copyOfRange(payload, 1, 11))); //11 break; case battery_status2: - devEvts.addAll(handleBatteryInfo(Arrays.copyOfRange(payload, 2, 4))); + devEvts.addAll(handleBatteryInfo(Arrays.copyOfRange(payload, 2, 12))); //12 break; default: LOG.debug("Unhandled: " + hexdump(responseData)); @@ -107,8 +131,14 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { ByteBuffer msgBuf = ByteBuffer.allocate(7); msgBuf.order(ByteOrder.LITTLE_ENDIAN); msgBuf.put(SOM); - msgBuf.put((byte) 0x0); //0x0 for sending - msgBuf.put((byte) 0x3); //size + byte size = 0x3; + if (SOM == SOMPlus) { + msgBuf.put((byte) size); + msgBuf.put((byte) 0x0); //0x0 for sending + } else { + msgBuf.put((byte) 0x0); //0x0 for sending + msgBuf.put((byte) size); //size + } msgBuf.put((byte) command); //command id msgBuf.putShort((short) crc16_ccitt(new byte[]{command})); msgBuf.put(EOM); @@ -120,8 +150,14 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { ByteBuffer msgBuf = ByteBuffer.allocate(8); msgBuf.order(ByteOrder.LITTLE_ENDIAN); msgBuf.put(SOM); - msgBuf.put((byte) 0x0); //0x0 for sending - msgBuf.put((byte) 0x4); //size + byte size = 0x4; + if (SOM == SOMPlus) { + msgBuf.put((byte) size); + msgBuf.put((byte) 0x0); //0x0 for sending + } else { + msgBuf.put((byte) 0x0); //0x0 for sending + msgBuf.put((byte) size); //size + } msgBuf.put((byte) command); //command id msgBuf.put((byte) parameter); msgBuf.putShort((short) crc16_ccitt(new byte[]{command, parameter})); @@ -134,8 +170,14 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { ByteBuffer msgBuf = ByteBuffer.allocate(9); msgBuf.order(ByteOrder.LITTLE_ENDIAN); msgBuf.put(SOM); - msgBuf.put((byte) 0x0); //0x0 for sending - msgBuf.put((byte) 0x5); //size + byte size = 0x5; + if (SOM == SOMPlus) { + msgBuf.put((byte) size); + msgBuf.put((byte) 0x0); //0x0 for sending + } else { + msgBuf.put((byte) 0x0); //0x0 for sending + msgBuf.put((byte) size); //size + } msgBuf.put((byte) command); msgBuf.put((byte) parameter); msgBuf.put((byte) value); @@ -185,20 +227,31 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { byte set_lock = (byte) (prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_LOCK_TOUCH, false) ? 0x01 : 0x00); return encodeMessage(set_lock_touch, set_lock); case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_GAME_MODE: - byte game_mode = (byte) (prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_GAME_MODE, false) ? 0x2 : 0x00); - return encodeMessage(set_game_mode, game_mode); + if (SOM == SOMPlus) { + byte game_mode = (byte) (prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_GAME_MODE, false) ? 0x1 : 0x00); + return encodeMessage(set_live_game_mode, game_mode); + } else { + byte game_mode = (byte) (prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_GAME_MODE, false) ? 0x2 : 0x00); + return encodeMessage(set_game_mode, game_mode); + } + case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_EQUALIZER: case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_EQUALIZER_DOLBY: case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_EQUALIZER_MODE: byte equalizer = (byte) (prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_EQUALIZER, false) ? 0x1 : 0x00); boolean equalizer_dolby = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_EQUALIZER_DOLBY, false); int dolby = 0; - if (equalizer_dolby) { + if (!equalizer_dolby) { dolby = 5; } String equalizer_mode = prefs.getString(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_EQUALIZER_MODE, "0"); - byte mode = (byte) (Integer.parseInt(equalizer_mode) + dolby); - return encodeMessage(set_equalizer, equalizer, mode); + + if (SOM == SOMPlus) { + return encodeMessage(set_equalizer, (byte) (Integer.parseInt(equalizer_mode))); + } else { + byte mode = (byte) (Integer.parseInt(equalizer_mode) + dolby); + return encodeMessage(set_equalizer, equalizer, mode); + } case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_TOUCH_LEFT: case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_TOUCH_RIGHT: @@ -208,6 +261,14 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { byte touchmode_right = (byte) Integer.parseInt(touch_right); return encodeMessage(set_touchpad_options, touchmode_left, touchmode_right); + case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_LIVE_ANC: + byte enable_anc = (byte) (prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_LIVE_ANC, false) ? 0x1 : 0x00); + return encodeMessage(set_automatic_noise_cancelling, enable_anc); + + case DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_PRESSURE_RELIEF: + byte enable_pressure_relief = (byte) (prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_GALAXY_BUDS_PRESSURE_RELIEF, false) ? 0x1 : 0x00); + return encodeMessage(set_pressure_relief, enable_pressure_relief); + default: LOG.debug("CONFIG: " + config); } @@ -221,9 +282,11 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { LOG.debug("pl: " + payload.length); LOG.debug("p0: " + payload[0]); LOG.debug("p1: " + payload[1]); + LOG.debug("p2: " + payload[5]); int batteryLevel1 = payload[0]; int batteryLevel2 = payload[1]; + int batteryLevel3 = payload[5]; GBDeviceEventBatteryInfo evBattery1 = new GBDeviceEventBatteryInfo(); evBattery1.batteryIndex = 0; @@ -232,6 +295,7 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { evBattery1.state = (batteryLevel1 > 0) ? BatteryState.BATTERY_NORMAL : BatteryState.UNKNOWN; deviceEvents.add(evBattery1); + GBDeviceEventBatteryInfo evBattery2 = new GBDeviceEventBatteryInfo(); evBattery2.batteryIndex = 1; evBattery2.level = GBDevice.BATTERY_UNKNOWN; @@ -239,11 +303,30 @@ public class GalaxyBudsProtocol extends GBDeviceProtocol { evBattery2.state = (batteryLevel2 > 0) ? BatteryState.BATTERY_NORMAL : BatteryState.UNKNOWN; deviceEvents.add(evBattery2); + + if (SOM == SOMPlus) { + GBDeviceEventBatteryInfo evBattery3 = new GBDeviceEventBatteryInfo(); + // reorder for the non OG version + evBattery1.batteryIndex = 1; //left + evBattery2.batteryIndex = 2; //right + evBattery3.batteryIndex = 0; //case + + evBattery3.level = GBDevice.BATTERY_UNKNOWN; + evBattery3.level = (batteryLevel3 > 0) ? batteryLevel3 : GBDevice.BATTERY_UNKNOWN; + evBattery3.state = (batteryLevel3 > 0) ? BatteryState.BATTERY_NORMAL : BatteryState.UNKNOWN; + deviceEvents.add(evBattery3); + } + return deviceEvents; } protected GalaxyBudsProtocol(GBDevice device) { super(device); - + LOG.debug("PETR, " + device.getType()); + if (device.getType().equals(DeviceType.GALAXY_BUDS_LIVE)) { + LOG.debug("set som"); + SOM = SOMPlus; + EOM = EOMPlus; + } } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java index c7da8fc78..6e2ca3501 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java @@ -50,6 +50,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.casio.gb6900.CasioGB6900Devi import nodomain.freeyourgadget.gadgetbridge.devices.casio.gbx100.CasioGBX100DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.domyos.DomyosT540Cooridnator; import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBudsDeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds.GalaxyBudsLiveDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.EXRIZUK8Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.HPlusCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.MakibesF68Coordinator; @@ -312,6 +313,7 @@ public class DeviceHelper { result.add(new FitProDeviceCoordinator()); result.add(new Ear1Coordinator()); result.add(new GalaxyBudsDeviceCoordinator()); + result.add(new GalaxyBudsLiveDeviceCoordinator()); result.add(new SonyWh1000Xm3Coordinator()); return result; diff --git a/app/src/main/res/drawable/ic_device_galaxy_buds_live.xml b/app/src/main/res/drawable/ic_device_galaxy_buds_live.xml new file mode 100644 index 000000000..7f30115ca --- /dev/null +++ b/app/src/main/res/drawable/ic_device_galaxy_buds_live.xml @@ -0,0 +1,36 @@ + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_device_galaxy_buds_live_disabled.xml b/app/src/main/res/drawable/ic_device_galaxy_buds_live_disabled.xml new file mode 100644 index 000000000..26e25a945 --- /dev/null +++ b/app/src/main/res/drawable/ic_device_galaxy_buds_live_disabled.xml @@ -0,0 +1,41 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_engineering.xml b/app/src/main/res/drawable/ic_engineering.xml new file mode 100644 index 000000000..3aede2a7c --- /dev/null +++ b/app/src/main/res/drawable/ic_engineering.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_galaxy_buds_live_l.xml b/app/src/main/res/drawable/ic_galaxy_buds_live_l.xml new file mode 100644 index 000000000..71d5b87ee --- /dev/null +++ b/app/src/main/res/drawable/ic_galaxy_buds_live_l.xml @@ -0,0 +1,16 @@ + + + + diff --git a/app/src/main/res/drawable/ic_galaxy_buds_live_r.xml b/app/src/main/res/drawable/ic_galaxy_buds_live_r.xml new file mode 100644 index 000000000..13bedc195 --- /dev/null +++ b/app/src/main/res/drawable/ic_galaxy_buds_live_r.xml @@ -0,0 +1,16 @@ + + + + diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index b869cdd50..e5f58c64a 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1602,12 +1602,10 @@ REWIND BROADCAST Voice Assistant + Active Noise Cancelling Quick Ambient Sound Volume Ambient Sound - Spotify - Other Left - Other Right @string/pref_button_action_disabled @@ -1811,6 +1809,24 @@ 4 + + @string/pref_title_equalizer_normal + @string/pref_title_equalizer_bass_boost + @string/pref_title_equalizer_soft + @string/pref_title_equalizer_dynamic + @string/pref_title_equalizer_clear + @string/pref_title_equalizer_trebble + + + + 0 + 1 + 2 + 3 + 4 + 5 + + @string/pref_title_touch_voice_assistant @string/pref_title_touch_quick_ambient @@ -1825,6 +1841,18 @@ 3 + + @string/pref_title_touch_voice_assistant + @string/pref_title_touch_anc + @string/pref_title_touch_volume + + + + 1 + 2 + 3 + + @string/sony_ambient_sound_off @string/sony_ambient_sound_noise_cancelling diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8b6222fa3..6c88ef42a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1287,10 +1287,12 @@ Frequency of measurements Nothing Ear (1) Galaxy Buds + Galaxy Buds Live Play/pause the music depending if you wear the earbuds In-Ear detection Audio mode Equalizer Preset + Normal Bass boost Soft Dynamic @@ -1310,6 +1312,10 @@ Make voice stand out Ambient Sound Ambient Mode + Active Noise Cancelling + Block noises of the surroundings + Pressure relief with ambient sound + Prevent feeling of pressure in ears when not using Active Noise Cancelling Left Right Touch Options diff --git a/app/src/main/res/xml/devicesettings_galaxy_buds_live.xml b/app/src/main/res/xml/devicesettings_galaxy_buds_live.xml new file mode 100644 index 000000000..dace3a9cc --- /dev/null +++ b/app/src/main/res/xml/devicesettings_galaxy_buds_live.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + +