How to check if “verify app” is enabled or disable

2020-07-24 03:37发布

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.

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-07-24 04:23

You should check like this:

Settings.Global.getInt(context.getContentResolver(), "verifier_verify_adb_installs", -1);
查看更多
The star\"
3楼-- · 2020-07-24 04:23

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) {
---
}
});
查看更多
登录 后发表回答