summaryrefslogtreecommitdiff
path: root/autofill-parser/src
diff options
context:
space:
mode:
authorFabian Meumertzheim <4312191+fmeum@users.noreply.github.com>2020-12-07 08:48:16 +0100
committerHarsh Shandilya <me@msfjarvis.dev>2020-12-21 20:28:13 +0530
commitfb5fe77e668df9140594763c912403d69f470ae1 (patch)
tree37ada03a515364395dda1479dd81e39e8152f3a0 /autofill-parser/src
parent295af9eff8adffb2a49d47bcbe6a09fdd068c154 (diff)
Mark Chrome Canary as non-flaky and allowing save (#1237)
* Mark Chrome Canary as non-flaky and allowing save * autofill-parser: update API dump Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * autofill-parser: bump snapshot version Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> Co-authored-by: Harsh Shandilya <me@msfjarvis.dev> (cherry picked from commit 2e43d77c5c72a0111445317a3d88e53a8b4b6782) Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'autofill-parser/src')
-rw-r--r--autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt23
1 files changed, 20 insertions, 3 deletions
diff --git a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt
index a8ed0c85..9df5aca7 100644
--- a/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt
+++ b/autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt
@@ -9,6 +9,8 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
+import android.provider.Settings
+import android.service.autofill.SaveInfo
import androidx.annotation.RequiresApi
/*
@@ -143,7 +145,21 @@ private val BROWSER_SAVE_FLAG = mapOf(
)
@RequiresApi(Build.VERSION_CODES.O)
-private fun getBrowserSaveFlag(appPackage: String): Int? = BROWSER_SAVE_FLAG[appPackage]
+private val BROWSER_SAVE_FLAG_IF_NO_ACCESSIBILITY = mapOf(
+ "com.chrome.canary" to SaveInfo.FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE,
+)
+
+private fun isNoAccessibilityServiceEnabled(context: Context): Boolean {
+ // See https://chromium.googlesource.com/chromium/src/+/447a31e977a65e2eb78804e4a09633699b4ede33
+ return Settings.Secure.getString(context.contentResolver,
+ Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES).isNullOrEmpty()
+}
+
+@RequiresApi(Build.VERSION_CODES.O)
+private fun getBrowserSaveFlag(context: Context, appPackage: String): Int? =
+ BROWSER_SAVE_FLAG[appPackage] ?: BROWSER_SAVE_FLAG_IF_NO_ACCESSIBILITY[appPackage]?.takeIf {
+ isNoAccessibilityServiceEnabled(context)
+ }
data class BrowserAutofillSupportInfo(
val multiOriginMethod: BrowserMultiOriginMethod,
@@ -158,14 +174,13 @@ fun getBrowserAutofillSupportInfoIfTrusted(
if (!isTrustedBrowser(context, appPackage)) return null
return BrowserAutofillSupportInfo(
multiOriginMethod = getBrowserMultiOriginMethod(appPackage),
- saveFlags = getBrowserSaveFlag(appPackage)
+ saveFlags = getBrowserSaveFlag(context, appPackage)
)
}
private val FLAKY_BROWSERS = listOf(
"com.android.chrome",
"com.chrome.beta",
- "com.chrome.canary",
"com.chrome.dev",
"org.bromite.bromite",
"org.ungoogled.chromium.stable",
@@ -176,6 +191,7 @@ enum class BrowserAutofillSupportLevel {
None,
FlakyFill,
PasswordFill,
+ PasswordFillAndSaveIfNoAccessibility,
GeneralFill,
GeneralFillAndSave,
}
@@ -189,6 +205,7 @@ private fun getBrowserAutofillSupportLevel(
return when {
browserInfo == null -> BrowserAutofillSupportLevel.None
appPackage in FLAKY_BROWSERS -> BrowserAutofillSupportLevel.FlakyFill
+ appPackage in BROWSER_SAVE_FLAG_IF_NO_ACCESSIBILITY -> BrowserAutofillSupportLevel.PasswordFillAndSaveIfNoAccessibility
browserInfo.multiOriginMethod == BrowserMultiOriginMethod.None -> BrowserAutofillSupportLevel.PasswordFill
browserInfo.saveFlags == null -> BrowserAutofillSupportLevel.GeneralFill
else -> BrowserAutofillSupportLevel.GeneralFillAndSave