Huawei: Allow encryption to be enabled / disabled

This commit is contained in:
José Rebelo
2026-05-17 00:46:18 +02:00
committed by José Rebelo
parent e93d6105bf
commit c1f5647b6f
5 changed files with 36 additions and 1 deletions
@@ -573,6 +573,7 @@ public abstract class HuaweiCoordinator extends AbstractDeviceCoordinator {
// Developer // Developer
final List<Integer> developer = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DEVELOPER); final List<Integer> developer = deviceSpecificSettings.addRootScreen(DeviceSpecificSettingsScreen.DEVELOPER);
developer.add(R.xml.devicesettings_force_encryption);
developer.add(R.xml.devicesettings_huawei_debug); developer.add(R.xml.devicesettings_huawei_debug);
if (deviceState.supportsGpsAndTimeToDevice()) if (deviceState.supportsGpsAndTimeToDevice())
developer.add(R.xml.devicesettings_huawei_gps_and_time); developer.add(R.xml.devicesettings_huawei_gps_and_time);
@@ -236,6 +236,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.MediaManager; import nodomain.freeyourgadget.gadgetbridge.util.MediaManager;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
import nodomain.freeyourgadget.gadgetbridge.util.preferences.DevicePrefs;
public class HuaweiSupportProvider { public class HuaweiSupportProvider {
private static final Logger LOG = LoggerFactory.getLogger(HuaweiSupportProvider.class); private static final Logger LOG = LoggerFactory.getLogger(HuaweiSupportProvider.class);
@@ -381,7 +382,13 @@ public class HuaweiSupportProvider {
this.context = context; this.context = context;
this.huaweiType = getCoordinator().getHuaweiType(); this.huaweiType = getCoordinator().getHuaweiType();
this.paramsProvider.setAW(getCoordinator().getHuaweiType() == HuaweiDeviceType.AW); this.paramsProvider.setAW(getCoordinator().getHuaweiType() == HuaweiDeviceType.AW);
this.paramsProvider.setTransactionsCrypted(getCoordinator().isTransactionCrypted()); final DevicePrefs devicePrefs = GBApplication.getDevicePrefs(device);
final boolean transactionCrypted = switch (devicePrefs.getString("force_encryption", "default")) {
case "force_enabled" -> true;
case "force_disabled" -> false;
default -> getCoordinator().isTransactionCrypted();
};
this.paramsProvider.setTransactionsCrypted(transactionCrypted);
mediaManager = new MediaManager(context); mediaManager = new MediaManager(context);
} }
+11
View File
@@ -5351,6 +5351,17 @@
<item>@string/pref_force_connection_type_bt_classic_value</item> <item>@string/pref_force_connection_type_bt_classic_value</item>
</string-array> </string-array>
<string-array name="pref_force_encryption_names">
<item>@string/pref_default</item>
<item>@string/preference_force_enabled</item>
<item>@string/preference_force_disabled</item>
</string-array>
<string-array name="pref_force_encryption_values">
<item>default</item>
<item>force_enabled</item>
<item>force_disabled</item>
</string-array>
<string-array name="pref_dashboard_widgets_order"> <string-array name="pref_dashboard_widgets_order">
<item>@string/pref_dashboard_widget_today_title</item> <item>@string/pref_dashboard_widget_today_title</item>
<item>@string/pref_dashboard_widget_goals_chart_title</item> <item>@string/pref_dashboard_widget_goals_chart_title</item>
+4
View File
@@ -4055,6 +4055,10 @@
<string name="pref_force_connection_type_auto">Automatic</string> <string name="pref_force_connection_type_auto">Automatic</string>
<string name="pref_force_connection_type_ble">Bluetooth LE</string> <string name="pref_force_connection_type_ble">Bluetooth LE</string>
<string name="pref_force_connection_type_bt_classic">Bluetooth Classic</string> <string name="pref_force_connection_type_bt_classic">Bluetooth Classic</string>
<string name="encryption">Encryption</string>
<string name="development_preference_do_not_change">Do not change unless instructed, or if you are developer</string>
<string name="preference_force_enabled">Force enabled</string>
<string name="preference_force_disabled">Force disabled</string>
<string name="pref_force_connection_type_auto_value" translatable="false">BOTH</string> <string name="pref_force_connection_type_auto_value" translatable="false">BOTH</string>
<string name="pref_force_connection_type_ble_value" translatable="false">BLE</string> <string name="pref_force_connection_type_ble_value" translatable="false">BLE</string>
<string name="pref_force_connection_type_bt_classic_value" translatable="false">BT_CLASSIC</string> <string name="pref_force_connection_type_bt_classic_value" translatable="false">BT_CLASSIC</string>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ListPreference
android:defaultValue="default"
android:entries="@array/pref_force_encryption_names"
android:entryValues="@array/pref_force_encryption_values"
android:icon="@drawable/ic_lock_open"
android:key="force_encryption"
android:summary="@string/development_preference_do_not_change"
android:title="@string/encryption" />
</androidx.preference.PreferenceScreen>