-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UID to logs, new per-app filters
- Loading branch information
Showing
31 changed files
with
831 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
app/schemas/com.f0x1d.logfox.database.AppDatabase/9.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 9, | ||
"identityHash": "533c258b7f37e152867610670d2204c4", | ||
"entities": [ | ||
{ | ||
"tableName": "AppCrash", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`app_name` TEXT, `package_name` TEXT NOT NULL, `crash_type` INTEGER NOT NULL, `date_and_time` INTEGER NOT NULL, `log` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "appName", | ||
"columnName": "app_name", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "packageName", | ||
"columnName": "package_name", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "crashType", | ||
"columnName": "crash_type", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "dateAndTime", | ||
"columnName": "date_and_time", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "log", | ||
"columnName": "log", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": true, | ||
"columnNames": [ | ||
"id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "LogRecording", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`title` TEXT NOT NULL, `date_and_time` INTEGER NOT NULL, `file` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "title", | ||
"columnName": "title", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "dateAndTime", | ||
"columnName": "date_and_time", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "file", | ||
"columnName": "file", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": true, | ||
"columnNames": [ | ||
"id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
}, | ||
{ | ||
"tableName": "UserFilter", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`including` INTEGER NOT NULL, `allowed_levels` TEXT NOT NULL, `uid` TEXT, `pid` TEXT, `tid` TEXT, `package_name` TEXT, `tag` TEXT, `content` TEXT, `enabled` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)", | ||
"fields": [ | ||
{ | ||
"fieldPath": "including", | ||
"columnName": "including", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "allowedLevels", | ||
"columnName": "allowed_levels", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "uid", | ||
"columnName": "uid", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "pid", | ||
"columnName": "pid", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "tid", | ||
"columnName": "tid", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "packageName", | ||
"columnName": "package_name", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "tag", | ||
"columnName": "tag", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "content", | ||
"columnName": "content", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
}, | ||
{ | ||
"fieldPath": "enabled", | ||
"columnName": "enabled", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "id", | ||
"columnName": "id", | ||
"affinity": "INTEGER", | ||
"notNull": true | ||
} | ||
], | ||
"primaryKey": { | ||
"autoGenerate": true, | ||
"columnNames": [ | ||
"id" | ||
] | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
} | ||
], | ||
"views": [], | ||
"setupQueries": [ | ||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", | ||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '533c258b7f37e152867610670d2204c4')" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.f0x1d.logfox.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import com.f0x1d.logfox.adapter.base.BaseListAdapter | ||
import com.f0x1d.logfox.databinding.ItemAppBinding | ||
import com.f0x1d.logfox.model.InstalledApp | ||
import com.f0x1d.logfox.ui.viewholder.AppViewHolder | ||
|
||
class AppsAdapter( | ||
private val click: (InstalledApp) -> Unit | ||
): BaseListAdapter<InstalledApp, ItemAppBinding>(APP_DIFF) { | ||
|
||
companion object { | ||
val APP_DIFF = object : DiffUtil.ItemCallback<InstalledApp>() { | ||
override fun areItemsTheSame(oldItem: InstalledApp, newItem: InstalledApp) = oldItem.packageName == newItem.packageName | ||
|
||
override fun areContentsTheSame(oldItem: InstalledApp, newItem: InstalledApp) = oldItem == newItem | ||
} | ||
} | ||
|
||
override fun createHolder( | ||
layoutInflater: LayoutInflater, | ||
parent: ViewGroup | ||
) = AppViewHolder( | ||
ItemAppBinding.inflate(layoutInflater, parent, false), | ||
click | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 30 additions & 7 deletions
37
app/src/main/java/com/f0x1d/logfox/extensions/logline/LogLineExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
package com.f0x1d.logfox.extensions.logline | ||
|
||
import android.content.pm.PackageManager | ||
import androidx.collection.LruCache | ||
import com.f0x1d.logfox.model.LogLevel | ||
import com.f0x1d.logfox.model.LogLine | ||
import com.f0x1d.logfox.utils.UIDS | ||
|
||
private val logRegex = "(.{23}) (.{5}) (.{5}) (.) (.+?): (.+)".toRegex() | ||
private val logRegex = "(.{23}) (.{1,5}) (.{1,5}) (.{1,5}) (.) (.+?): (.+)".toRegex() | ||
// time, uid, pid, tid, level, tag, message | ||
|
||
private val uidsCache = LruCache<String, String>(200) | ||
|
||
fun LogLine( | ||
id: Long, | ||
line: String, | ||
packageManager: PackageManager | ||
) = logRegex.find(line)?.run { | ||
val uid = groupValues[2].replace(" ", "") | ||
val integerUid = uid.toIntOrNull() ?: UIDS.MAPPINGS[uid] | ||
|
||
val packageName = uidsCache.get(uid) ?: integerUid?.let { | ||
packageManager.getPackagesForUid(it)?.firstOrNull()?.also { packageName -> | ||
uidsCache.put(uid, packageName) | ||
} | ||
} | ||
|
||
fun LogLine(id: Long, line: String) = logRegex.find(line)?.run { | ||
LogLine( | ||
id, | ||
groupValues[1].replace(" ", "").run { | ||
indexOf(".").let { | ||
substring(0, it).toLong() * 1000 + substring(it + 1).toLong() | ||
} | ||
}, | ||
groupValues[2].replace(" ", ""), | ||
uid, | ||
groupValues[3].replace(" ", ""), | ||
mapLevel(groupValues[4]), | ||
groupValues[5], | ||
groupValues[6] | ||
groupValues[4].replace(" ", ""), | ||
packageName, | ||
mapLevel(groupValues[5]), | ||
groupValues[6].trim(), | ||
groupValues[7] | ||
) | ||
} | ||
|
||
private fun mapLevel(level: String) = LogLevel.values().find { it.letter == level } ?: throw RuntimeException("wtf is $level") | ||
private fun mapLevel(level: String) = LogLevel.values().find { | ||
it.letter == level | ||
} ?: throw RuntimeException("wtf is $level") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.f0x1d.logfox.model | ||
|
||
data class InstalledApp( | ||
val title: CharSequence, | ||
val packageName: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.