Find out whether the device is full disk encrypted and what encryption was used?

纵然是瞬间 提交于 2019-12-04 11:21:46

As @Mikle mentions you can just call the DevicePolicyManager and ask it the status

@SuppressLint("NewApi")
    private boolean isEncrypted(Context context) {
        DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
                .getSystemService(Context.DEVICE_POLICY_SERVICE);

        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
            int status = devicePolicyManager.getStorageEncryptionStatus();
            if (DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE == status) {
                return true;
            }
        }
        return false;
    }

I think the API you're looking for is part of the Device Administration APIs. Specifically, you'll need to set up a DeviceAdminReceiver and, in the "uses-policies" section of device_admin.xml, add an "encrypted-storage" element. Then you'll be free to call setStorageEncryption to indicate what type of encryption to enforce. DeviceAdminSample.java should provide you with much of the code you'll need. This is kind of an indirect way of finding out whether the device is encrypted, but it's the only public API I know of.

This also won't tell you what kind of encryption is being used... I haven't been able to find an API for that.

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