From 4b4c6d1a6b383fcb762b3442e0a7978eb368cc48 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Tue, 1 Sep 2015 22:53:47 +0200 Subject: [PATCH] Do not accept negative step/intensity values in the db (Ignore and log those requests instead) --- .../gadgetbridge/database/ActivityDatabaseHandler.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/database/ActivityDatabaseHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/database/ActivityDatabaseHandler.java index e2dfeef0..59ee6d07 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/database/ActivityDatabaseHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/database/ActivityDatabaseHandler.java @@ -117,6 +117,15 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHandl */ @Override public void addGBActivitySample(int timestamp, byte provider, short intensity, short steps, byte kind) { + if (intensity < 0) { + LOG.error("negative intensity received, ignoring"); + intensity = 0; + } + if (steps < 0) { + LOG.error("negative steps received, ignoring"); + steps = 0; + } + try (SQLiteDatabase db = this.getWritableDatabase()) { ContentValues values = new ContentValues(); values.put(KEY_TIMESTAMP, timestamp);