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

Commit 0ca78185 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Merge "Update ringer audio focus if ringer volume is changed during ringing." into gingerbread

parents 86386c8e 051c99dc
Loading
Loading
Loading
Loading
+29 −7
Original line number Diff line number Diff line
@@ -506,6 +506,15 @@ public class AudioService extends IAudioService.Stub {
            }
            index = streamState.mIndex;
        }

        if (streamType == AudioSystem.STREAM_RING) {
            synchronized(mRingingLock) {
                if (mIsRinging) {
                    updateRingingAudioFocus();
                }
            }
        }

        // UI
        showVolumeChangeUi(streamType, flags);
        // Broadcast Intent
@@ -524,6 +533,14 @@ public class AudioService extends IAudioService.Stub {

        index = (streamState.muteCount() != 0) ? streamState.mLastAudibleIndex : streamState.mIndex;

        if (streamType == AudioSystem.STREAM_RING) {
            synchronized(mRingingLock) {
                if (mIsRinging) {
                    updateRingingAudioFocus();
                }
            }
        }

        // UI, etc.
        showVolumeChangeUi(streamType, flags);
        // Broadcast Intent
@@ -2155,13 +2172,7 @@ public class AudioService extends IAudioService.Stub {
                synchronized(mRingingLock) {
                    mIsRinging = true;
                }
                int ringVolume = AudioService.this.getStreamVolume(AudioManager.STREAM_RING);
                if (ringVolume > 0) {
                    requestAudioFocus(AudioManager.STREAM_RING,
                                AudioManager.AUDIOFOCUS_GAIN_TRANSIENT,
                                null, null /* both allowed to be null only for this clientId */,
                                IN_VOICE_COMM_FOCUS_ID /*clientId*/);
                }
                updateRingingAudioFocus();
            } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                //Log.v(TAG, " CALL_STATE_OFFHOOK");
                synchronized(mRingingLock) {
@@ -2181,6 +2192,17 @@ public class AudioService extends IAudioService.Stub {
        }
    };

    private void updateRingingAudioFocus() {
        int ringVolume = getStreamVolume(AudioManager.STREAM_RING);
        int hint = ringVolume > 0
                ? AudioManager.AUDIOFOCUS_GAIN_TRANSIENT
                : AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK;

        requestAudioFocus(AudioManager.STREAM_RING, hint,
                null, null /* both allowed to be null only for this clientId */,
                IN_VOICE_COMM_FOCUS_ID /*clientId*/);
    }

    private void notifyTopOfAudioFocusStack() {
        // notify the top of the stack it gained focus
        if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null)) {