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 <seokil.kang@samsung.corp-partner.google.com>
This commit is contained in:
seokil
2023-01-06 16:08:30 +09:00
committed by Eric Biggers
parent 6ec1f4309d
commit ef6ddb0142

View File

@@ -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");
}
}
};