1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-02 11:26:09 +02:00

move low-latency setting for Mi Band to per-device settings (only for Mi Band 1)

This commit is contained in:
Andreas Shimokawa 2019-06-05 12:48:33 +02:00
parent d2988f987f
commit b6a015c18b
4 changed files with 17 additions and 11 deletions

View File

@ -664,11 +664,14 @@ public static String packageNameToPebbleMsgSender(String packageName) {
deviceSharedPrefsEdit.putString("disconnect_notification_end", prefs.getString("disconnect_notification_end", "22:00"));
}
if (deviceType == MIBAND2 || deviceType == MIBAND3) {
deviceSharedPrefsEdit.putString("mi2_do_not_disturb", prefs.getString("do_not_disturb", "off"));
deviceSharedPrefsEdit.putString("mi2_do_not_disturb_start", prefs.getString("do_not_disturb_start", "1:00"));
deviceSharedPrefsEdit.putString("mi2_do_not_disturb_end", prefs.getString("do_not_disturb_end", "6:00"));
deviceSharedPrefsEdit.putString("do_not_disturb", prefs.getString("mi2_do_not_disturb", "off"));
deviceSharedPrefsEdit.putString("do_not_disturb_start", prefs.getString("mi2_do_not_disturb_start", "1:00"));
deviceSharedPrefsEdit.putString("do_not_disturb_end", prefs.getString("mi2_do_not_disturb_end", "6:00"));
}
switch (deviceType) {
case MIBAND:
deviceSharedPrefsEdit.putBoolean("low_latency_fw_update", prefs.getBoolean("mi_low_latency_fw_update", true));
break;
case AMAZFITCOR:
displayItems = prefs.getStringSet("cor_display_items", null);
break;
@ -705,6 +708,7 @@ public static String packageNameToPebbleMsgSender(String packageName) {
editor.remove("disconnect_notification");
editor.remove("disconnect_notification_start");
editor.remove("disconnect_notification_end");
editor.remove("mi_low_latency_fw_update");
editor.remove("mi2_do_not_disturb");
editor.remove("mi2_do_not_disturb_start");
editor.remove("mi2_do_not_disturb_end");

View File

@ -36,6 +36,7 @@ import androidx.annotation.NonNull;
import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
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;
@ -256,6 +257,13 @@ public class MiBandCoordinator extends AbstractDeviceCoordinator {
return isMi1S(hwVersion) || isMiPro(hwVersion);
}
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_lowlatency_fwupdate
};
}
private boolean isMi1S(String hardwareVersion) {
return MiBandConst.MI_1S.equals(hardwareVersion);
}

View File

@ -33,6 +33,7 @@ import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandService;
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
@ -187,7 +188,6 @@ public class UpdateFirmwareOperation extends AbstractMiBand1Operation {
* The Mi Band will send a notification after receiving these data to confirm if the metadata looks good to it.
*
* @param newFwVersion
* @see MiBandSupport#handleNotificationNotif
*/
private UpdateCoordinator prepareFirmwareInfo(byte[] fwBytes, int newFwVersion) throws IOException {
int newFwSize = fwBytes.length;
@ -297,7 +297,6 @@ public class UpdateFirmwareOperation extends AbstractMiBand1Operation {
*
* @param fwbytes
* @return whether the transfer succeeded or not. Only a BT layer exception will cause the transmission to fail.
* @see MiBandSupport#handleNotificationNotif
*/
private boolean sendFirmwareData(byte[] fwbytes) {
int len = fwbytes.length;
@ -311,7 +310,7 @@ public class UpdateFirmwareOperation extends AbstractMiBand1Operation {
int firmwareProgress = 0;
TransactionBuilder builder = performInitialized("send firmware packet");
if (prefs.getBoolean("mi_low_latency_fw_update", true)) {
if (GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress()).getBoolean("low_latency_fw_update", true)) {
getSupport().setLowLatency(builder);
}
for (int i = 0; i < packets; i++) {

View File

@ -464,10 +464,5 @@
android:title="@string/pref_title_keep_data_on_device"
android:summary="@string/pref_summary_keep_data_on_device"
android:defaultValue="false" />
<CheckBoxPreference
android:key="mi_low_latency_fw_update"
android:title="@string/pref_title_low_latency_fw_update"
android:summary="@string/pref_summary_low_latency_fw_update"
android:defaultValue="true" />
</PreferenceCategory>
</PreferenceScreen>