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

Commit f3dc1ca7 authored by Roman Birg's avatar Roman Birg Committed by Abhisek Devkota
Browse files

fix Notification volume slider linking



Change-Id: I0f74485f5c8c2aa7698cf9ba1c60c2c8c967798d
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent dd8c7275
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -103,8 +103,14 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
        mDefaultUri = defaultUri;
    }

    private static boolean isNotificationOrRing(int stream) {
        return stream == AudioManager.STREAM_RING || stream == AudioManager.STREAM_NOTIFICATION;
    private boolean isNotificationOrRing(int stream) {
        return stream == AudioManager.STREAM_RING
                || (stream == AudioManager.STREAM_NOTIFICATION && isNotificationStreamLinked());
    }

    private boolean isNotificationStreamLinked() {
        return Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.VOLUME_LINK_NOTIFICATION, 1) == 1;
    }

    public void setSeekBar(SeekBar seekBar) {
@@ -126,7 +132,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
            mSeekBar.setEnabled(false);
            mSeekBar.setProgress(0);
        } else {
            mSeekBar.setEnabled(true);
            mSeekBar.setEnabled(mStreamType != AudioManager.STREAM_NOTIFICATION
                    || !isNotificationStreamLinked());
            mSeekBar.setProgress(mLastProgress > -1 ? mLastProgress : mOriginalStreamVolume);
        }
    }
+8 −6
Original line number Diff line number Diff line
@@ -4596,6 +4596,8 @@ public class AudioService extends IAudioService.Stub {
            super(new Handler());
            mContentResolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.MODE_RINGER_STREAMS_AFFECTED), false, this);
            mContentResolver.registerContentObserver(Settings.Secure.getUriFor(
                    Settings.Secure.VOLUME_LINK_NOTIFICATION), false, this);
            mContentResolver.registerContentObserver(Settings.Global.getUriFor(
                Settings.Global.DOCK_AUDIO_MEDIA_ENABLED), false, this);
        }
@@ -4617,12 +4619,12 @@ public class AudioService extends IAudioService.Stub {
                }
                readDockAudioSettings(mContentResolver);

                mLinkNotificationWithVolume = Settings.Secure.getInt(mContentResolver,
                boolean linkNotificationWithVolume = Settings.Secure.getInt(mContentResolver,
                        Settings.Secure.VOLUME_LINK_NOTIFICATION, 1) == 1;
                if (mLinkNotificationWithVolume) {
                    mStreamVolumeAlias[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_RING;
                } else {
                    mStreamVolumeAlias[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_NOTIFICATION;
                if (linkNotificationWithVolume != mLinkNotificationWithVolume) {
                    mLinkNotificationWithVolume = linkNotificationWithVolume;
                    updateStreamVolumeAlias(true);
                    createStreamStates();
                }
            }
        }