From 5a94d2ccc252d128880f2c4ea1eb5f252e256767 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 27 Jul 2022 19:47:57 +0000 Subject: [PATCH] UserCredentialsSettings: remove unneeded checks for locksettings keys Since Android 12 (frameworks/base change Iac339e64812232875afa9dc6109b848b50b0ef2f), the locksettings keys are in their own key namespace. Therefore, they are no longer included when UserCredentialsSettings enumerates the keys in the app namespace, so there is no longer any need to explicitly ignore these keys. This is a cleanup that is a prerequisite for a cleanup in locksettings where LockPatternUtils.SYNTHETIC_PASSWORD_KEY_PREFIX will be renamed and have its visibility reduced. No change in behavior intended. Test: Added temporary logging of all key aliases enumerated by keyStore.aliases() in getCredentialsForUid(). Set an LSKF, and went to the User Credentials page in the Settings app. Verified via logcat that the locksettings keys aren't being enumerated. Change-Id: If9040b55a5743c9b0e174538f67c669e864f0312 --- .../android/settings/UserCredentialsSettings.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/com/android/settings/UserCredentialsSettings.java b/src/com/android/settings/UserCredentialsSettings.java index 80b97e4272a..c45b5efb860 100644 --- a/src/com/android/settings/UserCredentialsSettings.java +++ b/src/com/android/settings/UserCredentialsSettings.java @@ -48,7 +48,6 @@ import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; -import com.android.internal.widget.LockPatternUtils; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; @@ -297,7 +296,6 @@ public class UserCredentialsSettings extends SettingsPreferenceFragment private SortedMap getCredentialsForUid(KeyStore keyStore, int uid) { try { final SortedMap aliasMap = new TreeMap<>(); - boolean isSystem = UserHandle.getAppId(uid) == Process.SYSTEM_UID; Enumeration aliases = keyStore.aliases(); while (aliases.hasMoreElements()) { String alias = aliases.nextElement(); @@ -315,19 +313,6 @@ public class UserCredentialsSettings extends SettingsPreferenceFragment // We don't display any symmetric key entries. continue; } - if (isSystem) { - // Do not show work profile keys in user credentials - if (alias.startsWith(LockPatternUtils.PROFILE_KEY_NAME_ENCRYPT) || - alias.startsWith(LockPatternUtils.PROFILE_KEY_NAME_DECRYPT)) { - continue; - } - // Do not show synthetic password keys in user credential - // We should never reach this point because the synthetic password key - // is symmetric. - if (alias.startsWith(LockPatternUtils.SYNTHETIC_PASSWORD_KEY_PREFIX)) { - continue; - } - } // At this point we have determined that we have an asymmetric key. // so we have at least a USER_KEY and USER_CERTIFICATE. c.storedTypes.add(Credential.Type.USER_KEY);