mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-12 06:23:40 +00:00
parent
58406d6b37
commit
aade4c7af3
@ -1,8 +1,13 @@
|
|||||||
package org.thoughtcrime.redphone.audio;
|
package org.thoughtcrime.redphone.audio;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
@ -38,7 +43,13 @@ public class CallAudioManager {
|
|||||||
setMute(handle, enabled);
|
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 {
|
try {
|
||||||
start(handle);
|
start(handle);
|
||||||
} catch (NativeAudioException | NoSuchMethodError e) {
|
} catch (NativeAudioException | NoSuchMethodError e) {
|
||||||
|
@ -127,6 +127,6 @@ public class InitiatingCallManager extends CallManager {
|
|||||||
masterSecret.getResponderMacKey(),
|
masterSecret.getResponderMacKey(),
|
||||||
masterSecret.getResponderSrtpSailt());
|
masterSecret.getResponderSrtpSailt());
|
||||||
this.callAudioManager.setMute(muteEnabled);
|
this.callAudioManager.setMute(muteEnabled);
|
||||||
this.callAudioManager.start();
|
this.callAudioManager.start(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ public class ResponderCallManager extends CallManager {
|
|||||||
masterSecret.getInitiatorMacKey(),
|
masterSecret.getInitiatorMacKey(),
|
||||||
masterSecret.getInitiatorSrtpSalt());
|
masterSecret.getInitiatorSrtpSalt());
|
||||||
this.callAudioManager.setMute(muteEnabled);
|
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.Activity;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@ -28,4 +29,8 @@ public class ServiceUtil {
|
|||||||
public static TelephonyManager getTelephonyManager(Context context) {
|
public static TelephonyManager getTelephonyManager(Context context) {
|
||||||
return (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
|
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