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

Commit 05e31308 authored by Roman Birg's avatar Roman Birg
Browse files

Telephony service: add ability to always request focus for calls



Add in the ability to overlay a config value to allow for incoming calls
to always request focus no matter the current ring volume.

Change-Id: Ie1fdbf7f0783772e3a0dae9606e3b5c3ea8e1e2b
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 185629ba
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -117,6 +117,8 @@ public class CallManager {

    protected boolean mSpeedUpAudioForMtCall = false;

    protected Boolean mAlwaysRequestVolumeFocus;

    protected CmHandler mHandler;

    // state registrants
@@ -474,7 +476,8 @@ public class CallManager {
                int curAudioMode = audioManager.getMode();
                if (curAudioMode != AudioManager.MODE_RINGTONE) {
                    // only request audio focus if the ringtone is going to be heard
                    if (audioManager.getStreamVolume(AudioManager.STREAM_RING) > 0) {
                    if (audioManager.getStreamVolume(AudioManager.STREAM_RING) > 0
                            || shouldAlwaysRequestAudioFocusForCall()) {
                        if (VDBG) Rlog.d(LOG_TAG, "requestAudioFocus on STREAM_RING");
                        audioManager.requestAudioFocusForCall(AudioManager.STREAM_RING,
                                AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
@@ -527,6 +530,16 @@ public class CallManager {
        Rlog.d(LOG_TAG, "setAudioMode state = " + getState());
    }

    protected boolean shouldAlwaysRequestAudioFocusForCall() {
        if (mAlwaysRequestVolumeFocus == null) {
            Context context = getContext();
            if (context == null) return false;
            mAlwaysRequestVolumeFocus = context.getResources().getBoolean(
                    com.android.internal.R.bool.config_alwaysRequestAudioFocusForCalls);
        }
        return mAlwaysRequestVolumeFocus;
    }

    protected Context getContext() {
        Phone defaultPhone = getDefaultPhone();
        return ((defaultPhone == null) ? null : defaultPhone.getContext());
+2 −1
Original line number Diff line number Diff line
@@ -336,7 +336,8 @@ public class ExtCallManager extends CallManager {
                int curAudioMode = mAudioManager.getMode();
                if (curAudioMode != AudioManager.MODE_RINGTONE) {
                    // only request audio focus if the ringtone is going to be heard
                    if (mAudioManager.getStreamVolume(AudioManager.STREAM_RING) > 0) {
                    if (mAudioManager.getStreamVolume(AudioManager.STREAM_RING) > 0
                            || shouldAlwaysRequestAudioFocusForCall()) {
                        Rlog.d(LOG_TAG, "requestAudioFocus on STREAM_RING");
                        mAudioManager.requestAudioFocusForCall(AudioManager.STREAM_RING,
                                AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);