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

Commit d2a8d71c authored by Jae Seo's avatar Jae Seo
Browse files

MediaSession: Do not lock on AudioManager.getStreamVolume

Locking on AudioManager.getStreamVolume method causes watchdog killing
system process for it makes a native call to get devices for stream,
which takes time. This change removes such locking.

Bug: 22404242
Change-Id: I23de3efe33642341205d65f58bc5b74542f1f506
parent 11813232
Loading
Loading
Loading
Loading
+13 −14
Original line number Diff line number Diff line
@@ -1067,23 +1067,22 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {

        @Override
        public ParcelableVolumeInfo getVolumeAttributes() {
            int volumeType;
            AudioAttributes attributes;
            synchronized (mLock) {
                int type;
                int max;
                int current;
                if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_REMOTE) {
                    type = mVolumeControlType;
                    max = mMaxVolume;
                    current = mOptimisticVolume != -1 ? mOptimisticVolume
                            : mCurrentVolume;
                } else {
                    int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs);
                    type = VolumeProvider.VOLUME_CONTROL_ABSOLUTE;
                    max = mAudioManager.getStreamMaxVolume(stream);
                    current = mAudioManager.getStreamVolume(stream);
                }
                return new ParcelableVolumeInfo(mVolumeType, mAudioAttrs, type, max, current);
            }
                    int current = mOptimisticVolume != -1 ? mOptimisticVolume : mCurrentVolume;
                    return new ParcelableVolumeInfo(
                            mVolumeType, mAudioAttrs, mVolumeControlType, mMaxVolume, current);
                }
                volumeType = mVolumeType;
                attributes = mAudioAttrs;
            }
            int stream = AudioAttributes.toLegacyStreamType(attributes);
            int max = mAudioManager.getStreamMaxVolume(stream);
            int current = mAudioManager.getStreamVolume(stream);
            return new ParcelableVolumeInfo(
                    volumeType, attributes, VolumeProvider.VOLUME_CONTROL_ABSOLUTE, max, current);
        }

        @Override