Limit number of notified IP addresses to 7

This commit is contained in:
M66B 2016-02-22 14:16:41 +01:00
parent 12d87bc4f1
commit c56ba04df8
2 changed files with 4 additions and 2 deletions

View File

@ -670,7 +670,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
}
}
public Cursor getAccessUnset(int uid) {
public Cursor getAccessUnset(int uid, int limit) {
mLock.readLock().lock();
try {
SQLiteDatabase db = this.getReadableDatabase();
@ -682,6 +682,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
query += " AND block < 0";
query += " GROUP BY daddr, allowed";
query += " ORDER BY time DESC";
if (limit > 0)
query += " LIMIT " + limit;
return db.rawQuery(query, new String[]{Integer.toString(uid)});
} finally {
mLock.readLock().unlock();

View File

@ -1960,7 +1960,7 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
sp.setSpan(new StyleSpan(Typeface.BOLD), pos, pos + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
notification.addLine(sp);
Cursor cursor = DatabaseHelper.getInstance(SinkholeService.this).getAccessUnset(uid);
Cursor cursor = DatabaseHelper.getInstance(SinkholeService.this).getAccessUnset(uid, 7);
int colDAddr = cursor.getColumnIndex("daddr");
int colTime = cursor.getColumnIndex("time");
int colAllowed = cursor.getColumnIndex("allowed");