Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BiometricPrompt hints are not localized

Issue

We are changing the locale inside the app, everything works except the hints in the fingerprint dialog. Whatever language we set, we always have english hints:

  • Touch the fingerprint sensor
  • Not recognized
  • etc...

enter image description here

Environment

  • Component used: androidx.biometric.BiometricPrompt
  • Version used: 1.0.0.0-alpha04
  • Devices/Android versions reproduced on: emulator API 28

How the locale is set:

    private fun setNewLocaleAndRestart(language: String) {
        LocaleManager(this).setNewLocale(language)

        //restarting app
        val i = Intent(this, SplashScreenActivity::class.java)
        startActivity(i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK))
        finish()
        System.exit(0)
    }

class LocaleManager(val context: Context) {

    val sharedPreferenceManager = createSharedPreferenceManager(context)

    fun setLocale(): Context = updateResources()

    fun setNewLocale(language: String): Context {
        return updateResources(language)
    }


    private fun updateResources(l: String? = null): Context {

        val language = l ?: sharedPreferenceManager.language

        if (language.isBlank()) return context

        val locale = Locale(language)

        Locale.setDefault(locale)

        val res = context.resources
        val config = Configuration(res.configuration)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            config.setLocale(locale)
            return context.createConfigurationContext(config)
        } else @Suppress("DEPRECATION") {
            config.locale = locale
            res.updateConfiguration(config, res.displayMetrics)
            return context
        }

    }
}
like image 784
Anis CAMPOS Avatar asked May 08 '19 18:05

Anis CAMPOS


People also ask

What is BiometricPrompt?

BiometricPrompt.Builder. A builder that collects arguments to be shown on the system-provided biometric dialog. class. BiometricPrompt.CryptoObject. A wrapper class for the cryptographic operations supported by BiometricPrompt.

How do you do biometric authentication?

Biometric authentication methodsRetina scans identify subjects by analyzing the pattern of blood vessels at the back of their eyes. Iris recognition uses a picture of the iris to identify people. Fingerprint scanning identifies people based on their fingerprints.

Is Android biometric authentication secure?

Research conducted by F-Secure Labs revealed that 70% of the sampled mobile applications on Google Play store that have implemented biometric authentication can be easily bypassed. Additionally, 50% of these applications store sensitive data, which can be retrieved by attackers without valid biometric credentials.


1 Answers

everything works except the hints in the fingerprint dialog

All system dialogs will use the language that the user set for the device. This includes system dialogs for biometrics.

like image 152
CommonsWare Avatar answered Nov 09 '22 23:11

CommonsWare