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
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 099e6d3..f51ff7c 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -23,6 +23,7 @@
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 @@
setCallState(call, CallState.DIALING, "dialing set explicitly");
maybeMoveToSpeakerPhone(call);
maybeTurnOffMute(call);
+ ensureCallAudible();
}
void markCallAsPulling(Call call) {
@@ -1962,6 +1964,7 @@
} else {
setCallState(call, CallState.ACTIVE, "active set explicitly");
maybeMoveToSpeakerPhone(call);
+ ensureCallAudible();
}
}
@@ -2958,6 +2961,19 @@
}
}
+ 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.
*