Show access log since first install time

SinkholeService might not be running when uninstalling an app
This commit is contained in:
M66B 2017-07-16 18:46:13 +02:00
parent e6d208c77e
commit c4fa123b59
2 changed files with 4 additions and 3 deletions

View File

@ -641,7 +641,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
if (rule.expanded) {
// Access the database when expanded only
final AdapterAccess badapter = new AdapterAccess(context,
DatabaseHelper.getInstance(context).getAccess(rule.info.applicationInfo.uid));
DatabaseHelper.getInstance(context).getAccess(rule.info.applicationInfo.uid, rule.info.firstInstallTime));
holder.lvAccess.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int bposition, long bid) {

View File

@ -686,7 +686,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
notifyAccessChanged();
}
public Cursor getAccess(int uid) {
public Cursor getAccess(int uid, long since) {
lock.readLock().lock();
try {
SQLiteDatabase db = this.getReadableDatabase();
@ -696,9 +696,10 @@ public class DatabaseHelper extends SQLiteOpenHelper {
query += ", (SELECT COUNT(DISTINCT d.qname) FROM dns d WHERE d.resource IN (SELECT d1.resource FROM dns d1 WHERE d1.qname = a.daddr)) count";
query += " FROM access a";
query += " WHERE a.uid = ?";
query += " AND a.time >= ?";
query += " ORDER BY a.time DESC";
query += " LIMIT 50";
return db.rawQuery(query, new String[]{Integer.toString(uid)});
return db.rawQuery(query, new String[]{Integer.toString(uid), Long.toString(since)});
} finally {
lock.readLock().unlock();
}