Improve audio hack for Galaxy S.
This commit is contained in:
parent
50a1f3d3c3
commit
63c3ad8bdf
4 changed files with 19 additions and 63 deletions
|
@ -852,6 +852,10 @@ public class IncallActivity extends AbstractCalleesActivity implements
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (state == State.StreamsRunning) {
|
||||||
|
// The following should not be needed except some devices need it (e.g. Galaxy S).
|
||||||
|
LinphoneManager.getLc().enableSpeaker(LinphoneManager.getLc().isSpeakerEnabled());
|
||||||
|
}
|
||||||
super.onCallStateChanged(call, state, message);
|
super.onCallStateChanged(call, state, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,10 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
||||||
if (call == mCall && State.CallEnd == state) {
|
if (call == mCall && State.CallEnd == state) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
if (state == State.StreamsRunning) {
|
||||||
|
// The following should not be needed except some devices need it (e.g. Galaxy S).
|
||||||
|
LinphoneManager.getLc().enableSpeaker(LinphoneManager.getLc().isSpeakerEnabled());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decline() {
|
private void decline() {
|
||||||
|
|
|
@ -18,11 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
import static android.media.AudioManager.MODE_IN_CALL;
|
|
||||||
import static android.media.AudioManager.MODE_NORMAL;
|
import static android.media.AudioManager.MODE_NORMAL;
|
||||||
import static android.media.AudioManager.MODE_RINGTONE;
|
|
||||||
import static android.media.AudioManager.ROUTE_EARPIECE;
|
|
||||||
import static android.media.AudioManager.ROUTE_SPEAKER;
|
|
||||||
import static android.media.AudioManager.STREAM_RING;
|
import static android.media.AudioManager.STREAM_RING;
|
||||||
import static android.media.AudioManager.STREAM_VOICE_CALL;
|
import static android.media.AudioManager.STREAM_VOICE_CALL;
|
||||||
import static android.media.AudioManager.VIBRATE_TYPE_RINGER;
|
import static android.media.AudioManager.VIBRATE_TYPE_RINGER;
|
||||||
|
@ -200,44 +196,13 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
private BroadcastReceiver mKeepAliveReceiver = new KeepAliveReceiver();
|
private BroadcastReceiver mKeepAliveReceiver = new KeepAliveReceiver();
|
||||||
|
|
||||||
private native void hackSpeakerState(boolean speakerOn);
|
private synchronized void routeAudioToSpeakerHelper(boolean speakerOn) {
|
||||||
private static void sRouteAudioToSpeakerHelperHelper(boolean speakerOn) {
|
mLc.enableSpeaker(speakerOn);
|
||||||
getInstance().routeAudioToSpeakerHelperHelper(speakerOn);
|
final LinphoneCall call = mLc.getCurrentCall();
|
||||||
}
|
|
||||||
private void routeAudioToSpeakerHelperHelper(boolean speakerOn) {
|
|
||||||
boolean different = isSpeakerOn() ^ speakerOn;
|
|
||||||
if (!different) {
|
|
||||||
Log.d("Skipping change audio route by the same route ",
|
|
||||||
speakerOn ? "speaker" : "earpiece");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Hacks.needGalaxySAudioHack() || sLPref.useGalaxySHack())
|
|
||||||
setAudioModeIncallForGalaxyS();
|
|
||||||
|
|
||||||
if (sLPref.useSpecificAudioModeHack() != -1)
|
|
||||||
mAudioManager.setMode(sLPref.useSpecificAudioModeHack());
|
|
||||||
|
|
||||||
if (Hacks.needRoutingAPI() || sLPref.useAudioRoutingAPIHack()) {
|
|
||||||
mAudioManager.setRouting(
|
|
||||||
MODE_NORMAL,
|
|
||||||
speakerOn? ROUTE_SPEAKER : ROUTE_EARPIECE,
|
|
||||||
AudioManager.ROUTE_ALL);
|
|
||||||
} else {
|
|
||||||
mAudioManager.setSpeakerphoneOn(speakerOn);
|
|
||||||
}
|
|
||||||
for (LinphoneOnAudioChangedListener listener : getSimpleListeners(LinphoneOnAudioChangedListener.class)) {
|
for (LinphoneOnAudioChangedListener listener : getSimpleListeners(LinphoneOnAudioChangedListener.class)) {
|
||||||
listener.onAudioStateChanged(speakerOn ? AudioState.SPEAKER : AudioState.EARPIECE);
|
listener.onAudioStateChanged(speakerOn ? AudioState.SPEAKER : AudioState.EARPIECE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private synchronized void routeAudioToSpeakerHelper(boolean speakerOn) {
|
|
||||||
final LinphoneCall call = mLc.getCurrentCall();
|
|
||||||
if (call != null && call.getState() == State.StreamsRunning && Hacks.needPausingCallForSpeakers()) {
|
|
||||||
Log.d("Hack to have speaker=",speakerOn," while on call");
|
|
||||||
hackSpeakerState(speakerOn);
|
|
||||||
} else {
|
|
||||||
routeAudioToSpeakerHelperHelper(speakerOn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -262,7 +227,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
throw new RuntimeException("Linphone Manager is already initialized");
|
throw new RuntimeException("Linphone Manager is already initialized");
|
||||||
|
|
||||||
instance = new LinphoneManager(c, listener);
|
instance = new LinphoneManager(c, listener);
|
||||||
instance.startLibLinphone();
|
instance.startLibLinphone(c);
|
||||||
TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
boolean gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE;
|
boolean gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE;
|
||||||
setGsmIdle(gsmIdle);
|
setGsmIdle(gsmIdle);
|
||||||
|
@ -290,11 +255,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
|
|
||||||
public boolean isSpeakerOn() {
|
public boolean isSpeakerOn() {
|
||||||
if (Hacks.needRoutingAPI() || sLPref.useAudioRoutingAPIHack()) {
|
return mLc.isSpeakerEnabled();
|
||||||
return mAudioManager.getRouting(MODE_NORMAL) == ROUTE_SPEAKER;
|
|
||||||
} else {
|
|
||||||
return mAudioManager.isSpeakerphoneOn();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -447,7 +408,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private synchronized void startLibLinphone() {
|
private synchronized void startLibLinphone(Context c) {
|
||||||
try {
|
try {
|
||||||
copyAssetsFromPackage();
|
copyAssetsFromPackage();
|
||||||
//traces alway start with traces enable to not missed first initialization
|
//traces alway start with traces enable to not missed first initialization
|
||||||
|
@ -456,6 +417,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
mLc = LinphoneCoreFactory.instance().createLinphoneCore(
|
mLc = LinphoneCoreFactory.instance().createLinphoneCore(
|
||||||
this, mLinphoneConfigFile, mLinphoneInitialConfigFile, null);
|
this, mLinphoneConfigFile, mLinphoneInitialConfigFile, null);
|
||||||
|
mLc.setContext(c);
|
||||||
|
|
||||||
mLc.enableIpv6(getPrefBoolean(R.string.pref_ipv6_key, false));
|
mLc.enableIpv6(getPrefBoolean(R.string.pref_ipv6_key, false));
|
||||||
mLc.setZrtpSecretsCache(basePath+"/zrtp_secrets");
|
mLc.setZrtpSecretsCache(basePath+"/zrtp_secrets");
|
||||||
|
@ -1099,11 +1061,9 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
if (disableRinging ) {
|
if (disableRinging ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hacks.needGalaxySAudioHack()) {
|
mLc.startRinging();
|
||||||
mAudioManager.setMode(MODE_RINGTONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER) && mVibrator !=null) {
|
if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER) && mVibrator !=null) {
|
||||||
long[] patern = {0,1000,1000};
|
long[] patern = {0,1000,1000};
|
||||||
|
@ -1178,12 +1138,6 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
return isVideoEnabled() && getPrefBoolean(R.string.pref_video_initiate_call_with_video_key, false);
|
return isVideoEnabled() && getPrefBoolean(R.string.pref_video_initiate_call_with_video_key, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAudioModeIncallForGalaxyS() {
|
|
||||||
/* The microphone gain is way too high on the Galaxy S so correct it here. */
|
|
||||||
LinphoneManager.getLc().setMicrophoneGain(-9.0f);
|
|
||||||
mAudioManager.setMode(MODE_IN_CALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called on first launch only
|
// Called on first launch only
|
||||||
public void initializePayloads() {
|
public void initializePayloads() {
|
||||||
Log.i("Initializing supported payloads");
|
Log.i("Initializing supported payloads");
|
||||||
|
@ -1233,9 +1187,6 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean acceptCallIfIncomingPending() throws LinphoneCoreException {
|
public boolean acceptCallIfIncomingPending() throws LinphoneCoreException {
|
||||||
if (Hacks.needGalaxySAudioHack() || sLPref.useGalaxySHack())
|
|
||||||
setAudioModeIncallForGalaxyS();
|
|
||||||
|
|
||||||
if (mLc.isInComingInvitePending()) {
|
if (mLc.isInComingInvitePending()) {
|
||||||
mLc.acceptCall(mLc.getCurrentCall());
|
mLc.acceptCall(mLc.getCurrentCall());
|
||||||
return true;
|
return true;
|
||||||
|
@ -1244,9 +1195,6 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean acceptCall(LinphoneCall call) {
|
public boolean acceptCall(LinphoneCall call) {
|
||||||
if (Hacks.needGalaxySAudioHack() || sLPref.useGalaxySHack())
|
|
||||||
setAudioModeIncallForGalaxyS();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mLc.acceptCall(call);
|
mLc.acceptCall(call);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0849cfcffa9bd30bdb30469afdfce513a86c149c
|
Subproject commit 1e75dc40229e1f8e6e5c6c121957722f11c03a3e
|
Loading…
Reference in a new issue