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

Commit 4f0f1203 authored by John Spurlock's avatar John Spurlock
Browse files

AudioService: getMasterStreamType -> RING on tablets.

Since all service-internal checks use stream alias, and the alias
for NOTIFICATION is RING, even on tablets.

This is a followup to ag/506532.

Ensure that #getMasterStreamType always follows the stream_system
alias, and update the system alias for tablets per the new policy.
Update the associate javadoc comment in AudioManager to make this
clear.

Note: there is now no difference in the alias maps between phones
and tablets.

Also fix a condition affected by this in VolumePanel.

Bug:16626879
Change-Id: I2700a48d2a3e7703607f771a1ab7f325596fd789
parent 46db9340
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -834,6 +834,7 @@ public class AudioManager {
    /**
     * Get the stream type whose volume is driving the UI sounds volume.
     * UI sounds are screen lock/unlock, camera shutter, key clicks...
     * It is assumed that this stream type is also tied to ringer mode changes.
     * @hide
     */
    public int getMasterStreamType() {
+4 −12
Original line number Diff line number Diff line
@@ -291,14 +291,14 @@ public class AudioService extends IAudioService.Stub {
    };
    private final int[] STREAM_VOLUME_ALIAS_DEFAULT = new int[] {
        AudioSystem.STREAM_VOICE_CALL,      // STREAM_VOICE_CALL
        AudioSystem.STREAM_MUSIC,           // STREAM_SYSTEM
        AudioSystem.STREAM_RING,            // STREAM_SYSTEM
        AudioSystem.STREAM_RING,            // STREAM_RING
        AudioSystem.STREAM_MUSIC,           // STREAM_MUSIC
        AudioSystem.STREAM_ALARM,           // STREAM_ALARM
        AudioSystem.STREAM_RING,            // STREAM_NOTIFICATION
        AudioSystem.STREAM_BLUETOOTH_SCO,   // STREAM_BLUETOOTH_SCO
        AudioSystem.STREAM_MUSIC,           // STREAM_SYSTEM_ENFORCED
        AudioSystem.STREAM_MUSIC,           // STREAM_DTMF
        AudioSystem.STREAM_RING,            // STREAM_SYSTEM_ENFORCED
        AudioSystem.STREAM_RING,            // STREAM_DTMF
        AudioSystem.STREAM_MUSIC            // STREAM_TTS
    };
    private int[] mStreamVolumeAlias;
@@ -1572,15 +1572,7 @@ public class AudioService extends IAudioService.Stub {

    /** @see AudioManager#getMasterStreamType()  */
    public int getMasterStreamType() {
        switch (mPlatformType) {
            case PLATFORM_VOICE:
                return AudioSystem.STREAM_RING;
            case PLATFORM_TELEVISION:
                return AudioSystem.STREAM_MUSIC;
            default:
                break;
        }
        return AudioSystem.STREAM_NOTIFICATION;
        return mStreamVolumeAlias[AudioSystem.STREAM_SYSTEM];
    }

    /** @see AudioManager#setMicrophoneMute(boolean) */
+4 −4
Original line number Diff line number Diff line
@@ -680,15 +680,15 @@ public class VolumePanel extends Handler {
            // never disable touch interactions for remote playback, the muting is not tied to
            // the state of the phone.
            sc.seekbarView.setEnabled(!fixedVolume);
        } else if (fixedVolume ||
                        (sc.streamType != mAudioManager.getMasterStreamType() && muted) ||
                        (sSafetyWarning != null)) {
            sc.seekbarView.setEnabled(false);
        } else if (isRinger && mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
            sc.seekbarView.setEnabled(false);
            sc.icon.setEnabled(false);
            sc.icon.setAlpha(mDisabledAlpha);
            sc.icon.setClickable(false);
        } else if (fixedVolume ||
                (sc.streamType != mAudioManager.getMasterStreamType() && muted) ||
                (sSafetyWarning != null)) {
            sc.seekbarView.setEnabled(false);
        } else {
            sc.seekbarView.setEnabled(true);
            sc.icon.setEnabled(true);