We are developing secure application for Android. It's required for users to keep filesystems of their devices encrypted, but we have to check this fact and forbid to use app. Is it possible to check if filesystem is encrypted? Also there are some devices with Android < 3.0 that supports encryption, for example Motorola RAZR. It would be interesting to know about encryption on such devices.
Full-disk encryption was introduced to Android in 4.4, but Android 5.0 introduced these new features: Created fast encryption, which only encrypts used blocks on the data partition to avoid first boot taking a long time. Only ext4 and f2fs filesystems currently support fast encryption.
You can verify this by going into Settings > Security & lock screen > Encryption & credentials . It should say Encrypt phone - encrypted and it won't allow you to turn it off.
Virtually all Android devices on the market now come with encryption enabled by default. This is because Google required manufacturers to enable full-disk encryption starting with Android 6.0 Marshmallow, which debuted all the way back in 2015.
Just to clarify CommonsWare's answer, you can read the device encryption status 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, ENCRYPTION_STATUS_ACTIVE,
* ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY, ENCRYPTION_STATUS_ACTIVE_PER_USER.
*/
@TargetApi(11)
private static int getDeviceEncryptionStatus(Context context)
{
int status = DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED;
if (Build.VERSION.SDK_INT >= 11) {
final DevicePolicyManager dpm =
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
if (dpm != null) {
status = dpm.getStorageEncryptionStatus();
}
}
return status;
}
See the documentation for DevicePolicyManager and the encryption status flags.
It's also worth mentioning that Android has moved from full-disk encryption to file-based encryption to support Direct Boot, among other things. See File Based Encryption.
If your app is registered as a device admin, you can call getStorageEncryptionStatus()
on DevicePolicyManager
to find out the encryption status of the device, for API Level 11 and higher.
For any whole-device encryption on lower API levels, please contact the device manufacturer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With