Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6104eb96 authored by Nikhil Kumar's avatar Nikhil Kumar
Browse files

Add null check in the notifyForegroundUserAboutSoundIfNecessary

Bug: 349624618
Test: atest CtsMediaAudioTestCases:android.media.audio.cts.AudioFocusTest#testDuckedUidsAfterMediaMusic -- --abi x86_64 \
Flag: EXEMPT minor bug fix
Change-Id: Ia2b031fde4429f3800ddb9e621ab52316ee2f93c
parent 7c3c1a32
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.pm.UserInfo;
import android.media.AudioFocusInfo;
import android.media.AudioFocusInfo;
import android.media.AudioManager;
import android.media.AudioManager;
import android.media.AudioPlaybackConfiguration;
import android.media.AudioPlaybackConfiguration;
@@ -183,8 +184,8 @@ public class BackgroundUserSoundNotifier {
            foregroundContext) throws RemoteException {
            foregroundContext) throws RemoteException {
        final int userId = UserHandle.getUserId(afi.getClientUid());
        final int userId = UserHandle.getUserId(afi.getClientUid());
        final int usage = afi.getAttributes().getUsage();
        final int usage = afi.getAttributes().getUsage();
        String userName = mUserManager.getUserInfo(userId).name;
        UserInfo userInfo = mUserManager.getUserInfo(userId);
        if (userId != foregroundContext.getUserId()) {
        if (userInfo != null && userId != foregroundContext.getUserId()) {
            //TODO: b/349138482 - Add handling of cases when usage == USAGE_NOTIFICATION_RINGTONE
            //TODO: b/349138482 - Add handling of cases when usage == USAGE_NOTIFICATION_RINGTONE
            if (usage == USAGE_ALARM) {
            if (usage == USAGE_ALARM) {
                Intent muteIntent = createIntent(ACTION_MUTE_SOUND, afi, foregroundContext, userId);
                Intent muteIntent = createIntent(ACTION_MUTE_SOUND, afi, foregroundContext, userId);
@@ -199,7 +200,7 @@ public class BackgroundUserSoundNotifier {


                mUserWithNotification = foregroundContext.getUserId();
                mUserWithNotification = foregroundContext.getUserId();
                mNotificationManager.notifyAsUser(LOG_TAG, afi.getClientUid(),
                mNotificationManager.notifyAsUser(LOG_TAG, afi.getClientUid(),
                        createNotification(userName, mutePI, switchPI, foregroundContext),
                        createNotification(userInfo.name, mutePI, switchPI, foregroundContext),
                        foregroundContext.getUser());
                        foregroundContext.getUser());
            }
            }
        }
        }