detecting disk encryption on android

2019-08-19 05:29发布

问题:

Since Android SDK 3.0, users can choose to encrypt their entire disk which basically amounts to encrypting /data on a given device. The option is presented in the phone preferences so I assumed it would be available for read by applications. There's this DevicePolicyManager that looks like it has the information but am I to understand that an app must implement a receiver like here? This doesn't really work for me since I don't want to explicitly manage the user's device and certainly don't want them to have to agree to such a thing for them to install my application. Is there really not just some flag I can read somewhere to see if it's encrypted?

回答1:

There's this DevicePolicyManager that looks like it has the information but am I to understand that an app must implement a receiver like here?

You could try using getSystemService() to get a DevicePolicyManager, then call getStorageEncryptionStatus(), and see if it works.