Check if Android file system is encrypted

We are developing a secure Android application. This is necessary so that users keep the file systems of their devices encrypted, but we must verify this fact and prohibit the use of the application. Can I check if the file system is encrypted? There are also some devices with Android <3.0 that supports encryption, for example Motorola RAZR. It would be interesting to learn about encryption on such devices.

+6
source share
3 answers

If your application is registered as a device administrator , you can call getStorageEncryptionStatus() on the DevicePolicyManager to find out the device encryption status for API level 11 and above.

For any encryption of the entire device at lower API levels, contact the device manufacturer.

+8
source

To clarify CommonsWare's answer, you can read the encryption status of the device without any Android permissions.

  /** * Returns the encryption status of the device. Prior to Honeycomb, whole device encryption was * not supported by Android, and this method returns ENCRYPTION_STATUS_UNSUPPORTED. * * @return One of the following constants from DevicePolicyManager: * ENCRYPTION_STATUS_UNSUPPORTED, ENCRYPTION_STATUS_INACTIVE, * ENCRYPTION_STATUS_ACTIVATING, or ENCRYPTION_STATUS_ACTIVE. */ @TargetApi(11) private int getDeviceEncryptionStatus() { int status = DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED; if (Build.VERSION.SDK_INT >= 11) { final DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); if (dpm != null) { status = dpm.getStorageEncryptionStatus(); } } return status; } 
+12
source

to clarify previous answers to API <23 getStorageEncryptionStatus() returns ENCRYPTION_STATUS_INACTIVE when the device is encrypted but the password is not turned on.

In API> = 23, it returns ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY in this case.

+4
source

Source: https://habr.com/ru/post/926513/


All Articles