From ef6ddb0142c8c2fe67bf6a8e09a8b98f9f89b0a1 Mon Sep 17 00:00:00 2001 From: seokil Date: Fri, 6 Jan 2023 16:08:30 +0900 Subject: [PATCH] FBE notification is updated when language changed The FBE(encryption) notification shown when the work profile is locked still consists of the previous language even if the language is changed. The following commit resolve that issue. When the language is changed, the notification is re-configured in the changed language. After receiving 'ACTION_LOCALE_CHANGED' broadcast, the notification will be updated in the changed language. Manual testing * Create work profile * Set work profile lock type * Evict work profile's ce key or reboot. * Language change Bug: 239797643 Test: manual testing Change-Id: I1c97295d1053a2cabea33959bc1dbf5ed88173a1 Signed-off-by: seokil --- .../locksettings/LockSettingsService.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index ebc18bcd2369a..cd4a8f337b413 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -110,6 +110,7 @@ import android.security.keystore.recovery.WrappedApplicationKey; import android.security.keystore2.AndroidKeyStoreLoadStoreParameter; import android.security.keystore2.AndroidKeyStoreProvider; import android.service.gatekeeper.IGateKeeperService; +import android.service.notification.StatusBarNotification; import android.system.keystore2.Domain; import android.text.TextUtils; import android.util.ArrayMap; @@ -581,6 +582,7 @@ public class LockSettingsService extends ILockSettings.Stub { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_USER_ADDED); filter.addAction(Intent.ACTION_USER_STARTING); + filter.addAction(Intent.ACTION_LOCALE_CHANGED); injector.getContext().registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null); @@ -602,6 +604,20 @@ public class LockSettingsService extends ILockSettings.Stub { LocalServices.addService(LockSettingsInternal.class, new LocalService()); } + private void updateActivatedEncryptionNotifications(String reason) { + for (UserInfo userInfo : mUserManager.getUsers()) { + Context userContext = mContext.createContextAsUser(UserHandle.of(userInfo.id), 0); + NotificationManager nm = (NotificationManager) + userContext.getSystemService(Context.NOTIFICATION_SERVICE); + for (StatusBarNotification notification : nm.getActiveNotifications()) { + if (notification.getId() == SystemMessage.NOTE_FBE_ENCRYPTED_NOTIFICATION) { + maybeShowEncryptionNotificationForUser(userInfo.id, reason); + break; + } + } + } + } + /** * If the account is credential-encrypted, show notification requesting the user to unlock the * device. @@ -799,6 +815,8 @@ public class LockSettingsService extends ILockSettings.Stub { } else if (Intent.ACTION_USER_STARTING.equals(intent.getAction())) { final int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); mStorage.prefetchUser(userHandle); + } else if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) { + updateActivatedEncryptionNotifications("locale changed"); } } };