From 5b2189528360f1ae95f0af53d0560b4c540f8d2f Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 7 May 2016 21:46:20 +0200 Subject: [PATCH 01/11] try to get BT alias name by reflection. Useful if you have a lot of Mi Bands --- .../gadgetbridge/util/DeviceHelper.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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 05a629768..ee274dc7b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java @@ -5,6 +5,11 @@ import android.bluetooth.BluetoothDevice; import android.content.Context; import android.widget.Toast; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -22,6 +27,9 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; public class DeviceHelper { + + private static final Logger LOG = LoggerFactory.getLogger(DeviceHelper.class); + private static final DeviceHelper instance = new DeviceHelper(); public static DeviceHelper getInstance() { @@ -95,12 +103,23 @@ public class DeviceHelper { public GBDevice toSupportedDevice(BluetoothDevice device) { GBDeviceCandidate candidate = new GBDeviceCandidate(device, GBDevice.RSSI_UNKNOWN); + + String deviceName = device.getName(); + try { + Method method = device.getClass().getMethod("getAliasName"); + if (method != null) { + deviceName = (String) method.invoke(device); + } + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignore) { + LOG.info("Could not get device alias for " + deviceName); + } + if (coordinator != null && coordinator.supports(candidate)) { - return new GBDevice(device.getAddress(), device.getName(), coordinator.getDeviceType()); + return new GBDevice(device.getAddress(), deviceName, coordinator.getDeviceType()); } for (DeviceCoordinator coordinator : getAllCoordinators()) { if (coordinator.supports(candidate)) { - return new GBDevice(device.getAddress(), device.getName(), coordinator.getDeviceType()); + return new GBDevice(device.getAddress(), deviceName, coordinator.getDeviceType()); } } return null; From 9b7f2c1e915f47e3b569ccb6a88a9d673e835688 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sun, 8 May 2016 17:19:01 +0200 Subject: [PATCH 02/11] try to fix weiredness with pebble reconnects --- .../service/devices/pebble/PebbleIoThread.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java index d22650273..43b86e2f1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java @@ -396,6 +396,14 @@ public class PebbleIoThread extends GBDeviceIoThread { } catch (IOException ex) { ex.printStackTrace(); LOG.info("error while reconnecting"); + } finally { + try { + if (mBtServerSocket != null) { + mBtServerSocket.close(); + mBtServerSocket = null; + } + } catch (IOException ignore) { + } } } if (!mIsConnected) { From 1a353239c45c91e04db7cbe39f6f86429618910a Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 8 May 2016 21:38:55 +0200 Subject: [PATCH 03/11] Fix log content --- .../nodomain/freeyourgadget/gadgetbridge/GBApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java index 9020d8835..e17c4584a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java @@ -179,7 +179,7 @@ public class GBApplication extends Application { root.addAppender(fileLogger); } } catch (Throwable ex) { - Log.e("GBApplication", "Error removing logger FILE appender", ex); + Log.e("GBApplication", "Error adding logger FILE appender", ex); } } From 40837996f86010dea9f472e733ae1a3b1420335a Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 8 May 2016 21:39:23 +0200 Subject: [PATCH 04/11] Fix logback initialization, closes #300 --- .../nodomain/freeyourgadget/gadgetbridge/util/Prefs.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/Prefs.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/Prefs.java index 2b4fcdb62..03aca1aa2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/Prefs.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/Prefs.java @@ -1,6 +1,7 @@ package nodomain.freeyourgadget.gadgetbridge.util; import android.content.SharedPreferences; +import android.util.Log; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,7 +12,9 @@ import java.util.Set; * Wraps SharedPreferences to avoid ClassCastExceptions and others. */ public class Prefs { - private static final Logger LOG = LoggerFactory.getLogger(Prefs.class); + private static final String TAG = "Prefs"; + // DO NOT use slf4j logger here, this would break its configuration via GBApplication +// private static final Logger LOG = LoggerFactory.getLogger(Prefs.class); private final SharedPreferences preferences; @@ -136,7 +139,7 @@ public class Prefs { } private void logReadError(String key, Exception ex) { - LOG.error("Error reading preference value: " + key + "; returning default value", ex); // log the first exception + Log.e(TAG, "Error reading preference value: " + key + "; returning default value", ex); // log the first exception } /** From b805612ae5ba579e1a93d08ed65c8c557d585da3 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 8 May 2016 21:39:55 +0200 Subject: [PATCH 05/11] Allow in-process dex with 2GB heap, as recommended --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index 1d3591c8a..8c1449720 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,6 +11,7 @@ # The setting is particularly useful for tweaking memory settings. # Default value: -Xmx10248m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit From e2def7b467e0cf02ec1c6ad7f9ce836debae0ff0 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 14 May 2016 12:15:48 +0200 Subject: [PATCH 06/11] update changelog, bump version --- CHANGELOG.md | 11 ++++++++--- app/build.gradle | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 285abea9a..1ceacbab0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,17 @@ ###Changelog -####Version (0.9.6) +####Version 0.9.7 +* Pebble: hopefully fix some reconnect issues +* Show aliases for BT Devices if they had been renamed in BT Settings +* Do not show a hint about App Manager when a Mi Band is connected + +####Version 0.9.6 * Again some UI/theme improvements * New preference to reconnect after connection loss (defaults to true) * Fix crash when dealing with certain old preference values * Mi Band: automatically reconnect when back in range after connection loss * Mi Band 1S: display heart rate value again when invoked via the Debug view -####Version (0.9.5) +####Version 0.9.5 * Several UI Improvements * Easier First-time setup by using a FAB * Optional Dark Theme @@ -16,7 +21,7 @@ * Mi Band 1S: Initial live heartrate tracking * Fix certain crash in charts activity on slower devices (#277) -####Version (0.9.4) +####Version 0.9.4 * Pebble: support pebble health datalog messages of firmware 3.11 (this adds support for deep sleep!) * Pebble: try to reconnect on new notifications and phone calls when connection was lost unexpectedly * Pebble: delay between reconnection attempts (from 1 up to 64 seconds) diff --git a/app/build.gradle b/app/build.gradle index d567c3f32..fffe7f3cb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -16,8 +16,8 @@ android { targetSdkVersion 23 // note: always bump BOTH versionCode and versionName! - versionName "0.9.6" - versionCode 50 + versionName "0.9.7" + versionCode 51 } buildTypes { release { From 5efe9a5eb86b7e8b51fba995461de3fea17fe2e4 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 14 May 2016 12:23:01 +0200 Subject: [PATCH 07/11] update japanese and geraman translations form transifex (THANKS!) I did not merge others because tx pull deletes stuff again --- app/src/main/res/values-de/strings.xml | 18 +++++++++++++++++- app/src/main/res/values-ja/strings.xml | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 7dfeb3f71..121df48e8 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -32,6 +32,9 @@ Datum und Zeit Uhrzeit synchronisieren Synchronisiere die Urzeit mit dem Gerät (bei Verbindingsaufbau und wenn die Zeit oder Zeitzone auf dem Android Gerät eingestellt wird) + Thema + Hell + Dunkel Benachrichtigungen Wiederholungen Anrufe @@ -71,6 +74,7 @@ Bluetooth wird nicht unterstützt. Bluetooth ist abgeschaltet. berühre das verbundene Gerät, um den App Manager zu starten + Tippe auf ein verbundenes Gerät, um die Aktivitäten anzuzeigen berühre ein Gerät zum Verbinden Verbindung kann nicht aufgebaut werden. BT Adresse ungültig? Gadgetbridge läuft @@ -179,9 +183,11 @@ Schritte Live Aktivität Schritte heute, Ziel: %1$s + Transfer von Aktivitätsdaten nicht bestätigen Wenn der Transfer der Aktivitätsdaten nicht bestätigt wird, werden die Daten nicht auf dem Mi Band gelöscht. Das ist Sinnvoll, wenn neben Gadgetbridge noch andere Apps auf das Mi Band zugreifen. Aktivitätsdaten verbleiben auf dem Mi Band, auch nach der Synchronisierung. Hilfreich wenn das Mi Band mit weiteren Apps verwendet wird. - Transfer von Aktivitätsdaten nicht bestätigen + Benutze Modus mit niedriger Latenz für FW-Updates + Dies kann bei Geräten helfen, bei denen Firmwareupdates fehlschlagen Verlauf Schritte Akt. Schritte pro Minute Schritte insgesamt @@ -196,6 +202,7 @@ Aktivitätsdaten auf dem Gerät lassen Inkompatible Firmware Diese Firmware ist nicht mit dem Gerät kompatibel + Verwende den Herzfrequenzsensor um die Schlaferkennung zu verbessern warte auf eingehende Verbindung Erneut installieren Über Dich @@ -205,10 +212,19 @@ Gewicht in kg aktivieren deaktivieren + Authentifiziere + Authentifizierung erforderlich Zzz Widget hinzufügen Gewünschte Schlafdauer in Stunden Ein Wecker wurde auf %1$02d:%2$02d gestellt HW: %1$s FW: %1$s + Fehler beim Erstellen des Verzeichnisses für Logdateien: %1$s + HF: + Firmwareupdate wird durchgeführt + Firmware wurde nicht gesendet + Herzfrequenz + Herzfrequenz + Verbindungen automatisch wiederherstellen diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 5018b7d20..864ce5412 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -74,6 +74,7 @@ Bluetoothはサポートされていません。 Bluetoothは無効です。 アプリマネージャーの接続されたデバイスをタップ + アクティビティの接続されたデバイスをタップ 接続するデバイスをタップ 接続できません。 BTアドレスが無効? ガジェットブリッジは実行中 @@ -182,9 +183,11 @@ 歩数 生活活動 今日の歩数、目標: %1$s + 活動データ転送に応答しない 活動データは、バンドが応答しない場合は、クリアされません。 GBを他のアプリと一緒に使用する場合に便利です。 同期後もMi Bandに活動データを保持します。 GBを他のアプリと一緒に使用する場合に便利です。 - 活動データ転送に応答しない + FW の更新に低遅延モードを使用する + これはファームウェアの更新が失敗するデバイスで役立つことがあります 歩数履歴 現在の歩数/分 合計歩数 @@ -225,4 +228,5 @@ ファームウェアを送信しませんでした 心拍数 心拍数 + 自動的に再接続 From 59638432163923231c6a76ae8478643c4f03b8c1 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 15 May 2016 00:15:31 +0200 Subject: [PATCH 08/11] Experimental support for #274 (untested yet) --- .../gadgetbridge/devices/miband/MiBandConst.java | 1 + .../gadgetbridge/devices/miband/UserInfo.java | 2 +- .../gadgetbridge/service/devices/miband/DeviceInfo.java | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java index 6853b3714..8379d75bd 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java @@ -26,6 +26,7 @@ public final class MiBandConst { public static final String MI_1 = "1"; public static final String MI_1A = "1A"; public static final String MI_1S = "1S"; + public static final String MI_AMAZFIT = "Amazfit"; public static int getNotificationPrefIntValue(String pref, String origin, Prefs prefs, int defaultValue) { String key = getNotificationPrefKey(pref, origin); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/UserInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/UserInfo.java index 5bb901b3d..4bc728c4c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/UserInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/UserInfo.java @@ -85,7 +85,7 @@ public class UserInfo { sequence[8] = (byte) (type & 0xff); int aliasFrom = 9; - if (mDeviceInfo.isMili1A() || mDeviceInfo.isMili1S()) { + if (!mDeviceInfo.isMili1()) { sequence[9] = (byte) (mDeviceInfo.feature & 255); sequence[10] = (byte) (mDeviceInfo.appearance & 255); aliasFrom = 11; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/DeviceInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/DeviceInfo.java index 1072ff50c..3ba149df6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/DeviceInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/DeviceInfo.java @@ -112,6 +112,10 @@ public class DeviceInfo extends AbstractInfo { return (feature == 4 && appearance == 0) || hwVersion == 4; } + public boolean isAmazFit() { + return hwVersion == 6; + } + public String getHwVersion() { if (isMili1()) { return MiBandConst.MI_1; @@ -122,6 +126,9 @@ public class DeviceInfo extends AbstractInfo { if (isMili1S()) { return MiBandConst.MI_1S; } + if (isAmazFit()) { + return MiBandConst.MI_AMAZFIT; + } return "?"; } } From 3a1f91b5a8860053a6229952ce8a80ba3bf5350b Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 15 May 2016 00:21:55 +0200 Subject: [PATCH 09/11] Default to low latency mode #287 Tested with Mi1A and Mi1S -- works fine and faster than without low-latency mode. --- .../devices/miband/operations/UpdateFirmwareOperation.java | 2 +- app/src/main/res/xml/miband_preferences.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/UpdateFirmwareOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/UpdateFirmwareOperation.java index 5b733b3f1..32185d832 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/UpdateFirmwareOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/UpdateFirmwareOperation.java @@ -288,7 +288,7 @@ public class UpdateFirmwareOperation extends AbstractMiBandOperation { int firmwareProgress = 0; TransactionBuilder builder = performInitialized("send firmware packet"); - if (prefs.getBoolean("mi_low_latency_fw_update", false)) { + if (prefs.getBoolean("mi_low_latency_fw_update", true)) { getSupport().setLowLatency(builder); } for (int i = 0; i < packets; i++) { diff --git a/app/src/main/res/xml/miband_preferences.xml b/app/src/main/res/xml/miband_preferences.xml index 041fc6282..37e5d7777 100644 --- a/app/src/main/res/xml/miband_preferences.xml +++ b/app/src/main/res/xml/miband_preferences.xml @@ -165,6 +165,6 @@ 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="false" /> + android:defaultValue="true" /> \ No newline at end of file From d66f842e9b0e367ec20372a86705e735052acdd0 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sun, 15 May 2016 22:24:37 +0200 Subject: [PATCH 10/11] Mi Band: Make sure live activity gets stopped when using the back button --- .../gadgetbridge/activities/charts/LiveActivityFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java index 7b2013729..19a62a4b4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/LiveActivityFragment.java @@ -351,6 +351,7 @@ public class LiveActivityFragment extends AbstractChartFragment { @Override public void onDestroyView() { + onMadeInvisibleInActivity(); LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mReceiver); super.onDestroyView(); } From 8c88223f267a8ca7f7c7bc0ebe51f19047a7c095 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sun, 15 May 2016 23:29:19 +0200 Subject: [PATCH 11/11] update changelog --- CHANGELOG.md | 3 +++ app/src/main/res/xml/changelog_master.xml | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ceacbab0..bf801f266 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ###Changelog ####Version 0.9.7 * Pebble: hopefully fix some reconnect issues +* Mi Band: fix live activity monitoring running forever if back button pressed +* Mi Band: allow low latency firmware updates, fixes update with some phones +* Mi Band: inital experimental and probably broken support for Amazfit * Show aliases for BT Devices if they had been renamed in BT Settings * Do not show a hint about App Manager when a Mi Band is connected diff --git a/app/src/main/res/xml/changelog_master.xml b/app/src/main/res/xml/changelog_master.xml index ab86fe0d9..425e5c4a0 100644 --- a/app/src/main/res/xml/changelog_master.xml +++ b/app/src/main/res/xml/changelog_master.xml @@ -1,5 +1,13 @@ + + Pebble: hopefully fix some reconnect issues + Mi Band: fix live activity monitoring running forever if back button pressed + Mi Band: allow low latency firmware updates, fixes update with some phones + Mi Band: inital experimental and probably broken support for Amazfit + Show aliases for BT Devices if they had been renamed in BT Settings + Do not show a hint about App Manager when a Mi Band is connected + Again some UI/theme improvements New preference to reconnect after connection loss (defaults to true)