IT袋

当前位置:主页 > 经验教程 > 手机教程 >

安卓11怎么解除文件访问限制

安卓11怎么解除文件访问限制 小米安卓11解除data权限(3)

时间:2023-09-14 12:10:41 来源:IT袋 作者:苏晓敏
导读:安卓11怎么解除文件访问限制,如需定义您的应用接受的生物识别身份验证类型,请向 setAllowedAuthenticators() 方法传递一个身份验证类型或按位类型组合。例如,如果您的应用接受“强”

安卓11怎么解除文件访问限制

如需定义您的应用接受的生物识别身份验证类型,请向 setAllowedAuthenticators() 方法传递一个身份验证类型或按位类型组合。例如,如果您的应用接受“强”硬件元素或屏幕锁定凭据,请传入 BIOMETRIC_STRONG | DEVICE_CREDENTIAL。

如需检查是否有必要的身份验证元素,请将同一按位类型组合传入 canAuthenticate() 方法。如有必要,请调用 ACTION_BIOMETRIC_ENROLL intent 操作。在 intent extra 中,提供您的应用可接受的一组身份验证器。该 intent 会提示用户为您的应用接受的身份验证器注册凭据。

注意:为了注册身份验证器,用户需要创建 PIN 码、解锁图案或密码。如果用户还没有 PIN 码、解锁图案或密码,生物识别注册流程会提示他们创建一个。

在用户进行身份验证后,您可以通过调用 getAuthenticationType() 检查用户是使用设备凭据还是生物识别凭据进行的身份验证。

对“每次使用时进行身份验证”密钥的额外支持

Android 11 在 BiometricPrompt 类中提供了对“每次使用时进行身份验证”密钥的更多支持。此类密钥要求每次您的应用需要访问受该密钥保护的数据时,用户都必须提供生物识别凭据、设备凭据或上述任一凭据。“每次使用时进行身份验证”密钥对高价值的事务(如支付大笔款项或更新个人的健康档案)很有用。

如需将 BiometricPrompt 对象与“每次使用时进行身份验证”密钥相关联,请添加类似以下的代码:

KOTLIN

<pre spellcheck="false" lang="java" cid="n465" mdtype="fences">KeyGenParameterSpec authPerOpKeyGenParameterSpec = new KeyGenParameterSpec.Builder("myKeystoreAlias", key-purpose) // Accept either a biometric credential or a device credential. // To accept only one type of credential, include only that type as the // 2nd argument. .setUserAuthenticationParameters(0 /* duration */, KeyProperties.AUTH_BIOMETRIC_STRONG | KeyProperties.AUTH_DEVICE_CREDENTIAL) .build();</pre>

JAVA

<pre spellcheck="false" lang="java" cid="n467" mdtype="fences">KeyGenParameterSpec authPerOpKeyGenParameterSpec = new KeyGenParameterSpec.Builder("myKeystoreAlias", key-purpose) // Accept either a biometric credential or a device credential. // To accept only one type of credential, include only that type as the // 2nd argument. .setUserAuthenticationParameters(0 /* duration */, KeyProperties.AUTH_BIOMETRIC_STRONG | KeyProperties.AUTH_DEVICE_CREDENTIAL) .build();</pre>

已弃用的方法

Android 11 弃用了以下方法:

setDeviceCredentialAllowed() 方法。setUserAuthenticationValidityDurationSeconds() 方法。不带任何参数的 canAuthenticate() 过载版本。

安全共享大型数据集

在某些情况下,例如涉及机器学习或媒体播放时,您的应用可能需要与其他应用使用同一个大型数据集。在较早的 Android 版本中,您的应用与其他应用需要各自单独下载该数据集。

相关阅读