* #32664: volume STREAM_IN_COMMUNICATION
diff --git a/src/org/sflphone/service/SipService.java b/src/org/sflphone/service/SipService.java
index 7d8eb66..5ff7981 100644
--- a/src/org/sflphone/service/SipService.java
+++ b/src/org/sflphone/service/SipService.java
@@ -53,6 +53,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
@@ -63,7 +64,6 @@
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
-import android.widget.Toast;
public class SipService extends Service {
@@ -149,7 +149,6 @@
LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver);
notificationManager.onServiceDestroy();
// sflphoneApp.setServiceRunning(false);
-
getExecutor().execute(new FinalizeRunnable());
super.onDestroy();
@@ -212,11 +211,11 @@
}
}
}
-
- private void stopDaemon(){
- if(managerImpl != null){
- managerImpl.finish();
- isPjSipStackStarted = false;
+
+ private void stopDaemon() {
+ if (managerImpl != null) {
+ managerImpl.finish();
+ isPjSipStackStarted = false;
}
}
@@ -259,7 +258,7 @@
managerImpl = SFLPhoneservice.instance();
/* set static AppPath before calling manager.init */
-// managerImpl.setPath(getApplication().getFilesDir().getAbsolutePath());
+ // managerImpl.setPath(getApplication().getFilesDir().getAbsolutePath());
callManagerJNI = new CallManager();
callManagerCallBack = new CallManagerCallBack(this);
@@ -332,7 +331,7 @@
startPjSipStack();
}
}
-
+
class FinalizeRunnable extends SipRunnable {
@Override
protected void doRun() throws SameThreadException {
@@ -361,7 +360,7 @@
// watchout timestamp stored by sflphone is in seconds
call.setTimestamp_start(Long.parseLong(details.get(ServiceConstants.call.TIMESTAMP_START)));
getCurrent_calls().put(call.getCallId(), call);
-
+ mediaManager.getAudioManager().setMode(AudioManager.MODE_IN_COMMUNICATION);
}
});
}
@@ -1264,23 +1263,4 @@
}
};
-
- public void changeVolume(int currentVolume) {
- // StringVect resultsInput = configurationManagerJNI.getAudioInputDeviceList();
- // StringVect resultsOutput = configurationManagerJNI.getAudioOutputDeviceList();
- //
- // Log.i(TAG, "------------------> INPUT DEVICES");
- // for(int i = 0 ; i < resultsInput.size(); ++i){
- // Log.i(TAG, resultsInput.get(i));
- // }
- //
- // Log.i(TAG, "------------------> OUTPUT DEVICES");
- // for(int i = 0 ; i < resultsOutput.size(); ++i){
- // Log.i(TAG, resultsOutput.get(i));
- // }
-
- // Log.i(TAG,"AudioManager ------------> "+configurationManagerJNI.getAudioManager());
-
- callManagerJNI.setVolume("speaker", currentVolume);
- }
-}
+}
diff --git a/src/org/sflphone/utils/MediaManager.java b/src/org/sflphone/utils/MediaManager.java
index a38411b..6ec6044 100644
--- a/src/org/sflphone/utils/MediaManager.java
+++ b/src/org/sflphone/utils/MediaManager.java
@@ -2,6 +2,8 @@
import org.sflphone.service.SipService;
+import android.content.Context;
+import android.media.AudioManager;
import android.os.Handler;
import android.util.Log;
@@ -10,10 +12,12 @@
private static final String TAG = MediaManager.class.getSimpleName();
private SipService mService;
private SettingsContentObserver mSettingsContentObserver;
+ AudioManager mAudioManager;
public MediaManager(SipService aService) {
mService = aService;
mSettingsContentObserver = new SettingsContentObserver(mService, new Handler());
+ mAudioManager = (AudioManager) aService.getSystemService(Context.AUDIO_SERVICE);
}
public void startService() {
@@ -26,4 +30,8 @@
mService.getApplicationContext().getContentResolver().unregisterContentObserver(mSettingsContentObserver);
}
+ public AudioManager getAudioManager() {
+ return mAudioManager;
+ }
+
}
diff --git a/src/org/sflphone/utils/SettingsContentObserver.java b/src/org/sflphone/utils/SettingsContentObserver.java
index c3ddfdd..de3077d 100644
--- a/src/org/sflphone/utils/SettingsContentObserver.java
+++ b/src/org/sflphone/utils/SettingsContentObserver.java
@@ -9,20 +9,14 @@
import android.util.Log;
public class SettingsContentObserver extends ContentObserver {
- int previousVolume;
+ double previousVolume;
SipService context;
private static final String TAG = "Settings";
public SettingsContentObserver(SipService c, Handler handler) {
super(handler);
- context=c;
-
-
-
+ context=c;
AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
-
- Log.i(TAG,"audio mode: "+audio.getMode());
-
previousVolume = audio.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
}
@@ -36,21 +30,21 @@
super.onChange(selfChange);
AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
- int currentVolume = audio.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
+ double currentVolume = audio.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
- int delta=previousVolume-currentVolume;
+ double delta=previousVolume-currentVolume;
if(delta>0)
{
Log.d(TAG,"Decreased");
previousVolume=currentVolume;
- context.changeVolume(currentVolume);
+// context.changeVolume(currentVolume);
}
else if(delta<0)
{
Log.d(TAG,"Increased");
previousVolume=currentVolume;
- context.changeVolume(currentVolume);
+// context.changeVolume(currentVolume);
}
}
}