Do not accept negative step/intensity values in the db

(Ignore and log those requests instead)
This commit is contained in:
cpfeiffer 2015-09-01 22:53:47 +02:00
parent c5db816cd1
commit 4b4c6d1a6b
1 changed files with 9 additions and 0 deletions

View File

@ -117,6 +117,15 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHandl
*/ */
@Override @Override
public void addGBActivitySample(int timestamp, byte provider, short intensity, short steps, byte kind) { 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()) { try (SQLiteDatabase db = this.getWritableDatabase()) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(KEY_TIMESTAMP, timestamp); values.put(KEY_TIMESTAMP, timestamp);