From b668e035604edfa45712298374af08a019c5859e Mon Sep 17 00:00:00 2001 From: F0x1d Date: Sun, 17 Dec 2023 16:40:25 +0300 Subject: [PATCH] [feat]: handling names in uids --- .../com/f0x1d/logfox/extensions/logline/LogLineExtensions.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/f0x1d/logfox/extensions/logline/LogLineExtensions.kt b/app/src/main/java/com/f0x1d/logfox/extensions/logline/LogLineExtensions.kt index a9daf2c4..9f62980f 100644 --- a/app/src/main/java/com/f0x1d/logfox/extensions/logline/LogLineExtensions.kt +++ b/app/src/main/java/com/f0x1d/logfox/extensions/logline/LogLineExtensions.kt @@ -8,6 +8,7 @@ import com.f0x1d.logfox.utils.UIDS private val logRegex = "(.{14}) (.{1,5}) (.{1,5}) (.{1,5}) (.) (.+?): (.+)".toRegex() // time, uid, pid, tid, level, tag, message +private val uidRegex = "u(.+?).*a(.+)".toRegex() private val uidsCache = LruCache(200) @@ -17,7 +18,9 @@ fun LogLine( context: Context ) = logRegex.find(line.trim())?.run { val uid = groupValues[2].replace(" ", "") - val integerUid = uid.toIntOrNull() ?: UIDS.MAPPINGS[uid] + val integerUid = uidRegex.find(uid)?.run { + 100_000 * groupValues[1].toInt() + 10_000 + groupValues[2].toInt() + } ?: uid.toIntOrNull() ?: UIDS.MAPPINGS[uid] val packageName = uidsCache[uid] ?: integerUid?.let { context.packageManager.getPackagesForUid(it)?.firstOrNull()?.also { packageName ->