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

Commit f8232597 authored by Hall Liu's avatar Hall Liu
Browse files

Ensure calls are audible upon starting

Check volume on STREAM_VOICE_CALL. If zero, set it to the default before
proceeding with either an incoming or outgoing call.

Change-Id: I210d95f59fe73586dd4d3202cca3b3eb3e500d0c
Fixes: 73956232
Test: manual
parent b0398e4a
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.pm.UserInfo;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.media.AudioSystem;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -1909,6 +1910,7 @@ public class CallsManager extends Call.ListenerBase
        setCallState(call, CallState.DIALING, "dialing set explicitly");
        maybeMoveToSpeakerPhone(call);
        maybeTurnOffMute(call);
        ensureCallAudible();
    }

    void markCallAsPulling(Call call) {
@@ -1962,6 +1964,7 @@ public class CallsManager extends Call.ListenerBase
        } else {
            setCallState(call, CallState.ACTIVE, "active set explicitly");
            maybeMoveToSpeakerPhone(call);
            ensureCallAudible();
        }
    }

@@ -2958,6 +2961,19 @@ public class CallsManager extends Call.ListenerBase
        }
    }

    private void ensureCallAudible() {
        AudioManager am = mContext.getSystemService(AudioManager.class);
        if (am == null) {
            Log.w(this, "ensureCallAudible: audio manager is null");
            return;
        }
        if (am.getStreamVolume(AudioManager.STREAM_VOICE_CALL) == 0) {
            Log.i(this, "ensureCallAudible: voice call stream has volume 0. Adjusting to default.");
            am.setStreamVolume(AudioManager.STREAM_VOICE_CALL,
                    AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_VOICE_CALL), 0);
        }
    }

    /**
     * Creates a new call for an existing connection.
     *