mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 08:47:46 +00:00
parent
58406d6b37
commit
aade4c7af3
@ -1,8 +1,13 @@
|
||||
package org.thoughtcrime.redphone.audio;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.DatagramSocket;
|
||||
@ -38,7 +43,13 @@ public class CallAudioManager {
|
||||
setMute(handle, enabled);
|
||||
}
|
||||
|
||||
public void start() throws AudioException {
|
||||
public void start(@NonNull Context context) throws AudioException {
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
ServiceUtil.getAudioManager(context).setMode(AudioManager.MODE_IN_COMMUNICATION);
|
||||
} else {
|
||||
ServiceUtil.getAudioManager(context).setMode(AudioManager.MODE_IN_CALL);
|
||||
}
|
||||
|
||||
try {
|
||||
start(handle);
|
||||
} catch (NativeAudioException | NoSuchMethodError e) {
|
||||
|
@ -127,6 +127,6 @@ public class InitiatingCallManager extends CallManager {
|
||||
masterSecret.getResponderMacKey(),
|
||||
masterSecret.getResponderSrtpSailt());
|
||||
this.callAudioManager.setMute(muteEnabled);
|
||||
this.callAudioManager.start();
|
||||
this.callAudioManager.start(context);
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public class ResponderCallManager extends CallManager {
|
||||
masterSecret.getInitiatorMacKey(),
|
||||
masterSecret.getInitiatorSrtpSalt());
|
||||
this.callAudioManager.setMute(muteEnabled);
|
||||
this.callAudioManager.start();
|
||||
this.callAudioManager.start(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.util;
|
||||
import android.app.Activity;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.view.WindowManager;
|
||||
@ -28,4 +29,8 @@ public class ServiceUtil {
|
||||
public static TelephonyManager getTelephonyManager(Context context) {
|
||||
return (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
}
|
||||
|
||||
public static AudioManager getAudioManager(Context context) {
|
||||
return (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user