1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 10:05:49 +01:00

Revert "Bangle.js:actTrk:fetch all logs, then parse them"

This reverts commit 6b941f9277f70d642cfaa430d3d917ba6b559d17.
This commit is contained in:
Ganblejs 2024-03-06 12:04:25 +01:00 committed by José Rebelo
parent 6936053734
commit 7734fbe4b0
2 changed files with 6 additions and 24 deletions

View File

@ -58,15 +58,6 @@ class BangleJSActivityTrack extends BangleJSDeviceSupport {
GB.toast(context.getString(R.string.activity_detail_end_label) + " : " + context.getString(R.string.busy_task_fetch_sports_details), Toast.LENGTH_SHORT, GB.INFO);
}
static JSONArray makeDeepCopyOfJSONArray(JSONArray tracksList) throws JSONException {
JSONArray tracksListIntact = new JSONArray();
String[] tmpTracksList = tracksList.join(",").replace("\"","").split(","); // Hacky way to get a sort of deep copy.
for (int i = 0; i<tmpTracksList.length; i++) {
tracksListIntact.put(tmpTracksList[i]);
}
return tracksListIntact;
}
private static Timer timeout;
private static TimerTask timeoutTask;
@ -195,7 +186,7 @@ class BangleJSActivityTrack extends BangleJSDeviceSupport {
return o;
}
static JSONArray handleActTrk(JSONObject json, JSONArray tracksList, JSONArray tracksListIntact, int prevPacketCount, GBDevice device, Context context) throws JSONException {
static JSONArray handleActTrk(JSONObject json, JSONArray tracksList, int prevPacketCount, GBDevice device, Context context) throws JSONException {
stopAndRestartTimeout(device, context);
JSONArray returnArray;
@ -230,14 +221,8 @@ class BangleJSActivityTrack extends BangleJSDeviceSupport {
if (!json.has("lines")) { // if no lines were sent with this json object, it signifies that the whole recorder log has been transmitted.
setLatestFetchedRecorderLog(dir, log);
if (tracksList.length()==0) { // All data from all Recorder logs have been fetched.
LOG.warn("tracksListIntact:\n" + tracksListIntact);
for (int i = 0; i<tracksListIntact.length(); i++){
String currLog = tracksListIntact.getString(i);
LOG.info("currLog: " + currLog);
String currFilename = "recorder.log" + currLog + ".csv";
parseFetchedRecorderCSV(dir, currFilename, currLog, device, context);
}
parseFetchedRecorderCSV(dir, filename, log, device, context); // TODO: Parsing could be done after we fetched all recorder logs instead, making the fetching quicker and maybe less prone to user errors.
if (tracksList.length()==0) {
signalFetchingEnded(device, context);
int resetPacketCount = -1;
LOG.info("packetCount reset1: " + resetPacketCount);
@ -245,7 +230,6 @@ class BangleJSActivityTrack extends BangleJSDeviceSupport {
} else {
JSONObject requestTrackObj = BangleJSActivityTrack.compileTrackRequest(tracksList.getString(0), 1==tracksList.length());
tracksList.remove(0);
LOG.warn("tracksListIntact2:\n" + tracksListIntact);
int resetPacketCount = -1;
LOG.info("packetCount reset2: " + resetPacketCount);
returnArray = new JSONArray().put(requestTrackObj).put(tracksList).put(resetPacketCount);

View File

@ -514,9 +514,8 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
}
}
private JSONArray tracksList;
private JSONArray tracksListIntact;
private int packetCount;
JSONArray tracksList;
int packetCount;
private void handleUartRxJSON(JSONObject json) throws JSONException {
String packetType = json.getString("t");
switch (packetType) {
@ -570,14 +569,13 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
if (tracksList!=null) {
JSONObject requestTrackObj = BangleJSActivityTrack.compileTrackRequest(tracksList.getString(0), 1==tracksList.length());
uartTxJSON("requestActivityTrackLog", requestTrackObj);
tracksListIntact = BangleJSActivityTrack.makeDeepCopyOfJSONArray(tracksList);
tracksList.remove(0);
packetCount = -1;
}
break;
case "actTrk":
LOG.info("packetCount1: " + packetCount);
JSONArray returnArray = BangleJSActivityTrack.handleActTrk(json, tracksList, tracksListIntact, packetCount, getDevice(), getContext());
JSONArray returnArray = BangleJSActivityTrack.handleActTrk(json, tracksList, packetCount, getDevice(), getContext());
if (!returnArray.isNull(0)) uartTxJSON("requestActivityTrackLog", returnArray.getJSONObject(0));
tracksList = returnArray.getJSONArray(1);
packetCount = returnArray.getInt(2);