From ff16ec8542d8009baccc1d30fa8ff6cfaf73313c Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Fri, 10 Jun 2022 17:29:31 +0000 Subject: [PATCH] Use StorageManager.isFileEncrypted() instead of deprecated methods Since emulated FBE is no longer supported, isFileEncryptedNativeOnly() and isFileEncryptedNativeOrEmulated() are the same as the new method isFileEncrypted(). Replace all calls to these deprecated methods in this repository with isFileEncrypted(). Bug: 232458753 Change-Id: I95beea86ef771396c2e08f2d6a643fdc629ad89f --- .../settings/biometrics/BiometricUtils.java | 2 +- .../deviceinfo/StorageWizardMigrateConfirm.java | 2 +- .../deviceinfo/StorageWizardMoveConfirm.java | 2 +- .../settings/password/ChooseLockGeneric.java | 2 +- .../ScreenLockPreferenceDetailsUtils.java | 2 +- .../SetupFingerprintEnrollIntroductionTest.java | 2 +- .../settings/password/ChooseLockGenericTest.java | 16 ++++++++-------- .../testutils/shadow/ShadowStorageManager.java | 12 ++++++------ 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/com/android/settings/biometrics/BiometricUtils.java b/src/com/android/settings/biometrics/BiometricUtils.java index be233ed466b..7e5a22ff051 100644 --- a/src/com/android/settings/biometrics/BiometricUtils.java +++ b/src/com/android/settings/biometrics/BiometricUtils.java @@ -131,7 +131,7 @@ public class BiometricUtils { if (WizardManagerHelper.isAnySetupWizard(activityIntent)) { // Default to PIN lock in setup wizard Intent intent = new Intent(context, SetupChooseLockGeneric.class); - if (StorageManager.isFileEncryptedNativeOrEmulated()) { + if (StorageManager.isFileEncrypted()) { intent.putExtra( LockPatternUtils.PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_NUMERIC); diff --git a/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java index 0d513e5b5fe..f65dd24ed25 100644 --- a/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java +++ b/src/com/android/settings/deviceinfo/StorageWizardMigrateConfirm.java @@ -97,7 +97,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase { @Override public void onNavigateNext(View view) { // Ensure that all users are unlocked so that we can move their data - if (StorageManager.isFileEncryptedNativeOrEmulated()) { + if (StorageManager.isFileEncrypted()) { for (UserInfo user : getSystemService(UserManager.class).getUsers()) { if (!StorageManager.isUserKeyUnlocked(user.id)) { Log.d(TAG, "User " + user.id + " is currently locked; requesting unlock"); diff --git a/src/com/android/settings/deviceinfo/StorageWizardMoveConfirm.java b/src/com/android/settings/deviceinfo/StorageWizardMoveConfirm.java index b0f8cbd5cc1..da96104589a 100644 --- a/src/com/android/settings/deviceinfo/StorageWizardMoveConfirm.java +++ b/src/com/android/settings/deviceinfo/StorageWizardMoveConfirm.java @@ -79,7 +79,7 @@ public class StorageWizardMoveConfirm extends StorageWizardBase { @Override public void onNavigateNext(View view) { // Ensure that all users are unlocked so that we can move their data - if (StorageManager.isFileEncryptedNativeOrEmulated()) { + if (StorageManager.isFileEncrypted()) { for (UserInfo user : getSystemService(UserManager.class).getUsers()) { if (!StorageManager.isUserKeyUnlocked(user.id)) { Log.d(TAG, "User " + user.id + " is currently locked; requesting unlock"); diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java index 8a4e9bb6c13..63c4a626632 100644 --- a/src/com/android/settings/password/ChooseLockGeneric.java +++ b/src/com/android/settings/password/ChooseLockGeneric.java @@ -587,7 +587,7 @@ public class ChooseLockGeneric extends SettingsActivity { void updatePreferencesOrFinish(boolean isRecreatingActivity) { Intent intent = getActivity().getIntent(); int quality = -1; - if (StorageManager.isFileEncryptedNativeOrEmulated()) { + if (StorageManager.isFileEncrypted()) { quality = intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1); } else { // For non-file encrypted devices we need to show encryption interstitial, so always diff --git a/src/com/android/settings/security/ScreenLockPreferenceDetailsUtils.java b/src/com/android/settings/security/ScreenLockPreferenceDetailsUtils.java index 19e70d9ed3f..7de26353bf9 100644 --- a/src/com/android/settings/security/ScreenLockPreferenceDetailsUtils.java +++ b/src/com/android/settings/security/ScreenLockPreferenceDetailsUtils.java @@ -148,7 +148,7 @@ public class ScreenLockPreferenceDetailsUtils { // able to complete the operation due to the lack of (old) encryption key. if (mProfileChallengeUserId != UserHandle.USER_NULL && !mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId) - && StorageManager.isFileEncryptedNativeOnly()) { + && StorageManager.isFileEncrypted()) { if (mUm.isQuietModeEnabled(UserHandle.of(mProfileChallengeUserId))) { return UnlaunchableAppActivity.createInQuietModeDialogIntent( mProfileChallengeUserId); diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java index e3b23ac293d..898e433403f 100644 --- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java +++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/SetupFingerprintEnrollIntroductionTest.java @@ -247,7 +247,7 @@ public class SetupFingerprintEnrollIntroductionTest { @Test @Ignore public void testLockPattern() { - ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); + ShadowStorageManager.setIsFileEncrypted(false); mController.create().postCreate(null).resume(); diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java index e8d437aee0c..0d26acfbbd6 100644 --- a/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java +++ b/tests/robotests/src/com/android/settings/password/ChooseLockGenericTest.java @@ -146,7 +146,7 @@ public class ChooseLockGenericTest { @Test public void updatePreferencesOrFinish_passwordTypeSetPinNotFbe_shouldNotStartChooseLock() { - ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); + ShadowStorageManager.setIsFileEncrypted(false); Intent intent = new Intent().putExtra( LockPatternUtils.PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_NUMERIC); @@ -159,7 +159,7 @@ public class ChooseLockGenericTest { @Test public void updatePreferencesOrFinish_footerPreferenceAddedHighComplexityText() { - ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); + ShadowStorageManager.setIsFileEncrypted(false); Intent intent = new Intent() .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_HIGH); @@ -175,7 +175,7 @@ public class ChooseLockGenericTest { @Test public void updatePreferencesOrFinish_footerPreferenceAddedMediumComplexityText() { - ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); + ShadowStorageManager.setIsFileEncrypted(false); Intent intent = new Intent() .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_MEDIUM); @@ -191,7 +191,7 @@ public class ChooseLockGenericTest { @Test public void updatePreferencesOrFinish_footerPreferenceAddedLowComplexityText() { - ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); + ShadowStorageManager.setIsFileEncrypted(false); Intent intent = new Intent() .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_LOW); @@ -207,7 +207,7 @@ public class ChooseLockGenericTest { @Test public void updatePreferencesOrFinish_footerPreferenceAddedNoneComplexityText() { - ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); + ShadowStorageManager.setIsFileEncrypted(false); Intent intent = new Intent() .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_NONE); @@ -389,7 +389,7 @@ public class ChooseLockGenericTest { @Test public void updatePreferencesOrFinish_ComplexityIsReadFromDPM() { - ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); + ShadowStorageManager.setIsFileEncrypted(false); ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_HIGH); initActivity(null); @@ -405,7 +405,7 @@ public class ChooseLockGenericTest { @Test public void updatePreferencesOrFinish_ComplexityIsMergedWithDPM() { - ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); + ShadowStorageManager.setIsFileEncrypted(false); ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_HIGH); Intent intent = new Intent() .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") @@ -425,7 +425,7 @@ public class ChooseLockGenericTest { @Test public void updatePreferencesOrFinish_ComplexityIsMergedWithDPM_AppIsHigher() { - ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); + ShadowStorageManager.setIsFileEncrypted(false); ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_LOW); Intent intent = new Intent() .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowStorageManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowStorageManager.java index a8185a412d8..11834b1dc7e 100644 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowStorageManager.java +++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowStorageManager.java @@ -30,7 +30,7 @@ public class ShadowStorageManager { private static boolean sIsUnmountCalled; private static boolean sIsForgetCalled; - private static boolean sIsFileEncryptedNativeOrEmulated = true; + private static boolean sIsFileEncrypted = true; public static boolean isUnmountCalled() { return sIsUnmountCalled; @@ -44,7 +44,7 @@ public class ShadowStorageManager { public static void reset() { sIsUnmountCalled = false; sIsForgetCalled = false; - sIsFileEncryptedNativeOrEmulated = true; + sIsFileEncrypted = true; } @Implementation @@ -73,12 +73,12 @@ public class ShadowStorageManager { } @Implementation - protected static boolean isFileEncryptedNativeOrEmulated() { - return sIsFileEncryptedNativeOrEmulated; + protected static boolean isFileEncrypted() { + return sIsFileEncrypted; } - public static void setIsFileEncryptedNativeOrEmulated(boolean encrypted) { - sIsFileEncryptedNativeOrEmulated = encrypted; + public static void setIsFileEncrypted(boolean encrypted) { + sIsFileEncrypted = encrypted; } private VolumeInfo createVolumeInfo(String volumeId) {