2019-01-30 09:10:12 +01:00
|
|
|
package com.topjohnwu.magisk.container;
|
2017-01-26 18:02:40 +01:00
|
|
|
|
|
|
|
import android.content.ContentValues;
|
|
|
|
|
2019-01-30 09:10:12 +01:00
|
|
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
2017-07-22 16:14:02 +02:00
|
|
|
|
2017-01-27 18:10:50 +01:00
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
|
|
|
|
2017-07-23 18:34:34 +02:00
|
|
|
public class SuLogEntry {
|
2017-01-26 18:02:40 +01:00
|
|
|
|
|
|
|
public int fromUid, toUid, fromPid;
|
|
|
|
public String packageName, appName, command;
|
|
|
|
public boolean action;
|
2017-01-27 18:10:50 +01:00
|
|
|
public Date date;
|
2017-01-26 18:02:40 +01:00
|
|
|
|
|
|
|
public SuLogEntry(Policy policy) {
|
|
|
|
fromUid = policy.uid;
|
|
|
|
packageName = policy.packageName;
|
|
|
|
appName = policy.appName;
|
2018-10-28 03:06:24 +01:00
|
|
|
action = policy.policy == Policy.ALLOW;
|
2017-01-26 18:02:40 +01:00
|
|
|
}
|
|
|
|
|
2018-10-27 21:08:11 +02:00
|
|
|
public SuLogEntry(ContentValues values) {
|
|
|
|
fromUid = values.getAsInteger("from_uid");
|
|
|
|
packageName = values.getAsString("package_name");
|
|
|
|
appName = values.getAsString("app_name");
|
|
|
|
fromPid = values.getAsInteger("from_pid");
|
|
|
|
command = values.getAsString("command");
|
|
|
|
toUid = values.getAsInteger("to_uid");
|
|
|
|
action = values.getAsInteger("action") != 0;
|
|
|
|
date = new Date(values.getAsLong("time"));
|
2017-01-26 18:02:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public ContentValues getContentValues() {
|
|
|
|
ContentValues values = new ContentValues();
|
|
|
|
values.put("from_uid", fromUid);
|
|
|
|
values.put("package_name", packageName);
|
|
|
|
values.put("app_name", appName);
|
|
|
|
values.put("from_pid", fromPid);
|
|
|
|
values.put("command", command);
|
|
|
|
values.put("to_uid", toUid);
|
2017-01-27 18:10:50 +01:00
|
|
|
values.put("action", action ? 1 : 0);
|
2017-07-23 19:20:03 +02:00
|
|
|
values.put("time", date.getTime());
|
2017-01-26 18:02:40 +01:00
|
|
|
return values;
|
|
|
|
}
|
2017-01-27 18:10:50 +01:00
|
|
|
|
|
|
|
public String getDateString() {
|
2018-07-31 11:35:58 +02:00
|
|
|
return DateFormat.getDateInstance(DateFormat.MEDIUM, LocaleManager.locale).format(date);
|
2017-01-27 18:10:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getTimeString() {
|
2018-07-31 11:35:58 +02:00
|
|
|
return new SimpleDateFormat("h:mm a", LocaleManager.locale).format(date);
|
2017-01-27 18:10:50 +01:00
|
|
|
}
|
2017-01-26 18:02:40 +01:00
|
|
|
}
|