mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-11 01:21:56 +01:00
Huami: Add new option to disting to properly distinguish connected adverising and 3rd party hr exposure
This commit is contained in:
parent
162bb47c6d
commit
4fb79ac2b2
@ -62,4 +62,6 @@ public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_SONYSWR12_LOW_VIBRATION = "vibration_preference";
|
||||
public static final String PREF_SONYSWR12_STAMINA = "stamina_preference";
|
||||
public static final String PREF_SONYSWR12_SMART_INTERVAL = "smart_alarm_interval_preference";
|
||||
|
||||
public static final String PREF_BT_CONNECTED_ADVERTISEMENT = "bt_connected_advertisement";
|
||||
}
|
@ -47,6 +47,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.XTimePreferenceFragment;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALTITUDE_CALIBRATE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_AMPM_ENABLED;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ANTILOST_ENABLED;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BT_CONNECTED_ADVERTISEMENT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BUTTON_1_FUNCTION_DOUBLE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BUTTON_1_FUNCTION_LONG;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BUTTON_1_FUNCTION_SHORT;
|
||||
@ -359,6 +360,7 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
|
||||
addPreferenceHandlerFor(PREF_SHORTCUTS_SORTABLE);
|
||||
addPreferenceHandlerFor(PREF_LANGUAGE);
|
||||
addPreferenceHandlerFor(PREF_EXPOSE_HR_THIRDPARTY);
|
||||
addPreferenceHandlerFor(PREF_BT_CONNECTED_ADVERTISEMENT);
|
||||
addPreferenceHandlerFor(PREF_WEARLOCATION);
|
||||
addPreferenceHandlerFor(PREF_SCREEN_ORIENTATION);
|
||||
addPreferenceHandlerFor(PREF_TIMEFORMAT);
|
||||
|
@ -41,6 +41,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.DateTimeDisplay;
|
||||
@ -255,6 +256,11 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
|
||||
return prefs.getBoolean(HuamiConst.PREF_EXPOSE_HR_THIRDPARTY, false);
|
||||
}
|
||||
|
||||
public static boolean getBtConnectedAdvertising(String deviceAddress) {
|
||||
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(deviceAddress));
|
||||
return prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_BT_CONNECTED_ADVERTISEMENT, false);
|
||||
}
|
||||
|
||||
protected static Date getTimePreference(String key, String defaultValue, String deviceAddress) {
|
||||
Prefs prefs;
|
||||
|
||||
|
@ -140,8 +140,10 @@ public class HuamiService {
|
||||
public static final byte[] DATEFORMAT_TIME_12_HOURS = new byte[] {ENDPOINT_DISPLAY, 0x02, 0x0, 0x0 };
|
||||
public static final byte[] DATEFORMAT_TIME_24_HOURS = new byte[] {ENDPOINT_DISPLAY, 0x02, 0x0, 0x1 };
|
||||
public static final byte[] DATEFORMAT_DATE_MM_DD_YYYY = new byte[]{ENDPOINT_DISPLAY, 30, 0x00, 'M', 'M', '/', 'd', 'd', '/', 'y', 'y', 'y', 'y'};
|
||||
public static final byte[] COMMAND_ENBALE_HR_CONNECTION = new byte[]{ENDPOINT_DISPLAY, 0x01, 0x00, 0x01};
|
||||
public static final byte[] COMMAND_DISABLE_HR_CONNECTION = new byte[]{ENDPOINT_DISPLAY, 0x01, 0x00, 0x00};
|
||||
public static final byte[] COMMAND_ENBALE_HR_CONNECTION = new byte[]{ENDPOINT_DISPLAY, 0x1f, 0x00, 0x01};
|
||||
public static final byte[] COMMAND_DISABLE_HR_CONNECTION = new byte[]{ENDPOINT_DISPLAY, 0x1f, 0x00, 0x00};
|
||||
public static final byte[] COMMAND_ENABLE_BT_CONNECTED_ADVERTISEMENT = new byte[]{ENDPOINT_DISPLAY, 0x01, 0x00, 0x01};
|
||||
public static final byte[] COMMAND_DISABLE_BT_CONNECTED_ADVERTISEMENT = new byte[]{ENDPOINT_DISPLAY, 0x01, 0x00, 0x00};
|
||||
public static final byte[] COMMAND_ENABLE_DISPLAY_ON_LIFT_WRIST = new byte[]{ENDPOINT_DISPLAY, 0x05, 0x00, 0x01};
|
||||
public static final byte[] COMMAND_DISABLE_DISPLAY_ON_LIFT_WRIST = new byte[]{ENDPOINT_DISPLAY, 0x05, 0x00, 0x00};
|
||||
public static final byte[] COMMAND_SCHEDULE_DISPLAY_ON_LIFT_WRIST = new byte[]{ENDPOINT_DISPLAY, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00};
|
||||
|
@ -97,6 +97,7 @@ public class AmazfitBand5Coordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_swipeunlock,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey,
|
||||
R.xml.devicesettings_high_mtu
|
||||
|
@ -87,7 +87,7 @@ public class AmazfitBipCoordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_buttonactions_with_longpress,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey
|
||||
|
@ -76,7 +76,7 @@ public class AmazfitBipLiteCoordinator extends AmazfitBipCoordinator {
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_buttonactions_with_longpress,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey,
|
||||
|
@ -92,6 +92,7 @@ public class AmazfitBipSCoordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_high_mtu,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey
|
||||
|
@ -92,6 +92,7 @@ public class AmazfitBipUCoordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_high_mtu,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey
|
||||
|
@ -95,7 +95,7 @@ public class AmazfitCorCoordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey
|
||||
};
|
||||
|
@ -97,7 +97,7 @@ public class AmazfitCor2Coordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_liftwrist_display,
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey
|
||||
};
|
||||
|
@ -95,6 +95,7 @@ public class AmazfitGTRCoordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey,
|
||||
R.xml.devicesettings_high_mtu
|
||||
|
@ -96,6 +96,7 @@ public class AmazfitGTRLiteCoordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_pairingkey
|
||||
};
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ public class AmazfitGTR2Coordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey,
|
||||
R.xml.devicesettings_high_mtu
|
||||
|
@ -95,6 +95,7 @@ public class AmazfitGTSCoordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey,
|
||||
R.xml.devicesettings_high_mtu
|
||||
|
@ -95,6 +95,7 @@ public class AmazfitGTS2Coordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey,
|
||||
R.xml.devicesettings_high_mtu
|
||||
|
@ -95,6 +95,7 @@ public class AmazfitTRexCoordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_disconnectnotification,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey,
|
||||
R.xml.devicesettings_high_mtu
|
||||
|
@ -85,7 +85,7 @@ public class MiBand2Coordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_rotatewrist_cycleinfo,
|
||||
R.xml.devicesettings_buttonactions,
|
||||
R.xml.devicesettings_reserve_alarms_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_pairingkey
|
||||
};
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ public class MiBand3Coordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_swipeunlock,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey
|
||||
};
|
||||
|
@ -98,6 +98,7 @@ public class MiBand4Coordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_swipeunlock,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey,
|
||||
R.xml.devicesettings_high_mtu
|
||||
|
@ -98,6 +98,7 @@ public class MiBand5Coordinator extends HuamiCoordinator {
|
||||
R.xml.devicesettings_swipeunlock,
|
||||
R.xml.devicesettings_sync_calendar,
|
||||
R.xml.devicesettings_expose_hr_thirdparty,
|
||||
R.xml.devicesettings_bt_connected_advertisement,
|
||||
R.xml.devicesettings_device_actions,
|
||||
R.xml.devicesettings_pairingkey,
|
||||
R.xml.devicesettings_high_mtu
|
||||
|
@ -303,11 +303,11 @@ public class InitOperationGBX100 extends AbstractBTLEOperation<CasioGBX100Device
|
||||
LOG.debug("Got BLE features, requesting BLE settings");
|
||||
requestBleSettings();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_BLE")) {
|
||||
LOG.debug("Got BLE settings, requesting advertising parameters; should write BLE settings");
|
||||
LOG.debug("Got BLE settings, requesting advertisement parameters; should write BLE settings");
|
||||
writeBleSettings(data);
|
||||
requestAdvertisingParameters();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_ADVERTISE_PARAMETER_MANAGER")) {
|
||||
LOG.debug("Got advertising parameters, requesting connection parameters; should write advertising parameters");
|
||||
LOG.debug("Got advertisement parameters, requesting connection parameters; should write advertisement parameters");
|
||||
writeAdvertisingParameters();
|
||||
requestConnectionParameters();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_CONNECTION_PARAMETER_MANAGER")) {
|
||||
|
@ -148,6 +148,7 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SYNC_CALENDAR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_TIMEFORMAT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WEARLOCATION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BT_CONNECTED_ADVERTISEMENT;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_FELL_SLEEP_BROADCAST;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_FELL_SLEEP_SELECTION;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_SELECTION_BROADCAST;
|
||||
@ -1934,6 +1935,9 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
case HuamiConst.PREF_EXPOSE_HR_THIRDPARTY:
|
||||
setExposeHRThridParty(builder);
|
||||
break;
|
||||
case PREF_BT_CONNECTED_ADVERTISEMENT:
|
||||
setBtConnectedAdvertising(builder);
|
||||
break;
|
||||
case PREF_WEARLOCATION:
|
||||
setWearLocation(builder);
|
||||
break;
|
||||
@ -2662,6 +2666,19 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
return this;
|
||||
}
|
||||
|
||||
private HuamiSupport setBtConnectedAdvertising(TransactionBuilder builder) {
|
||||
boolean enable = HuamiCoordinator.getBtConnectedAdvertising(gbDevice.getAddress());
|
||||
LOG.info("Setting connected advertisement to: " + enable);
|
||||
|
||||
if (enable) {
|
||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), HuamiService.COMMAND_ENABLE_BT_CONNECTED_ADVERTISEMENT);
|
||||
} else {
|
||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_3_CONFIGURATION), HuamiService.COMMAND_DISABLE_BT_CONNECTED_ADVERTISEMENT);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void writeToChunked(TransactionBuilder builder, int type, byte[] data) {
|
||||
final int MAX_CHUNKLENGTH = mMTU - 6;
|
||||
int remaining = data.length;
|
||||
|
@ -186,6 +186,8 @@
|
||||
<string name="pref_title_pebble_reconnect_attempts">Reconnection attempts</string>
|
||||
<string name="pref_summary_expose_hr">Allows other apps to access HR data in realtime while Gadgetbridge is connected</string>
|
||||
<string name="pref_title_expose_hr">3rd party realtime HR access</string>
|
||||
<string name="pref_title_connected_advertisement">Visible while connected</string>
|
||||
<string name="pref_summary_connected_advertisement">Makes the device discoverable via Bluetooth even when connected</string>
|
||||
<string name="pref_title_use_custom_font">Use custom font</string>
|
||||
<string name="pref_summary_use_custom_font">Enable this if your device has a custom font firmware for emoji support</string>
|
||||
<string name="pref_title_allow_high_mtu">Allow high MTU</string>
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_settings_remote"
|
||||
android:key="bt_connected_advertisement"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:summary="@string/pref_summary_connected_advertisement"
|
||||
android:title="@string/pref_title_connected_advertisement"/>
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user