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

Commit be753d6b authored by Roman Birg's avatar Roman Birg
Browse files

fixup volume stream linking



- Make the SeekBarVolumizer move notification and ringer streams when
 linked and moving ringer.

- Fix initial state causing volume stream seek bar to be set to 0
  initially

- Clean up AudioService initialization code

Change-Id: Ia11a7a392e5eb3ef862147843e365d5f20eaf90a
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent b7af9418
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -107,8 +107,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
    }

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

    private boolean isNotificationStreamLinked() {
@@ -141,8 +140,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
    }

    private boolean enableSeekBar() {
        return mStreamType != AudioManager.STREAM_NOTIFICATION
                || !isNotificationStreamLinked();
        return !(mStreamType == AudioManager.STREAM_NOTIFICATION && isNotificationStreamLinked());
    }

    @Override
@@ -380,7 +378,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
            if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) {
                int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
                int streamValue = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, -1);
                final boolean streamMatch = mNotificationOrRing ? isNotificationOrRing(streamType)
                final boolean streamMatch = mNotificationOrRing && isNotificationStreamLinked()
                        ? isNotificationOrRing(streamType)
                        : (streamType == mStreamType);
                if (mSeekBar != null && streamMatch && streamValue != -1) {
                    final boolean muted = mAudioManager.isStreamMute(mStreamType);
+9 −10
Original line number Diff line number Diff line
@@ -644,13 +644,16 @@ public class AudioService extends IAudioService.Stub {
        mMasterVolumeRamp = context.getResources().getIntArray(
                com.android.internal.R.array.config_masterVolumeRamp);

        // read this in before readPersistedSettings() because updateStreamVolumeAlias needs it
        mLinkNotificationWithVolume = Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.VOLUME_LINK_NOTIFICATION, 1) == 1;

        // must be called before readPersistedSettings() which needs a valid mStreamVolumeAlias[]
        // array initialized by updateStreamVolumeAlias()
        updateStreamVolumeAlias(false /*updateVolumes*/);
        readPersistedSettings();
        mSettingsObserver = new SettingsObserver();
        createStreamStates();
        updateNotificationStreamVolumeAlias();

        readAndSetLowRamDevice();

@@ -954,7 +957,11 @@ public class AudioService extends IAudioService.Stub {

        mStreamVolumeAlias[AudioSystem.STREAM_DTMF] = dtmfStreamAlias;

        updateNotificationStreamVolumeAlias();
        if (mLinkNotificationWithVolume && mVoiceCapable) {
            mStreamVolumeAlias[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_RING;
        } else {
            mStreamVolumeAlias[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_NOTIFICATION;
        }

        if (updateVolumes) {
            mStreamStates[AudioSystem.STREAM_DTMF].setAllIndexes(mStreamStates[dtmfStreamAlias]);
@@ -969,14 +976,6 @@ public class AudioService extends IAudioService.Stub {
        }
    }

    private void updateNotificationStreamVolumeAlias() {
        if (mLinkNotificationWithVolume && mVoiceCapable) {
            mStreamVolumeAlias[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_RING;
        } else {
            mStreamVolumeAlias[AudioSystem.STREAM_NOTIFICATION] = AudioSystem.STREAM_NOTIFICATION;
        }
    }

    private void readDockAudioSettings(ContentResolver cr)
    {
        mDockAudioMediaEnabled = Settings.Global.getInt(