Commit ab199d88 authored by topjohnwu's avatar topjohnwu

Change su logs time granularity

parent 356065d1
...@@ -27,7 +27,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper { ...@@ -27,7 +27,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
public static final String MULTIUSER_MODE = "multiuser_mode"; public static final String MULTIUSER_MODE = "multiuser_mode";
public static final String MNT_NS = "mnt_ns"; public static final String MNT_NS = "mnt_ns";
private static final int DATABASE_VER = 2; private static final int DATABASE_VER = 3;
private static final String POLICY_TABLE = "policies"; private static final String POLICY_TABLE = "policies";
private static final String LOG_TABLE = "logs"; private static final String LOG_TABLE = "logs";
private static final String SETTINGS_TABLE = "settings"; private static final String SETTINGS_TABLE = "settings";
...@@ -76,6 +76,10 @@ public class SuDatabaseHelper extends SQLiteOpenHelper { ...@@ -76,6 +76,10 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
} }
++oldVersion; ++oldVersion;
} }
if (oldVersion == 2) {
db.execSQL("UPDATE " + LOG_TABLE + " SET time=time*1000");
++oldVersion;
}
} }
private void createTables(SQLiteDatabase db) { private void createTables(SQLiteDatabase db) {
...@@ -104,7 +108,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper { ...@@ -104,7 +108,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
new String[] { String.valueOf(System.currentTimeMillis() / 1000) }); new String[] { String.valueOf(System.currentTimeMillis() / 1000) });
// Clear outdated logs // Clear outdated logs
mDb.delete(LOG_TABLE, "time < ?", new String[] { String.valueOf( mDb.delete(LOG_TABLE, "time < ?", new String[] { String.valueOf(
System.currentTimeMillis() / 1000 - magiskManager.suLogTimeout * 86400) }); System.currentTimeMillis() - magiskManager.suLogTimeout * 86400000) });
} }
public void deletePolicy(Policy policy) { public void deletePolicy(Policy policy) {
...@@ -189,7 +193,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper { ...@@ -189,7 +193,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
List<Integer> list = null; List<Integer> list = null;
String dateString = null, newString; String dateString = null, newString;
while (c.moveToNext()) { while (c.moveToNext()) {
Date date = new Date(c.getLong(c.getColumnIndex("time")) * 1000); Date date = new Date(c.getLong(c.getColumnIndex("time")));
newString = DateFormat.getDateInstance(DateFormat.MEDIUM, MagiskManager.locale).format(date); newString = DateFormat.getDateInstance(DateFormat.MEDIUM, MagiskManager.locale).format(date);
if (!TextUtils.equals(dateString, newString)) { if (!TextUtils.equals(dateString, newString)) {
dateString = newString; dateString = newString;
......
...@@ -30,7 +30,7 @@ public class SuLogEntry { ...@@ -30,7 +30,7 @@ public class SuLogEntry {
appName = c.getString(c.getColumnIndex("app_name")); appName = c.getString(c.getColumnIndex("app_name"));
command = c.getString(c.getColumnIndex("command")); command = c.getString(c.getColumnIndex("command"));
action = c.getInt(c.getColumnIndex("action")) != 0; action = c.getInt(c.getColumnIndex("action")) != 0;
date = new Date(c.getLong(c.getColumnIndex("time")) * 1000); date = new Date(c.getLong(c.getColumnIndex("time")));
} }
public ContentValues getContentValues() { public ContentValues getContentValues() {
...@@ -42,7 +42,7 @@ public class SuLogEntry { ...@@ -42,7 +42,7 @@ public class SuLogEntry {
values.put("command", command); values.put("command", command);
values.put("to_uid", toUid); values.put("to_uid", toUid);
values.put("action", action ? 1 : 0); values.put("action", action ? 1 : 0);
values.put("time", date.getTime() / 1000); values.put("time", date.getTime());
return values; return values;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment