Merge "Add null check in the notifyForegroundUserAboutSoundIfNecessary" into main
diff --git a/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java b/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java
index ec95298..58b14b1 100644
--- a/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java
+++ b/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java
@@ -28,6 +28,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.UserInfo;
import android.media.AudioFocusInfo;
import android.media.AudioManager;
import android.media.AudioPlaybackConfiguration;
@@ -183,8 +184,8 @@
foregroundContext) throws RemoteException {
final int userId = UserHandle.getUserId(afi.getClientUid());
final int usage = afi.getAttributes().getUsage();
- String userName = mUserManager.getUserInfo(userId).name;
- if (userId != foregroundContext.getUserId()) {
+ UserInfo userInfo = mUserManager.getUserInfo(userId);
+ if (userInfo != null && userId != foregroundContext.getUserId()) {
//TODO: b/349138482 - Add handling of cases when usage == USAGE_NOTIFICATION_RINGTONE
if (usage == USAGE_ALARM) {
Intent muteIntent = createIntent(ACTION_MUTE_SOUND, afi, foregroundContext, userId);
@@ -199,7 +200,7 @@
mUserWithNotification = foregroundContext.getUserId();
mNotificationManager.notifyAsUser(LOG_TAG, afi.getClientUid(),
- createNotification(userName, mutePI, switchPI, foregroundContext),
+ createNotification(userInfo.name, mutePI, switchPI, foregroundContext),
foregroundContext.getUser());
}
}