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
This commit is contained in:
Eric Biggers
2022-06-10 17:29:31 +00:00
parent b16b5b5476
commit ff16ec8542
8 changed files with 20 additions and 20 deletions

View File

@@ -131,7 +131,7 @@ public class BiometricUtils {
if (WizardManagerHelper.isAnySetupWizard(activityIntent)) { if (WizardManagerHelper.isAnySetupWizard(activityIntent)) {
// Default to PIN lock in setup wizard // Default to PIN lock in setup wizard
Intent intent = new Intent(context, SetupChooseLockGeneric.class); Intent intent = new Intent(context, SetupChooseLockGeneric.class);
if (StorageManager.isFileEncryptedNativeOrEmulated()) { if (StorageManager.isFileEncrypted()) {
intent.putExtra( intent.putExtra(
LockPatternUtils.PASSWORD_TYPE_KEY, LockPatternUtils.PASSWORD_TYPE_KEY,
DevicePolicyManager.PASSWORD_QUALITY_NUMERIC); DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);

View File

@@ -97,7 +97,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
@Override @Override
public void onNavigateNext(View view) { public void onNavigateNext(View view) {
// Ensure that all users are unlocked so that we can move their data // 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()) { for (UserInfo user : getSystemService(UserManager.class).getUsers()) {
if (!StorageManager.isUserKeyUnlocked(user.id)) { if (!StorageManager.isUserKeyUnlocked(user.id)) {
Log.d(TAG, "User " + user.id + " is currently locked; requesting unlock"); Log.d(TAG, "User " + user.id + " is currently locked; requesting unlock");

View File

@@ -79,7 +79,7 @@ public class StorageWizardMoveConfirm extends StorageWizardBase {
@Override @Override
public void onNavigateNext(View view) { public void onNavigateNext(View view) {
// Ensure that all users are unlocked so that we can move their data // 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()) { for (UserInfo user : getSystemService(UserManager.class).getUsers()) {
if (!StorageManager.isUserKeyUnlocked(user.id)) { if (!StorageManager.isUserKeyUnlocked(user.id)) {
Log.d(TAG, "User " + user.id + " is currently locked; requesting unlock"); Log.d(TAG, "User " + user.id + " is currently locked; requesting unlock");

View File

@@ -587,7 +587,7 @@ public class ChooseLockGeneric extends SettingsActivity {
void updatePreferencesOrFinish(boolean isRecreatingActivity) { void updatePreferencesOrFinish(boolean isRecreatingActivity) {
Intent intent = getActivity().getIntent(); Intent intent = getActivity().getIntent();
int quality = -1; int quality = -1;
if (StorageManager.isFileEncryptedNativeOrEmulated()) { if (StorageManager.isFileEncrypted()) {
quality = intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1); quality = intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1);
} else { } else {
// For non-file encrypted devices we need to show encryption interstitial, so always // For non-file encrypted devices we need to show encryption interstitial, so always

View File

@@ -148,7 +148,7 @@ public class ScreenLockPreferenceDetailsUtils {
// able to complete the operation due to the lack of (old) encryption key. // able to complete the operation due to the lack of (old) encryption key.
if (mProfileChallengeUserId != UserHandle.USER_NULL if (mProfileChallengeUserId != UserHandle.USER_NULL
&& !mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId) && !mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)
&& StorageManager.isFileEncryptedNativeOnly()) { && StorageManager.isFileEncrypted()) {
if (mUm.isQuietModeEnabled(UserHandle.of(mProfileChallengeUserId))) { if (mUm.isQuietModeEnabled(UserHandle.of(mProfileChallengeUserId))) {
return UnlaunchableAppActivity.createInQuietModeDialogIntent( return UnlaunchableAppActivity.createInQuietModeDialogIntent(
mProfileChallengeUserId); mProfileChallengeUserId);

View File

@@ -247,7 +247,7 @@ public class SetupFingerprintEnrollIntroductionTest {
@Test @Test
@Ignore @Ignore
public void testLockPattern() { public void testLockPattern() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); ShadowStorageManager.setIsFileEncrypted(false);
mController.create().postCreate(null).resume(); mController.create().postCreate(null).resume();

View File

@@ -146,7 +146,7 @@ public class ChooseLockGenericTest {
@Test @Test
public void updatePreferencesOrFinish_passwordTypeSetPinNotFbe_shouldNotStartChooseLock() { public void updatePreferencesOrFinish_passwordTypeSetPinNotFbe_shouldNotStartChooseLock() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); ShadowStorageManager.setIsFileEncrypted(false);
Intent intent = new Intent().putExtra( Intent intent = new Intent().putExtra(
LockPatternUtils.PASSWORD_TYPE_KEY, LockPatternUtils.PASSWORD_TYPE_KEY,
DevicePolicyManager.PASSWORD_QUALITY_NUMERIC); DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
@@ -159,7 +159,7 @@ public class ChooseLockGenericTest {
@Test @Test
public void updatePreferencesOrFinish_footerPreferenceAddedHighComplexityText() { public void updatePreferencesOrFinish_footerPreferenceAddedHighComplexityText() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); ShadowStorageManager.setIsFileEncrypted(false);
Intent intent = new Intent() Intent intent = new Intent()
.putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name")
.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_HIGH); .putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_HIGH);
@@ -175,7 +175,7 @@ public class ChooseLockGenericTest {
@Test @Test
public void updatePreferencesOrFinish_footerPreferenceAddedMediumComplexityText() { public void updatePreferencesOrFinish_footerPreferenceAddedMediumComplexityText() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); ShadowStorageManager.setIsFileEncrypted(false);
Intent intent = new Intent() Intent intent = new Intent()
.putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name")
.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_MEDIUM); .putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_MEDIUM);
@@ -191,7 +191,7 @@ public class ChooseLockGenericTest {
@Test @Test
public void updatePreferencesOrFinish_footerPreferenceAddedLowComplexityText() { public void updatePreferencesOrFinish_footerPreferenceAddedLowComplexityText() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); ShadowStorageManager.setIsFileEncrypted(false);
Intent intent = new Intent() Intent intent = new Intent()
.putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name")
.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_LOW); .putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_LOW);
@@ -207,7 +207,7 @@ public class ChooseLockGenericTest {
@Test @Test
public void updatePreferencesOrFinish_footerPreferenceAddedNoneComplexityText() { public void updatePreferencesOrFinish_footerPreferenceAddedNoneComplexityText() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); ShadowStorageManager.setIsFileEncrypted(false);
Intent intent = new Intent() Intent intent = new Intent()
.putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name")
.putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_NONE); .putExtra(EXTRA_KEY_REQUESTED_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_NONE);
@@ -389,7 +389,7 @@ public class ChooseLockGenericTest {
@Test @Test
public void updatePreferencesOrFinish_ComplexityIsReadFromDPM() { public void updatePreferencesOrFinish_ComplexityIsReadFromDPM() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); ShadowStorageManager.setIsFileEncrypted(false);
ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_HIGH); ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_HIGH);
initActivity(null); initActivity(null);
@@ -405,7 +405,7 @@ public class ChooseLockGenericTest {
@Test @Test
public void updatePreferencesOrFinish_ComplexityIsMergedWithDPM() { public void updatePreferencesOrFinish_ComplexityIsMergedWithDPM() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); ShadowStorageManager.setIsFileEncrypted(false);
ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_HIGH); ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_HIGH);
Intent intent = new Intent() Intent intent = new Intent()
.putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name")
@@ -425,7 +425,7 @@ public class ChooseLockGenericTest {
@Test @Test
public void updatePreferencesOrFinish_ComplexityIsMergedWithDPM_AppIsHigher() { public void updatePreferencesOrFinish_ComplexityIsMergedWithDPM_AppIsHigher() {
ShadowStorageManager.setIsFileEncryptedNativeOrEmulated(false); ShadowStorageManager.setIsFileEncrypted(false);
ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_LOW); ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_LOW);
Intent intent = new Intent() Intent intent = new Intent()
.putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name") .putExtra(EXTRA_KEY_CALLER_APP_NAME, "app name")

View File

@@ -30,7 +30,7 @@ public class ShadowStorageManager {
private static boolean sIsUnmountCalled; private static boolean sIsUnmountCalled;
private static boolean sIsForgetCalled; private static boolean sIsForgetCalled;
private static boolean sIsFileEncryptedNativeOrEmulated = true; private static boolean sIsFileEncrypted = true;
public static boolean isUnmountCalled() { public static boolean isUnmountCalled() {
return sIsUnmountCalled; return sIsUnmountCalled;
@@ -44,7 +44,7 @@ public class ShadowStorageManager {
public static void reset() { public static void reset() {
sIsUnmountCalled = false; sIsUnmountCalled = false;
sIsForgetCalled = false; sIsForgetCalled = false;
sIsFileEncryptedNativeOrEmulated = true; sIsFileEncrypted = true;
} }
@Implementation @Implementation
@@ -73,12 +73,12 @@ public class ShadowStorageManager {
} }
@Implementation @Implementation
protected static boolean isFileEncryptedNativeOrEmulated() { protected static boolean isFileEncrypted() {
return sIsFileEncryptedNativeOrEmulated; return sIsFileEncrypted;
} }
public static void setIsFileEncryptedNativeOrEmulated(boolean encrypted) { public static void setIsFileEncrypted(boolean encrypted) {
sIsFileEncryptedNativeOrEmulated = encrypted; sIsFileEncrypted = encrypted;
} }
private VolumeInfo createVolumeInfo(String volumeId) { private VolumeInfo createVolumeInfo(String volumeId) {