如何检查“验证应用程序"是否有效以编程方式启用或禁用 [英] How to check if "verify app" is enabled or disabled programmatically

查看:49
本文介绍了如何检查“验证应用程序"是否有效以编程方式启用或禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果谷歌的验证应用"在应用启动时被禁用,我有一个安全要求来提醒用户.问题是我不知道有什么方法可以检查验证应用程序"是否被禁用.

I've a security requirement to alert users if google's "verify app" is disabled on app launch. The problem is that I dont know any way to check whether "verify app" is disabled or not.

我尝试使用下面的代码,但它总是返回 1.

I tried to use the code below, but it's always returning 1.

        int verifierInt = -1;
        if (Build.VERSION.SDK_INT >= 17) {
            verifierInt = Settings.Global.getInt(context.getContentResolver(), "package_verifier_enable", -1);
        } else if (Build.VERSION.SDK_INT >= 14) {
            verifierInt = Settings.Secure.getInt(context.getContentResolver(), "verifier_enable", -1);
        } else {
            // No package verification option before API Level 14
        }
        boolean isVerifyAppEnabled = verifierInt == 1;

此外,作为一项要求,如果此功能被禁用,希望用户被导航到验证应用"设置.

Also, as a requirement, want user to be navigated to the "verifiy app" settings if this feature is disabled.

推荐答案

阅读首选项,不再有用,因为 android 现在不更新首选项.所以基本上阅读谷歌验证的首选项值是行不通的.

Reading preferences, won't help anymore as android don't update preferences now. So basically reading preferences value for google Verify won't work.

请使用以下 SaftyNet 回调来验证谷歌保护.

Please use below SaftyNet callbacks to verify google protect.

SafetyNet.getClient(context)
                .isVerifyAppsEnabled()
                .addOnCompleteListener(new OnCompleteListener<SafetyNetApi.VerifyAppsUserResponse>() {
                    @Override
                    public void onComplete(@NonNull Task<SafetyNetApi.VerifyAppsUserResponse> task) {
---
}
});

这篇关于如何检查“验证应用程序"是否有效以编程方式启用或禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆