How to check if “verify app” is enabled or disabled programmatically

旧巷老猫 提交于 2019-12-21 23:10:29

问题


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.

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.


回答1:


You should check like this:

Settings.Global.getInt(context.getContentResolver(), "verifier_verify_adb_installs", -1);



回答2:


Reading preferences value for google Verify won't work. 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) {
---
}
});


来源:https://stackoverflow.com/questions/42132239/how-to-check-if-verify-app-is-enabled-or-disabled-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!