From 92df2bb4fceeb075941d52b973c8b1f8da2a3786 Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Fri, 17 May 2024 11:17:16 +0100 Subject: HSUM: Fix profile unlock notification Send the confirm credential intent from the right user. Bug: 327350831 Test: none Change-Id: Ife9f2bed7a2095d2aac87a79aafe7868dce3591b --- core/java/android/app/admin/flags/flags.aconfig | 10 ++++++++++ .../android/server/locksettings/LockSettingsService.java | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/core/java/android/app/admin/flags/flags.aconfig b/core/java/android/app/admin/flags/flags.aconfig index 6600ca9989bb..649b8126a371 100644 --- a/core/java/android/app/admin/flags/flags.aconfig +++ b/core/java/android/app/admin/flags/flags.aconfig @@ -43,6 +43,16 @@ flag { bug: "295324350" } +flag { + name: "hsum_unlock_notification_fix" + namespace: "enterprise" + description: "Using the right userId when starting the work profile unlock flow " + bug: "327350831" + metadata { + purpose: PURPOSE_BUGFIX + } +} + flag { name: "dumpsys_policy_engine_migration_enabled" namespace: "enterprise" diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index ba99d2e4a950..54fb65c4e799 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -724,12 +724,13 @@ public class LockSettingsService extends ILockSettings.Stub { !mUserManager.isQuietModeEnabled(userHandle)) { // Only show notifications for managed profiles once their parent // user is unlocked. - showEncryptionNotificationForProfile(userHandle, reason); + showEncryptionNotificationForProfile(userHandle, parent.getUserHandle(), reason); } } } - private void showEncryptionNotificationForProfile(UserHandle user, String reason) { + private void showEncryptionNotificationForProfile(UserHandle user, UserHandle parent, + String reason) { CharSequence title = getEncryptionNotificationTitle(); CharSequence message = getEncryptionNotificationMessage(); CharSequence detail = getEncryptionNotificationDetail(); @@ -746,8 +747,15 @@ public class LockSettingsService extends ILockSettings.Stub { unlockIntent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); - PendingIntent intent = PendingIntent.getActivity(mContext, 0, unlockIntent, - PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED); + PendingIntent intent; + if (android.app.admin.flags.Flags.hsumUnlockNotificationFix()) { + intent = PendingIntent.getActivityAsUser(mContext, 0, unlockIntent, + PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED, + null, parent); + } else { + intent = PendingIntent.getActivity(mContext, 0, unlockIntent, + PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED); + } Slogf.d(TAG, "Showing encryption notification for user %d; reason: %s", user.getIdentifier(), reason); -- cgit v1.2.3-59-g8ed1b