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

Commit 7a066985 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by android-build-merger
Browse files

Merge "AudioService: fix updating of stream alias for A11y" into oc-dev am: d6792516

am: dd9f14c5

Change-Id: Iaec8f2ebac9241ac043b3cf3773880336a230f8a
parents e0e42625 dd9f14c5
Loading
Loading
Loading
Loading
+21 −13
Original line number Original line Diff line number Diff line
@@ -929,11 +929,8 @@ public class AudioService extends IAudioService.Stub
        synchronized (VolumeStreamState.class) {
        synchronized (VolumeStreamState.class) {
            int numStreamTypes = AudioSystem.getNumStreamTypes();
            int numStreamTypes = AudioSystem.getNumStreamTypes();
            for (int streamType = 0; streamType < numStreamTypes; streamType++) {
            for (int streamType = 0; streamType < numStreamTypes; streamType++) {
                if (streamType != mStreamVolumeAlias[streamType]) {
                mStreamStates[streamType]
                    mStreamStates[streamType].
                        .setAllIndexes(mStreamStates[mStreamVolumeAlias[streamType]], TAG);
                                    setAllIndexes(mStreamStates[mStreamVolumeAlias[streamType]],
                                            TAG);
                }
                // apply stream volume
                // apply stream volume
                if (!mStreamStates[streamType].mIsMuted) {
                if (!mStreamStates[streamType].mIsMuted) {
                    mStreamStates[streamType].applyAllVolumes();
                    mStreamStates[streamType].applyAllVolumes();
@@ -1022,20 +1019,21 @@ public class AudioService extends IAudioService.Stub
        }
        }


        mStreamVolumeAlias[AudioSystem.STREAM_DTMF] = dtmfStreamAlias;
        mStreamVolumeAlias[AudioSystem.STREAM_DTMF] = dtmfStreamAlias;
        final int oldStreamA11yAlias = mStreamVolumeAlias[AudioSystem.STREAM_ACCESSIBILITY];
        if (oldStreamA11yAlias != a11yStreamAlias) {
        mStreamVolumeAlias[AudioSystem.STREAM_ACCESSIBILITY] = a11yStreamAlias;
        mStreamVolumeAlias[AudioSystem.STREAM_ACCESSIBILITY] = a11yStreamAlias;
            mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].mVolumeIndexSettingName =
                    System.VOLUME_SETTINGS_INT[a11yStreamAlias];
            // restore the value from the settings when the alias changes
            mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].readSettings();
        }


        if (updateVolumes) {
        if (updateVolumes) {
            mStreamStates[AudioSystem.STREAM_DTMF].setAllIndexes(mStreamStates[dtmfStreamAlias],
            mStreamStates[AudioSystem.STREAM_DTMF].setAllIndexes(mStreamStates[dtmfStreamAlias],
                    caller);
                    caller);

            mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].mVolumeIndexSettingName =
                    System.VOLUME_SETTINGS_INT[a11yStreamAlias];
            mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].setAllIndexes(
            mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].setAllIndexes(
                    mStreamStates[a11yStreamAlias], caller);
                    mStreamStates[a11yStreamAlias], caller);
            if (sIndependentA11yVolume) {
                // restore the a11y values from the settings
                mStreamStates[AudioSystem.STREAM_ACCESSIBILITY].readSettings();
            }

            // apply stream mute states according to new value of mRingerModeAffectedStreams
            // apply stream mute states according to new value of mRingerModeAffectedStreams
            setRingerModeInt(getRingerModeInternal(), false);
            setRingerModeInt(getRingerModeInternal(), false);
            sendMsg(mAudioHandler,
            sendMsg(mAudioHandler,
@@ -4228,7 +4226,17 @@ public class AudioService extends IAudioService.Stub
            return mIndexMin;
            return mIndexMin;
        }
        }


        /**
         * Copies all device/index pairs from the given VolumeStreamState after initializing
         * them with the volume for DEVICE_OUT_DEFAULT. No-op if the source VolumeStreamState
         * has the same stream type as this instance.
         * @param srcStream
         * @param caller
         */
        public void setAllIndexes(VolumeStreamState srcStream, String caller) {
        public void setAllIndexes(VolumeStreamState srcStream, String caller) {
            if (mStreamType == srcStream.mStreamType) {
                return;
            }
            synchronized (VolumeStreamState.class) {
            synchronized (VolumeStreamState.class) {
                int srcStreamType = srcStream.getStreamType();
                int srcStreamType = srcStream.getStreamType();
                // apply default device volume from source stream to all devices first in case
                // apply default device volume from source stream to all devices first in case