From 8c25415736466323f8b2493845c320155bcc471b Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 25 Apr 2022 21:27:03 +0000 Subject: [PATCH] MainClear: remove obsolete check for multi-volume FDE It is never the case that '!isExternalStorageEmulated() && !isExternalStorageRemovable() && isExtStorageEncrypted()', so stop checking for this. It's easy to see that even just the last part, isExtStorageEncrypted(), is never true, since it checks whether the property "vold.decrypt" is non-empty. That system property was only set on devices that used FDE (Full Disk Encryption), and FDE support was removed in Android T. Moreover, the full condition of '!emulated && !removable && FDE' actually checked for devices that used multi-volume FDE, which apparently was never actually used, and was removed 8 years ago by vold commit 87999173dd79 (http://ag/423222). This is consistent with the fact that this code was added 11 years ago by commit 2a32192329ac (http://ag/134210), when probably this feature was still planned. Bug: 208476087 Change-Id: I4c2b5c9aed8812367a70d0dd1bbcc94008fec529 --- src/com/android/settings/MainClear.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/com/android/settings/MainClear.java b/src/com/android/settings/MainClear.java index 62462b3492a..1e8b47b4cb1 100644 --- a/src/com/android/settings/MainClear.java +++ b/src/com/android/settings/MainClear.java @@ -44,7 +44,6 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; -import android.sysprop.VoldProperties; import android.telephony.euicc.EuiccManager; import android.text.TextUtils; import android.util.Log; @@ -309,12 +308,9 @@ public class MainClear extends InstrumentedFragment implements OnGlobalLayoutLis * If the external storage is emulated, it will be erased with a factory * reset at any rate. There is no need to have a separate option until * we have a factory reset that only erases some directories and not - * others. Likewise, if it's non-removable storage, it could potentially have been - * encrypted, and will also need to be wiped. + * others. */ - boolean isExtStorageEmulated = Environment.isExternalStorageEmulated(); - if (isExtStorageEmulated - || (!Environment.isExternalStorageRemovable() && isExtStorageEncrypted())) { + if (Environment.isExternalStorageEmulated()) { mExternalStorageContainer.setVisibility(View.GONE); final View externalOption = mContentView.findViewById(R.id.erase_external_option_text); @@ -323,9 +319,7 @@ public class MainClear extends InstrumentedFragment implements OnGlobalLayoutLis final View externalAlsoErased = mContentView.findViewById(R.id.also_erases_external); externalAlsoErased.setVisibility(View.VISIBLE); - // If it's not emulated, it is on a separate partition but it means we're doing - // a force wipe due to encryption. - mExternalStorage.setChecked(!isExtStorageEmulated); + mExternalStorage.setChecked(false); } else { mExternalStorageContainer.setOnClickListener(new View.OnClickListener() { @@ -457,11 +451,6 @@ public class MainClear extends InstrumentedFragment implements OnGlobalLayoutLis } } - private boolean isExtStorageEncrypted() { - String state = VoldProperties.decrypt().orElse(""); - return !"".equals(state); - } - private void loadAccountList(final UserManager um) { View accountsLabel = mContentView.findViewById(R.id.accounts_label); LinearLayout contents = (LinearLayout) mContentView.findViewById(R.id.accounts);