From 77d147be49bbacefa92cf8a0b33b2968125ce613 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 26 Jan 2022 05:12:04 +0000 Subject: [PATCH 1/4] Stop trying to get/set fields in FDE footer Now that FDE is no longer supported, getting/setting FDE fields is always a no-op, so there is no need to do so. Bug: 208476087 Change-Id: Iab7ba8d36890daa0645b2cedf33e4bd177a86b63 (cherry picked from commit c6ce767e594a7bdbf6e9c00382bffa6b5fb689aa) Merged-In: Iab7ba8d36890daa0645b2cedf33e4bd177a86b63 --- .../internal/widget/LockPatternUtils.java | 60 +------------------ .../android/server/StorageManagerService.java | 35 ----------- .../server/wm/ActivityTaskManagerService.java | 18 ------ 3 files changed, 1 insertion(+), 112 deletions(-) diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index cd1bbb6bc6fe1..3923febe17dae 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -701,38 +701,14 @@ public class LockPatternUtils { return true; } - private void updateCryptoUserInfo(int userId) { - if (userId != UserHandle.USER_SYSTEM) { - return; - } - - final String ownerInfo = isOwnerInfoEnabled(userId) ? getOwnerInfo(userId) : ""; - - IBinder service = ServiceManager.getService("mount"); - if (service == null) { - Log.e(TAG, "Could not find the mount service to update the user info"); - return; - } - - IStorageManager storageManager = IStorageManager.Stub.asInterface(service); - try { - Log.d(TAG, "Setting owner info"); - storageManager.setField(StorageManager.OWNER_INFO_KEY, ownerInfo); - } catch (RemoteException e) { - Log.e(TAG, "Error changing user info", e); - } - } - @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public void setOwnerInfo(String info, int userId) { setString(LOCK_SCREEN_OWNER_INFO, info, userId); - updateCryptoUserInfo(userId); } @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public void setOwnerInfoEnabled(boolean enabled, int userId) { setBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, enabled, userId); - updateCryptoUserInfo(userId); } @UnsupportedAppUsage @@ -988,24 +964,6 @@ public class LockPatternUtils { */ public void setVisiblePatternEnabled(boolean enabled, int userId) { setBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, enabled, userId); - - // Update for crypto if owner - if (userId != UserHandle.USER_SYSTEM) { - return; - } - - IBinder service = ServiceManager.getService("mount"); - if (service == null) { - Log.e(TAG, "Could not find the mount service to update the user info"); - return; - } - - IStorageManager storageManager = IStorageManager.Stub.asInterface(service); - try { - storageManager.setField(StorageManager.PATTERN_VISIBLE_KEY, enabled ? "1" : "0"); - } catch (RemoteException e) { - Log.e(TAG, "Error changing pattern visible state", e); - } } public boolean isVisiblePatternEverChosen(int userId) { @@ -1016,23 +974,7 @@ public class LockPatternUtils { * Set whether the visible password is enabled for cryptkeeper screen. */ public void setVisiblePasswordEnabled(boolean enabled, int userId) { - // Update for crypto if owner - if (userId != UserHandle.USER_SYSTEM) { - return; - } - - IBinder service = ServiceManager.getService("mount"); - if (service == null) { - Log.e(TAG, "Could not find the mount service to update the user info"); - return; - } - - IStorageManager storageManager = IStorageManager.Stub.asInterface(service); - try { - storageManager.setField(StorageManager.PASSWORD_VISIBLE_KEY, enabled ? "1" : "0"); - } catch (RemoteException e) { - Log.e(TAG, "Error changing password visible state", e); - } + // No longer does anything. } /** diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index 9266bb431aa58..8a83130f50fa1 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -75,7 +75,6 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.ProviderInfo; import android.content.pm.UserInfo; -import android.content.res.Configuration; import android.content.res.ObbInfo; import android.database.ContentObserver; import android.net.Uri; @@ -122,7 +121,6 @@ import android.provider.DocumentsContract; import android.provider.Downloads; import android.provider.MediaStore; import android.provider.Settings; -import android.sysprop.VoldProperties; import android.text.TextUtils; import android.text.format.DateUtils; import android.util.ArrayMap; @@ -1380,39 +1378,6 @@ class StorageManagerService extends IStorageManager.Stub private void handleDaemonConnected() { initIfBootedAndConnected(); resetIfBootedAndConnected(); - - // On an encrypted device we can't see system properties yet, so pull - // the system locale out of the mount service. - if ("".equals(VoldProperties.encrypt_progress().orElse(""))) { - copyLocaleFromMountService(); - } - } - - private void copyLocaleFromMountService() { - String systemLocale; - try { - systemLocale = getField(StorageManager.SYSTEM_LOCALE_KEY); - } catch (RemoteException e) { - return; - } - if (TextUtils.isEmpty(systemLocale)) { - return; - } - - Slog.d(TAG, "Got locale " + systemLocale + " from mount service"); - Locale locale = Locale.forLanguageTag(systemLocale); - Configuration config = new Configuration(); - config.setLocale(locale); - try { - ActivityManager.getService().updatePersistentConfigurationWithAttribution(config, - mContext.getOpPackageName(), mContext.getAttributionTag()); - } catch (RemoteException e) { - Slog.e(TAG, "Error setting system locale from mount service", e); - } - - // Temporary workaround for http://b/17945169. - Slog.d(TAG, "Setting system properties to " + systemLocale + " from mount service"); - SystemProperties.set("persist.sys.locale", locale.toLanguageTag()); } private final IVoldListener mListener = new IVoldListener.Stub() { diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index c8227d9530093..dde52c5e33fb2 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -203,8 +203,6 @@ import android.os.UpdateLock; import android.os.UserHandle; import android.os.UserManager; import android.os.WorkSource; -import android.os.storage.IStorageManager; -import android.os.storage.StorageManager; import android.provider.Settings; import android.service.dreams.DreamActivity; import android.service.voice.IVoiceInteractionSession; @@ -4209,11 +4207,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { SystemProperties.set("persist.sys.locale", locales.get(bestLocaleIndex).toLanguageTag()); LocaleList.setDefault(locales, bestLocaleIndex); - - final Message m = PooledLambda.obtainMessage( - ActivityTaskManagerService::sendLocaleToMountDaemonMsg, this, - locales.get(bestLocaleIndex)); - mH.sendMessage(m); } mTempConfig.seq = increaseConfigurationSeqLocked(); @@ -4367,17 +4360,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { Settings.System.putConfigurationForUser(resolver, config, userId); } - private void sendLocaleToMountDaemonMsg(Locale l) { - try { - IBinder service = ServiceManager.getService("mount"); - IStorageManager storageManager = IStorageManager.Stub.asInterface(service); - Log.d(TAG, "Storing locale " + l.toLanguageTag() + " for decryption UI"); - storageManager.setField(StorageManager.SYSTEM_LOCALE_KEY, l.toLanguageTag()); - } catch (RemoteException e) { - Log.e(TAG, "Error storing locale for decryption UI", e); - } - } - private void expireStartAsCallerTokenMsg(IBinder permissionToken) { mStartActivitySources.remove(permissionToken); mExpiredStartAsCallerTokens.add(permissionToken); From 0a9389d296636a3c8322381ff859b3527753bcc2 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 26 Jan 2022 05:19:25 +0000 Subject: [PATCH 2/4] Remove clearEncryptionPassword() from LockPatternUtils Remove this method which cleared the FDE password, since is no longer used. It was only being used by the accessibility settings in the Settings app, and that caller was removed by http://ag/16624515. Bug: 208476087 Change-Id: If0c75774555d3503f21857e66cce527c5edfa586 (cherry picked from commit 8e265a9fd375625f7585a5deae6f0544624cbabb) Merged-In: If0c75774555d3503f21857e66cce527c5edfa586 --- .../com/android/internal/widget/LockPatternUtils.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 3923febe17dae..408decc9ca569 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -762,17 +762,6 @@ public class LockPatternUtils { return StorageManager.isFileEncryptedNativeOrEmulated(); } - /** - * Clears the encryption password. - */ - public void clearEncryptionPassword() { - try { - getLockSettings().updateEncryptionPassword(StorageManager.CRYPT_TYPE_DEFAULT, null); - } catch (RemoteException e) { - Log.e(TAG, "Couldn't clear encryption password"); - } - } - /** * Retrieves the quality mode for {@code userHandle}. * @see DevicePolicyManager#getPasswordQuality(android.content.ComponentName) From d63d0e12cc6db7e2f2bb84edb794254b6b94f58e Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 26 Jan 2022 05:22:38 +0000 Subject: [PATCH 3/4] Stop trying to update FDE password from LockSettingsService Since FDE is no longer supported, updating the FDE password never does anything. Stop trying to do so. Remove updateEncryptionPassword() from ILockSettings, since its only caller outside of LockSettingsService itself was in LockPatternUtils, and the previous CL removed that caller. Bug: 208476087 Change-Id: I46c2a472177836f0c9084e4c3b4ed2e6c0ab61d5 (cherry picked from commit 3762ada110e11b051badb6ff2f4109083721d627) Merged-In: I46c2a472177836f0c9084e4c3b4ed2e6c0ab61d5 --- .../internal/widget/ILockSettings.aidl | 1 - .../locksettings/LockSettingsService.java | 53 ++----------------- 2 files changed, 4 insertions(+), 50 deletions(-) diff --git a/core/java/com/android/internal/widget/ILockSettings.aidl b/core/java/com/android/internal/widget/ILockSettings.aidl index d16d9c6194038..654b46164dcf9 100644 --- a/core/java/com/android/internal/widget/ILockSettings.aidl +++ b/core/java/com/android/internal/widget/ILockSettings.aidl @@ -95,5 +95,4 @@ interface ILockSettings { boolean hasSecureLockScreen(); boolean tryUnlockWithCachedUnifiedChallenge(int userId); void removeCachedUnifiedChallenge(int userId); - void updateEncryptionPassword(int type, in byte[] password); } diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index 7d5b7e535ca93..45f85edeff7e6 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -1761,7 +1761,10 @@ public class LockSettingsService extends ILockSettings.Stub { } private void onPostPasswordChanged(LockscreenCredential newCredential, int userHandle) { - updateEncryptionPasswordIfNeeded(newCredential, userHandle); + if (userHandle == UserHandle.USER_SYSTEM && isDeviceEncryptionEnabled() && + shouldEncryptWithCredentials() && newCredential.isNone()) { + setCredentialRequiredToDecrypt(false); + } if (newCredential.isPattern()) { setBoolean(LockPatternUtils.PATTERN_EVER_CHOSEN_KEY, true, userHandle); } @@ -1769,26 +1772,6 @@ public class LockSettingsService extends ILockSettings.Stub { mContext.getSystemService(TrustManager.class).reportEnabledTrustAgentsChanged(userHandle); } - /** - * Update device encryption password if calling user is USER_SYSTEM and device supports - * encryption. - */ - private void updateEncryptionPasswordIfNeeded(LockscreenCredential credential, int userHandle) { - // Update the device encryption password. - if (userHandle != UserHandle.USER_SYSTEM || !isDeviceEncryptionEnabled()) { - return; - } - if (!shouldEncryptWithCredentials()) { - updateEncryptionPassword(StorageManager.CRYPT_TYPE_DEFAULT, null); - return; - } - if (credential.isNone()) { - // Set the encryption password to default. - setCredentialRequiredToDecrypt(false); - } - updateEncryptionPassword(credential.getStorageCryptType(), credential.getCredential()); - } - /** * Store the hash of the *current* password in the password history list, if device policy * enforces password history requirement. @@ -1883,34 +1866,6 @@ public class LockSettingsService extends ILockSettings.Stub { } } - /** Update the encryption password if it is enabled **/ - @Override - public void updateEncryptionPassword(final int type, final byte[] password) { - if (!hasSecureLockScreen() && password != null && password.length != 0) { - throw new UnsupportedOperationException( - "This operation requires the lock screen feature."); - } - if (!isDeviceEncryptionEnabled()) { - return; - } - final IBinder service = ServiceManager.getService("mount"); - if (service == null) { - Slog.e(TAG, "Could not find the mount service to update the encryption password"); - return; - } - - // TODO(b/120484642): This is a location where we still use a String for vold - String passwordString = password != null ? new String(password) : null; - mHandler.post(() -> { - IStorageManager storageManager = mInjector.getStorageManager(); - try { - storageManager.changeEncryptionPassword(type, passwordString); - } catch (RemoteException e) { - Slog.e(TAG, "Error changing encryption password", e); - } - }); - } - @VisibleForTesting /** Note: this method is overridden in unit tests */ protected void tieProfileLockToParent(int userId, LockscreenCredential password) { if (DEBUG) Slog.v(TAG, "tieProfileLockToParent for user: " + userId); From 25bf2f8ae04daebe92ccf255da1c156e9ba7c2ea Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 26 Jan 2022 05:04:06 +0000 Subject: [PATCH 4/4] Stub out some FDE methods in StorageManager Now that FDE is no longer supported, stub out some methods in StorageManager that return FDE state. This allows StorageManager.getPasswordType() to be removed, and it prepares for removing these methods later. Bug: 208476087 Change-Id: Ib5bcfb6a0279150fec33f2c3edd0431b450c90f4 (cherry picked from commit 401bf8a176492297a695596c0df6aa3fb2a82d5e) Merged-In: Ib5bcfb6a0279150fec33f2c3edd0431b450c90f4 --- .../android/os/storage/StorageManager.java | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java index 39f87d5580982..db724d2de30bd 100644 --- a/core/java/android/os/storage/StorageManager.java +++ b/core/java/android/os/storage/StorageManager.java @@ -82,7 +82,6 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.provider.MediaStore; import android.provider.Settings; -import android.sysprop.VoldProperties; import android.system.ErrnoException; import android.system.Os; import android.system.OsConstants; @@ -1636,10 +1635,7 @@ public class StorageManager { * false not encrypted or file encrypted */ public static boolean isBlockEncrypted() { - if (!isEncrypted()) { - return false; - } - return RoSystemProperties.CRYPTO_BLOCK_ENCRYPTED; + return false; } /** {@hide} @@ -1649,18 +1645,7 @@ public class StorageManager { * false not encrypted, file encrypted or default block encrypted */ public static boolean isNonDefaultBlockEncrypted() { - if (!isBlockEncrypted()) { - return false; - } - - try { - IStorageManager storageManager = IStorageManager.Stub.asInterface( - ServiceManager.getService("mount")); - return storageManager.getPasswordType() != CRYPT_TYPE_DEFAULT; - } catch (RemoteException e) { - Log.e(TAG, "Error getting encryption type"); - return false; - } + return false; } /** {@hide} @@ -1674,8 +1659,7 @@ public class StorageManager { * framework, so no service needs to check for changes during their lifespan */ public static boolean isBlockEncrypting() { - final String state = VoldProperties.encrypt_progress().orElse(""); - return !"".equalsIgnoreCase(state); + return false; } /** {@hide} @@ -1690,8 +1674,7 @@ public class StorageManager { * framework, so no service needs to check for changes during their lifespan */ public static boolean inCryptKeeperBounce() { - final String status = VoldProperties.decrypt().orElse(""); - return "trigger_restart_min_framework".equals(status); + return false; } /** {@hide} */