aboutsummaryrefslogtreecommitdiff
path: root/autofill-parser
diff options
context:
space:
mode:
author(´⌣`ʃƪ) <pt2121@users.noreply.github.com>2021-10-03 01:32:15 -0700
committerGitHub <noreply@github.com>2021-10-03 14:02:15 +0530
commit2cef6a5bb4cb4afb1b1f1b704f83c1565e441825 (patch)
tree92db72d9578a0093d09e83d8c244b51b38cab10c /autofill-parser
parentc4df226cfd4efcfdd4aae332d1ac598336821fa7 (diff)
Replace Timber with logcat (#1509)
* Replace Timber with logcat (#1505) * Add extension for asLog which takes a message param Co-authored-by: Aditya Wasan <adityawasan55@gmail.com>
Diffstat (limited to 'autofill-parser')
-rw-r--r--autofill-parser/build.gradle.kts2
-rw-r--r--autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillFormParser.kt12
-rw-r--r--autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt6
-rw-r--r--autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt6
-rw-r--r--autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillStrategyDsl.kt40
5 files changed, 34 insertions, 32 deletions
diff --git a/autofill-parser/build.gradle.kts b/autofill-parser/build.gradle.kts
index be71acf0..ed5b5b35 100644
--- a/autofill-parser/build.gradle.kts
+++ b/autofill-parser/build.gradle.kts
@@ -21,6 +21,6 @@ dependencies {
implementation(libs.androidx.autofill)
implementation(libs.kotlin.coroutines.android)
implementation(libs.kotlin.coroutines.core)
- implementation(libs.thirdparty.timberkt)
+ implementation(libs.thirdparty.logcat)
testImplementation(libs.bundles.testDependencies)
}
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillFormParser.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillFormParser.kt
index 85381254..66205bbc 100644
--- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillFormParser.kt
+++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillFormParser.kt
@@ -12,7 +12,7 @@ import android.os.Build
import android.os.Bundle
import android.view.autofill.AutofillId
import androidx.annotation.RequiresApi
-import com.github.ajalt.timberkt.d
+import logcat.logcat
/**
* A unique identifier for either an Android app (package name) or a website (origin minus port).
@@ -84,7 +84,7 @@ private class AutofillFormParser(
private val webOrigins = mutableSetOf<String>()
init {
- d { "Request from $appPackage (${computeCertificatesHash(context, appPackage)})" }
+ logcat { "Request from $appPackage (${computeCertificatesHash(context, appPackage)})" }
parseStructure(structure)
}
@@ -92,7 +92,7 @@ private class AutofillFormParser(
val formOrigin = determineFormOrigin(context)
init {
- d { "Origin: $formOrigin" }
+ logcat { "Origin: $formOrigin" }
}
private fun parseStructure(structure: AssistStructure) {
@@ -111,11 +111,11 @@ private class AutofillFormParser(
FormField(node, fieldIndex, false)
}
if (field.relevantField) {
- d { "Relevant: $field" }
+ logcat { "Relevant: $field" }
relevantFields.add(field)
fieldIndex++
} else {
- d { "Ignored : $field" }
+ logcat { "Ignored : $field" }
ignoredIds.add(field.autofillId)
}
for (i in 0 until node.childCount) {
@@ -134,7 +134,7 @@ private class AutofillFormParser(
if (trustedBrowserInfo == null) return
node.webOrigin?.let {
if (it !in webOrigins) {
- d { "Origin encountered: $it" }
+ logcat { "Origin encountered: $it" }
webOrigins.add(it)
}
}
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt
index 2de929b9..e8f661ef 100644
--- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt
+++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillHelper.kt
@@ -15,9 +15,9 @@ import android.util.Base64
import android.view.autofill.AutofillId
import android.widget.Toast
import androidx.annotation.RequiresApi
-import com.github.ajalt.timberkt.Timber.tag
-import com.github.ajalt.timberkt.e
import java.security.MessageDigest
+import logcat.LogPriority.ERROR
+import logcat.logcat
private fun ByteArray.sha256(): ByteArray {
return MessageDigest.getInstance("SHA-256").run {
@@ -59,7 +59,7 @@ public fun computeCertificatesHash(context: Context, appPackage: String): String
info.signingInfo.signingCertificateHistory ?: info.signingInfo.apkContentsSigners
val stableHashNew = stableHash(signaturesNew.map { it.toByteArray() })
if (stableHashNew != stableHashOld)
- tag("CertificatesHash").e {
+ logcat("CertificatesHash", ERROR) {
"Mismatch between old and new hash: $stableHashNew != $stableHashOld"
}
}
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt
index 11b85b66..fec33285 100644
--- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt
+++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillScenario.kt
@@ -11,7 +11,9 @@ import android.service.autofill.Dataset
import android.view.autofill.AutofillId
import android.view.autofill.AutofillValue
import androidx.annotation.RequiresApi
-import com.github.ajalt.timberkt.e
+import logcat.LogPriority.ERROR
+import logcat.asLog
+import logcat.logcat
public enum class AutofillAction {
Match,
@@ -68,7 +70,7 @@ public sealed class AutofillScenario<out T : Any> {
}
.build()
} catch (e: Throwable) {
- e(e)
+ logcat(ERROR) { e.asLog() }
null
}
}
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillStrategyDsl.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillStrategyDsl.kt
index 3d7f9849..6d2414d2 100644
--- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillStrategyDsl.kt
+++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/AutofillStrategyDsl.kt
@@ -6,8 +6,8 @@ package com.github.androidpasswordstore.autofillparser
import android.os.Build
import androidx.annotation.RequiresApi
-import com.github.ajalt.timberkt.d
-import com.github.ajalt.timberkt.w
+import logcat.LogPriority.WARN
+import logcat.logcat
@DslMarker internal annotation class AutofillDsl
@@ -116,16 +116,16 @@ internal class SingleFieldMatcher(
val new = current.filter { tieBreaker(it, alreadyMatched) }
// skipping those tie breakers that are not satisfied for any remaining field...
if (new.isEmpty()) {
- d { "Tie breaker #${i + 1}: Didn't match any field; skipping" }
+ logcat { "Tie breaker #${i + 1}: Didn't match any field; skipping" }
continue
}
// and return if the available options have been narrowed to a single field.
if (new.size == 1) {
- d { "Tie breaker #${i + 1}: Success" }
+ logcat { "Tie breaker #${i + 1}: Success" }
current = new
break
}
- d { "Tie breaker #${i + 1}: Matched ${new.size} fields; continuing" }
+ logcat { "Tie breaker #${i + 1}: Matched ${new.size} fields; continuing" }
current = new
}
listOf(current.singleOrNull() ?: return null)
@@ -154,16 +154,16 @@ private class PairOfFieldsMatcher(
for ((i, tieBreaker) in tieBreakers.withIndex()) {
val new = current.filter { tieBreaker(it, alreadyMatched) }
if (new.isEmpty()) {
- d { "Tie breaker #${i + 1}: Didn't match any pair of fields; skipping" }
+ logcat { "Tie breaker #${i + 1}: Didn't match any pair of fields; skipping" }
continue
}
// and return if the available options have been narrowed to a single field.
if (new.size == 1) {
- d { "Tie breaker #${i + 1}: Success" }
+ logcat { "Tie breaker #${i + 1}: Success" }
current = new
break
}
- d { "Tie breaker #${i + 1}: Matched ${new.size} pairs of fields; continuing" }
+ logcat { "Tie breaker #${i + 1}: Matched ${new.size} pairs of fields; continuing" }
current = new
}
current.singleOrNull()?.toList()
@@ -323,14 +323,14 @@ private constructor(
isManualRequest: Boolean
): AutofillScenario<FormField>? {
if (singleOriginMode && !applyInSingleOriginMode) {
- d { "$name: Skipped in single origin mode" }
+ logcat { "$name: Skipped in single origin mode" }
return null
}
if (!isManualRequest && applyOnManualRequestOnly) {
- d { "$name: Skipped since not a manual request" }
+ logcat { "$name: Skipped since not a manual request" }
return null
}
- d { "$name: Applying..." }
+ logcat { "$name: Applying..." }
val scenarioBuilder = AutofillScenario.Builder<FormField>()
val alreadyMatched = mutableListOf<FormField>()
for ((type, matcher, optional, matchHidden) in matchers) {
@@ -343,13 +343,13 @@ private constructor(
val matchResult =
matcher.match(fieldsToMatchOn, alreadyMatched)
?: if (optional) {
- d { "$name: Skipping optional $type matcher" }
+ logcat { "$name: Skipping optional $type matcher" }
continue
} else {
- d { "$name: Required $type matcher didn't match; passing to next rule" }
+ logcat { "$name: Required $type matcher didn't match; passing to next rule" }
return null
}
- d { "$name: Matched $type" }
+ logcat { "$name: Matched $type" }
when (type) {
FillableFieldType.Username -> {
check(matchResult.size == 1 && scenarioBuilder.username == null)
@@ -370,9 +370,9 @@ private constructor(
return scenarioBuilder.build().takeIf { scenario ->
scenario.passesOriginCheck(singleOriginMode = singleOriginMode).also { passed ->
if (passed) {
- d { "$name: Detected scenario:\n$scenario" }
+ logcat { "$name: Detected scenario:\n$scenario" }
} else {
- w { "$name: Scenario failed origin check:\n$scenario" }
+ logcat(WARN) { "$name: Scenario failed origin check:\n$scenario" }
}
}
}
@@ -411,13 +411,13 @@ internal class AutofillStrategy private constructor(private val rules: List<Auto
isManualRequest: Boolean
): AutofillScenario<FormField>? {
val possiblePasswordFields = fields.filter { it.passwordCertainty >= CertaintyLevel.Possible }
- d { "Possible password fields: ${possiblePasswordFields.size}" }
+ logcat { "Possible password fields: ${possiblePasswordFields.size}" }
val possibleUsernameFields = fields.filter { it.usernameCertainty >= CertaintyLevel.Possible }
- d { "Possible username fields: ${possibleUsernameFields.size}" }
+ logcat { "Possible username fields: ${possibleUsernameFields.size}" }
val possibleOtpFields = fields.filter { it.otpCertainty >= CertaintyLevel.Possible }
- d { "Possible otp fields: ${possibleOtpFields.size}" }
+ logcat { "Possible otp fields: ${possibleOtpFields.size}" }
// Return the result of the first rule that matches
- d { "Rules: ${rules.size}" }
+ logcat { "Rules: ${rules.size}" }
for (rule in rules) {
return rule.match(
possiblePasswordFields,