Fix for TestDirectBootEmulated testcase

In case of emulated FBE the secrets are empty hence add this
exception to prevent from unlocking userkey.

Bug: 177617301
Test: android.appsecurity.cts.DirectBootHostTest#testDirectBootEmulated

Change-Id: I5be2ceb61d9ef47219862e75cc8ec03ab5513426
This commit is contained in:
N Harish
2021-01-25 17:22:33 +05:30
committed by Anish Khan
parent 7166f0b425
commit 2912b101aa

View File

@@ -3297,6 +3297,12 @@ class StorageManagerService extends IStorageManager.Stub
enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);
if (isFsEncrypted) {
// When a user has secure lock screen, require secret to actually unlock.
// This check is mostly in place for emulation mode.
if (StorageManager.isFileEncryptedEmulatedOnly() &&
mLockPatternUtils.isSecure(userId) && ArrayUtils.isEmpty(secret)) {
throw new IllegalStateException("Secret required to unlock secure user " + userId);
}
try {
mVold.unlockUserKey(userId, serialNumber, encodeBytes(token),
encodeBytes(secret));