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

Commit 20f3fc13 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Automerger Merge Worker
Browse files

Merge "Fix ACTION_VOLUME_CHANGED behavior" into tm-qpr-dev am: a6abfc6e

parents 0eceb9e9 a6abfc6e
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -3710,6 +3710,10 @@ public class AudioService extends IAudioService.Stub
        Objects.requireNonNull(vi);
        Objects.requireNonNull(vi);
        Objects.requireNonNull(ada);
        Objects.requireNonNull(ada);
        Objects.requireNonNull(callingPackage);
        Objects.requireNonNull(callingPackage);
        AudioService.sVolumeLogger.loglogi("setDeviceVolume" + " from:" + callingPackage + " "
                + vi + " " + ada, TAG);
        if (!vi.hasStreamType()) {
        if (!vi.hasStreamType()) {
            Log.e(TAG, "Unsupported non-stream type based VolumeInfo", new Exception());
            Log.e(TAG, "Unsupported non-stream type based VolumeInfo", new Exception());
            return;
            return;
@@ -7839,6 +7843,7 @@ public class AudioService extends IAudioService.Stub
                boolean hasModifyAudioSettings) {
                boolean hasModifyAudioSettings) {
            boolean changed;
            boolean changed;
            int oldIndex;
            int oldIndex;
            final boolean isCurrentDevice;
            synchronized (mSettingsLock) {
            synchronized (mSettingsLock) {
                synchronized (VolumeStreamState.class) {
                synchronized (VolumeStreamState.class) {
                    oldIndex = getIndex(device);
                    oldIndex = getIndex(device);
@@ -7854,7 +7859,7 @@ public class AudioService extends IAudioService.Stub
                    // - there is no volume index stored for this device on alias stream.
                    // - there is no volume index stored for this device on alias stream.
                    // If changing volume of current device, also change volume of current
                    // If changing volume of current device, also change volume of current
                    // device on aliased stream
                    // device on aliased stream
                    final boolean isCurrentDevice = (device == getDeviceForStream(mStreamType));
                    isCurrentDevice = (device == getDeviceForStream(mStreamType));
                    final int numStreamTypes = AudioSystem.getNumStreamTypes();
                    final int numStreamTypes = AudioSystem.getNumStreamTypes();
                    for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
                    for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
                        final VolumeStreamState aliasStreamState = mStreamStates[streamType];
                        final VolumeStreamState aliasStreamState = mStreamStates[streamType];
@@ -7894,8 +7899,9 @@ public class AudioService extends IAudioService.Stub
                    EventLogTags.writeVolumeChanged(mStreamType, oldIndex, index, mIndexMax / 10,
                    EventLogTags.writeVolumeChanged(mStreamType, oldIndex, index, mIndexMax / 10,
                            caller);
                            caller);
                }
                }
                // fire changed intents for all streams
                // fire changed intents for all streams, but only when the device it changed on
                if (index != oldIndex) {
                // is the current device
                if ((index != oldIndex) && isCurrentDevice) {
                    mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index);
                    mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index);
                    mVolumeChanged.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex);
                    mVolumeChanged.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex);
                    mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE_ALIAS,
                    mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE_ALIAS,