Skip to content

Commit efcd6ed

Browse files
Copilotgerhardol
andauthored
Fix debug artifacts, NPE in reportDisconnected, and silent failure after max reconnects (#1332)
* Initial plan * Fix debug artifacts, NPE in reportDisconnected, and silent failure after max reconnects Co-authored-by: gerhardol <6248932+gerhardol@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gerhardol <6248932+gerhardol@users.noreply.github.com>
1 parent 22b7942 commit efcd6ed

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

hrdevice/src/org/runnerup/hr/AndroidBLEHRProvider.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ private static String stateToString(int state) {
137137
public void open(Handler handler, HRClient hrClient) {
138138
this.hrClient = hrClient;
139139
this.hrClientHandler = handler;
140-
System.err.println("KESO open: " + getName());
141-
142140
if (btAdapter == null) {
143141
btAdapter = BluetoothAdapter.getDefaultAdapter();
144142
}
@@ -908,11 +906,11 @@ private void reportDisconnected(String msg) {
908906
}
909907

910908
if (isDisconnecting) {
911-
hrClient.onDisconnectResult(true);
909+
client.onDisconnectResult(true);
912910
} else if (isConnecting) {
913-
hrClient.onConnectResult(false);
911+
client.onConnectResult(false);
914912
} else if (isConnected) {
915-
hrClient.onConnectResult(false);
913+
client.onConnectResult(false);
916914
}
917915
}
918916

hrdevice/src/org/runnerup/hr/RetryingHRProviderProxy.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ public void onCloseResult(boolean ok) {
229229
}
230230
attempt++;
231231
if (attempt >= 10) {
232-
RetryingHRProviderProxy.this.log(from + ", attempt: " + attempt);
232+
RetryingHRProviderProxy.this.log(from + ", attempt: " + attempt + " => give up");
233+
registerDefault();
234+
HRClient c = RetryingHRProviderProxy.this.client;
235+
if (c != null) {
236+
c.onConnectResult(false);
237+
}
233238
return;
234239
}
235240
handler.postDelayed(
@@ -337,7 +342,7 @@ public int getBatteryLevel() {
337342
@Override
338343
public void log(HRProvider src, String msg) {
339344
String extra = (client == null) ? "Log w/o client: " : "";
340-
Log.d(src.getLogName(), "KESO: " + extra + msg);
345+
Log.d(src.getLogName(), extra + msg);
341346
if (client != null) {
342347
if (Looper.myLooper() == Looper.getMainLooper()) {
343348
client.log(src, msg);

0 commit comments

Comments
 (0)