Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit fb5fe77

Browse files
fmeummsfjarvis
andcommitted
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 <[email protected]> * autofill-parser: bump snapshot version Signed-off-by: Harsh Shandilya <[email protected]> Co-authored-by: Harsh Shandilya <[email protected]> (cherry picked from commit 2e43d77) Signed-off-by: Harsh Shandilya <[email protected]>
1 parent 295af9e commit fb5fe77

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

app/src/main/java/com/zeapo/pwdstore/UserPreference.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ class UserPreference : AppCompatActivity() {
531531
BrowserAutofillSupportLevel.None -> getString(R.string.oreo_autofill_no_support)
532532
BrowserAutofillSupportLevel.FlakyFill -> getString(R.string.oreo_autofill_flaky_fill_support)
533533
BrowserAutofillSupportLevel.PasswordFill -> getString(R.string.oreo_autofill_password_fill_support)
534+
BrowserAutofillSupportLevel.PasswordFillAndSaveIfNoAccessibility -> getString(R.string.oreo_autofill_password_fill_and_conditional_save_support)
534535
BrowserAutofillSupportLevel.GeneralFill -> getString(R.string.oreo_autofill_general_fill_support)
535536
BrowserAutofillSupportLevel.GeneralFillAndSave -> getString(R.string.oreo_autofill_general_fill_and_save_support)
536537
}

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,5 +415,6 @@
415415
<string name="port">Port</string>
416416
<string name="pref_proxy_settings">HTTP(S) proxy settings</string>
417417
<string name="invalid_proxy_url">Invalid URL</string>
418+
<string name="oreo_autofill_password_fill_and_conditional_save_support">Fill and save passwords (saving requires that no accessibility services are enabled)</string>
418419

419420
</resources>

autofill-parser/api/autofill-parser.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public final class com/github/androidpasswordstore/autofillparser/BrowserAutofil
158158
public static final field GeneralFillAndSave Lcom/github/androidpasswordstore/autofillparser/BrowserAutofillSupportLevel;
159159
public static final field None Lcom/github/androidpasswordstore/autofillparser/BrowserAutofillSupportLevel;
160160
public static final field PasswordFill Lcom/github/androidpasswordstore/autofillparser/BrowserAutofillSupportLevel;
161+
public static final field PasswordFillAndSaveIfNoAccessibility Lcom/github/androidpasswordstore/autofillparser/BrowserAutofillSupportLevel;
161162
public static fun valueOf (Ljava/lang/String;)Lcom/github/androidpasswordstore/autofillparser/BrowserAutofillSupportLevel;
162163
public static fun values ()[Lcom/github/androidpasswordstore/autofillparser/BrowserAutofillSupportLevel;
163164
}

autofill-parser/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GROUP=com.github.androidpasswordstore
2-
VERSION_NAME=1.0.0
2+
VERSION_NAME=1.1.0-SNAPSHOT
33
POM_ARTIFACT_ID=autofill-parser
44
POM_ARTIFACT_DESCRIPTION=Android library for low-level parsing of Autofill structures
55

autofill-parser/src/main/java/com/github/androidpasswordstore/autofillparser/FeatureAndTrustDetection.kt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import android.content.Intent
99
import android.content.pm.PackageManager
1010
import android.net.Uri
1111
import android.os.Build
12+
import android.provider.Settings
13+
import android.service.autofill.SaveInfo
1214
import androidx.annotation.RequiresApi
1315

1416
/*
@@ -143,7 +145,21 @@ private val BROWSER_SAVE_FLAG = mapOf(
143145
)
144146

145147
@RequiresApi(Build.VERSION_CODES.O)
146-
private fun getBrowserSaveFlag(appPackage: String): Int? = BROWSER_SAVE_FLAG[appPackage]
148+
private val BROWSER_SAVE_FLAG_IF_NO_ACCESSIBILITY = mapOf(
149+
"com.chrome.canary" to SaveInfo.FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE,
150+
)
151+
152+
private fun isNoAccessibilityServiceEnabled(context: Context): Boolean {
153+
// See https://chromium.googlesource.com/chromium/src/+/447a31e977a65e2eb78804e4a09633699b4ede33
154+
return Settings.Secure.getString(context.contentResolver,
155+
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES).isNullOrEmpty()
156+
}
157+
158+
@RequiresApi(Build.VERSION_CODES.O)
159+
private fun getBrowserSaveFlag(context: Context, appPackage: String): Int? =
160+
BROWSER_SAVE_FLAG[appPackage] ?: BROWSER_SAVE_FLAG_IF_NO_ACCESSIBILITY[appPackage]?.takeIf {
161+
isNoAccessibilityServiceEnabled(context)
162+
}
147163

148164
data class BrowserAutofillSupportInfo(
149165
val multiOriginMethod: BrowserMultiOriginMethod,
@@ -158,14 +174,13 @@ fun getBrowserAutofillSupportInfoIfTrusted(
158174
if (!isTrustedBrowser(context, appPackage)) return null
159175
return BrowserAutofillSupportInfo(
160176
multiOriginMethod = getBrowserMultiOriginMethod(appPackage),
161-
saveFlags = getBrowserSaveFlag(appPackage)
177+
saveFlags = getBrowserSaveFlag(context, appPackage)
162178
)
163179
}
164180

165181
private val FLAKY_BROWSERS = listOf(
166182
"com.android.chrome",
167183
"com.chrome.beta",
168-
"com.chrome.canary",
169184
"com.chrome.dev",
170185
"org.bromite.bromite",
171186
"org.ungoogled.chromium.stable",
@@ -176,6 +191,7 @@ enum class BrowserAutofillSupportLevel {
176191
None,
177192
FlakyFill,
178193
PasswordFill,
194+
PasswordFillAndSaveIfNoAccessibility,
179195
GeneralFill,
180196
GeneralFillAndSave,
181197
}
@@ -189,6 +205,7 @@ private fun getBrowserAutofillSupportLevel(
189205
return when {
190206
browserInfo == null -> BrowserAutofillSupportLevel.None
191207
appPackage in FLAKY_BROWSERS -> BrowserAutofillSupportLevel.FlakyFill
208+
appPackage in BROWSER_SAVE_FLAG_IF_NO_ACCESSIBILITY -> BrowserAutofillSupportLevel.PasswordFillAndSaveIfNoAccessibility
192209
browserInfo.multiOriginMethod == BrowserMultiOriginMethod.None -> BrowserAutofillSupportLevel.PasswordFill
193210
browserInfo.saveFlags == null -> BrowserAutofillSupportLevel.GeneralFill
194211
else -> BrowserAutofillSupportLevel.GeneralFillAndSave

0 commit comments

Comments
 (0)