From 11dadcf93f8eadc34e85a529dd6d5414f5bbe878 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 7 Feb 2016 09:43:28 +0100 Subject: [PATCH] Group addresses for access notifications --- .../main/java/eu/faircode/netguard/DatabaseHelper.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java b/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java index 41f8f1d0..37f1ba77 100644 --- a/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java +++ b/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java @@ -454,9 +454,13 @@ public class DatabaseHelper extends SQLiteOpenHelper { public Cursor getAccessUnset(int uid) { SQLiteDatabase db = this.getReadableDatabase(); - return db.query("access", null, - "uid = ? AND block < 0", new String[]{Integer.toString(uid)}, - null, null, "time DESC"); + String query = "SELECT MAX(time) AS time, daddr, allowed"; + query += " FROM access"; + query += " WHERE uid = ?"; + query += " AND block < 0"; + query += " GROUP BY daddr, allowed"; + query += " ORDER BY time DESC"; + return db.rawQuery(query, new String[]{Integer.toString(uid)}); } public long getRuleCount(int uid) {