mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Huami: Do not crash when failing to parse activity summary
This commit is contained in:
parent
b5a016a03f
commit
a717fd1db2
@ -12,7 +12,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiActivitySummaryParser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.BaseActivitySummary;
|
||||
|
||||
public class ActivitySummaryJsonSummary {
|
||||
@ -73,7 +72,11 @@ public class ActivitySummaryJsonSummary {
|
||||
|
||||
private String getCorrectSummary(BaseActivitySummary item){
|
||||
if (item.getRawSummaryData() != null) {
|
||||
item = summaryParser.parseBinaryData(item);
|
||||
try {
|
||||
item = summaryParser.parseBinaryData(item);
|
||||
} catch (final Exception e) {
|
||||
LOG.error("Failed to re-parse corrected summary", e);
|
||||
}
|
||||
}
|
||||
return item.getSummaryData();
|
||||
}
|
||||
|
@ -93,7 +93,14 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
|
||||
summary = new BaseActivitySummary();
|
||||
summary.setStartTime(getLastStartTimestamp().getTime()); // due to a bug this has to be set
|
||||
summary.setRawSummaryData(buffer.toByteArray());
|
||||
summary = summaryParser.parseBinaryData(summary);
|
||||
try {
|
||||
summary = summaryParser.parseBinaryData(summary);
|
||||
} catch (final Exception e) {
|
||||
GB.toast(getContext(), "Failed to parse activity summary", Toast.LENGTH_LONG, GB.ERROR, e);
|
||||
summary = null;
|
||||
parseSummarySuccess = false;
|
||||
}
|
||||
|
||||
if (summary != null) {
|
||||
summary.setSummaryData(null); // remove json before saving to database,
|
||||
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
||||
|
Loading…
Reference in New Issue
Block a user