CMF Watch Pro: Allow enable of bluetooth calls

This commit is contained in:
José Rebelo
2025-03-18 21:58:33 +00:00
parent 4a3eaf76be
commit 528fb09f52
5 changed files with 36 additions and 3 deletions
@@ -323,6 +323,7 @@ public class CmfWatchProCoordinator extends AbstractBLEDeviceCoordinator {
settings.add(R.xml.devicesettings_header_notifications);
settings.add(R.xml.devicesettings_send_app_notifications);
settings.add(R.xml.devicesettings_bluetooth_calls);
settings.add(R.xml.devicesettings_transliteration);
settings.add(R.xml.devicesettings_header_other);
@@ -37,7 +37,8 @@ public enum CmfCommand {
AUTHENTICATED_CONFIRM_REPLY(0xffff, 0x0004),
AUTHENTICATED_CONFIRM_REQUEST(0xffff, 0x804d),
BATTERY(0x005c, 0x0001),
CALL_REMINDER(0xffff, 0x9066),
CALL_REMINDER_REQUEST(0xffff, 0x9066),
CALL_REMINDER_RESPONSE(0xffff, 0xa066),
CONTACTS_GET(0x00d5, 0x0002),
CONTACTS_SET(0x00d5, 0x0001),
DATA_CHUNK_REQUEST_AGPS(0xffff, 0xa05f),
@@ -39,7 +39,6 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class CmfPreferences {
@@ -108,7 +107,9 @@ public class CmfPreferences {
case HuamiConst.PREF_WORKOUT_ACTIVITY_TYPES_SORTABLE:
setActivityTypes();
return;
// TODO call reminders
case DeviceSettingsPreferenceConst.PREF_BLUETOOTH_CALLS_ENABLED:
setCallReminders();
return;
}
LOG.warn("Unknown config changed: {}", config);
@@ -337,6 +338,17 @@ public class CmfPreferences {
mSupport.sendCommand("set hydration reminders", CmfCommand.WATER_REMINDER_SET, buf.array());
}
private void setCallReminders() {
final Prefs prefs = mSupport.getDevicePrefs();
final boolean enabled = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_BLUETOOTH_CALLS_ENABLED, false);
final TransactionBuilder builder = mSupport.createTransactionBuilder("set call reminders = " + enabled);
mSupport.sendCommand(builder, CmfCommand.CALL_REMINDER_REQUEST, new byte[]{0x01, (byte) (enabled ? 0x01 : 0x00)});
builder.queue(mSupport.getQueue());
}
private void setActivityTypes() {
final Prefs prefs = mSupport.getDevicePrefs();
List<String> activityTypes = new ArrayList<>(prefs.getList(HuamiConst.PREF_WORKOUT_ACTIVITY_TYPES_SORTABLE, Collections.emptyList()));
@@ -345,6 +345,7 @@ public class CmfWatchProSupport extends AbstractBTLEDeviceSupport implements Cmf
//sendCommand(phase2builder, CmfCommand.WATER_REMINDER_GET);
//sendCommand(phase2builder, CmfCommand.CONTACTS_GET);
//sendCommand(phase2builder, CmfCommand.ALARMS_GET);
//sendCommand(phase2builder, CmfCommand.CALL_REMINDER_REQUEST, 0x00);
// TODO premature to mark as initialized?
phase2builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
phase2builder.queue(getQueue());
@@ -390,6 +391,12 @@ public class CmfWatchProSupport extends AbstractBTLEDeviceSupport implements Cmf
}
evaluateGBDeviceEvent(findPhoneEvent);
return;
case CALL_REMINDER_RESPONSE:
LOG.debug("Got call reminder response: {}", GB.hexdump(payload));
// 00 -> ack set
// 01:00 -> disabled
// 01:01 -> enabled
break;
case MUSIC_INFO_ACK:
LOG.debug("Got music info ack");
break;
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreferenceCompat
android:defaultValue="false"
android:icon="@drawable/ic_voice"
android:key="bluetooth_calls_enabled"
android:layout="@layout/preference_checkbox"
android:summary="@string/pref_summary_receive_calls_watch"
android:title="@string/bluetooth_calls" />
</androidx.preference.PreferenceScreen>