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

Commit bd39cfaf authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

AudioService: prevent NPE on an invalid PIID

When looking for the AudioPlaybackConfiguration to act on a player,
  check that the PIID is valid.
(Note that this is also handled in checkConfigurationCaller())

Test: see bug
Bug 35484407

Change-Id: Ic46ad10f9730593f6600175ab3ca8f496cc6d972
parent 6e820805
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -106,7 +106,9 @@ public final class PlaybackActivityMonitor
        synchronized(mPlayerLock) {
            final AudioPlaybackConfiguration apc = mPlayers.get(new Integer(piid));
            // FIXME SoundPool not ready for state reporting
            if (apc.getPlayerType() == AudioPlaybackConfiguration.PLAYER_TYPE_JAM_SOUNDPOOL) {
            if (apc != null
                    && apc.getPlayerType() == AudioPlaybackConfiguration.PLAYER_TYPE_JAM_SOUNDPOOL)
            {
                return;
            }
            if (checkConfigurationCaller(piid, apc, binderUid)) {
@@ -278,6 +280,9 @@ public final class PlaybackActivityMonitor
            while (piidIterator.hasNext()) {
                final Integer piid = piidIterator.next();
                final AudioPlaybackConfiguration apc = mPlayers.get(piid);
                if (apc == null) {
                    continue;
                }
                if (!winner.hasSameUid(apc.getClientUid())
                        && loser.hasSameUid(apc.getClientUid())
                        && apc.getPlayerState() == AudioPlaybackConfiguration.PLAYER_STATE_STARTED)
@@ -363,6 +368,9 @@ public final class PlaybackActivityMonitor
            while (piidIterator.hasNext()) {
                final Integer piid = piidIterator.next();
                final AudioPlaybackConfiguration apc = mPlayers.get(piid);
                if (apc == null) {
                    continue;
                }
                final int playerUsage = apc.getAudioAttributes().getUsage();
                boolean mute = false;
                for (int usageToMute : usagesToMute) {