Skip to content

Commit e58ceed

Browse files
authored
Launch device auth settings differently for TCL devices (#6540)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1200930669568058/task/1210133000985922?focus=true ### Description Changes the way the system activity for setting up device auth is launched on `TCL`-manufactured devices. - Observed them behaving strangely in that they would not show the system device auth activity - In the logs, noticed them stating `no hardware available` - After investigating, concluded they are mishandling the provided flags around biometrics capabilities and not handling the `or` flag properly We don't require biometrics to be in place; only `credentials`. So for TCL devices as a workaround will provide the intent extra to indicate we only need `credentials`. ### Steps to test this PR - [x] Disable device auth and visit password management (`Overflow -> Passwords`) - [x] Tap `Set up in Settings` button - [x] Verify you see the system settings to set up pin/password/fingerprint etc... - [ ] You won't have a TCL device so will need to just QA-optional that change; i've tested it with a real device. Co-authored-by: Craig Russell <[email protected]>
1 parent b7f8432 commit e58ceed

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/ui/credential/management/viewing/AutofillManagementDisabledMode.kt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ import android.provider.Settings.ACTION_BIOMETRIC_ENROLL
2525
import android.provider.Settings.ACTION_FINGERPRINT_ENROLL
2626
import android.provider.Settings.ACTION_SECURITY_SETTINGS
2727
import android.provider.Settings.ACTION_SETTINGS
28+
import android.provider.Settings.EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED
2829
import android.view.LayoutInflater
2930
import android.view.View
3031
import android.view.ViewGroup
32+
import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL
3133
import com.duckduckgo.anvil.annotations.InjectWith
3234
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
3335
import com.duckduckgo.autofill.impl.databinding.FragmentAutofillManagementDisabledBinding
@@ -67,22 +69,29 @@ class AutofillManagementDisabledMode : DuckDuckGoFragment() {
6769

6870
@SuppressLint("InlinedApi", "DEPRECATION")
6971
private fun launchDeviceAuthEnrollment() {
72+
logcat { "Launching device authentication enrollment. Manufacturer=[${appBuildConfig.manufacturer}],sdkInt=[${appBuildConfig.sdkInt}]" }
73+
7074
when {
7175
appBuildConfig.manufacturer == "Xiaomi" -> {
7276
// Issue on Xiaomi: https://stackoverflow.com/questions/68484485/intent-action-fingerprint-enroll-on-redmi-results-in-exception
73-
SYSTEM_SETTINGS_ACTION.safeLaunchSettingsActivity(tryFallback = false)
77+
Intent(SYSTEM_SETTINGS_ACTION).safeLaunchSettingsActivity(tryFallback = false)
7478
}
7579

7680
appBuildConfig.sdkInt >= Build.VERSION_CODES.R -> {
77-
ACTION_BIOMETRIC_ENROLL.safeLaunchSettingsActivity(tryFallback = true)
81+
val intent = Intent(ACTION_BIOMETRIC_ENROLL)
82+
if (appBuildConfig.manufacturer.equals("TCL", ignoreCase = true)) {
83+
// https://app.asana.com/1/137249556945/project/1200930669568058/task/1210133000985922?focus=true
84+
intent.putExtra(EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, DEVICE_CREDENTIAL)
85+
}
86+
intent.safeLaunchSettingsActivity(tryFallback = true)
7887
}
7988

8089
appBuildConfig.sdkInt >= Build.VERSION_CODES.P -> {
81-
ACTION_FINGERPRINT_ENROLL.safeLaunchSettingsActivity(tryFallback = true)
90+
Intent(ACTION_FINGERPRINT_ENROLL).safeLaunchSettingsActivity(tryFallback = true)
8291
}
8392

8493
else -> {
85-
ACTION_SECURITY_SETTINGS.safeLaunchSettingsActivity(tryFallback = true)
94+
Intent(ACTION_SECURITY_SETTINGS).safeLaunchSettingsActivity(tryFallback = true)
8695
}
8796
}
8897

@@ -93,13 +102,13 @@ class AutofillManagementDisabledMode : DuckDuckGoFragment() {
93102
* Attempt to launch the given activity.
94103
* If it fails because the activity wasn't found, try launching the main settings activity if tryFallback=true.
95104
*/
96-
private fun String.safeLaunchSettingsActivity(tryFallback: Boolean) {
105+
private fun Intent.safeLaunchSettingsActivity(tryFallback: Boolean) {
97106
try {
98-
requireActivity().startActivity(Intent(this))
107+
requireActivity().startActivity(this)
99108
} catch (e: ActivityNotFoundException) {
100109
logcat(WARN) { "${e.asLog()}. Trying fallback? $tryFallback" }
101110
if (tryFallback) {
102-
SYSTEM_SETTINGS_ACTION.safeLaunchSettingsActivity(tryFallback = false)
111+
Intent(SYSTEM_SETTINGS_ACTION).safeLaunchSettingsActivity(tryFallback = false)
103112
}
104113
}
105114
}

0 commit comments

Comments
 (0)