Merge branch 'master' of git.linphone.org:linphone-android

This commit is contained in:
Guillaume Beraudo 2010-12-14 18:22:22 +01:00
commit 62a819b0ec
5 changed files with 67 additions and 47 deletions

View file

@ -74,7 +74,7 @@
android:dependency="@string/pref_video_enable_key"></CheckBoxPreference> android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_video_initiate_call_with_video_key" <CheckBoxPreference android:key="@string/pref_video_initiate_call_with_video_key"
android:defaultValue="false" android:defaultValue="true"
android:title="@string/pref_video_initiate_call_with_video_title" android:title="@string/pref_video_initiate_call_with_video_title"
android:summary="@string/pref_video_initiate_call_with_video" android:summary="@string/pref_video_initiate_call_with_video"
android:dependency="@string/pref_video_enable_key"></CheckBoxPreference> android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
@ -82,7 +82,7 @@
<CheckBoxPreference <CheckBoxPreference
android:key="@string/pref_video_automatically_share_my_video_key" android:key="@string/pref_video_automatically_share_my_video_key"
android:title="@string/pref_video_automatically_share_my_video_title" android:title="@string/pref_video_automatically_share_my_video_title"
android:defaultValue="false" android:summary="@string/pref_video_automatically_share_my_video" android:defaultValue="true" android:summary="@string/pref_video_automatically_share_my_video"
android:dependency="@string/pref_video_enable_key"></CheckBoxPreference> android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
<PreferenceScreen android:dependency="@string/pref_video_enable_key" <PreferenceScreen android:dependency="@string/pref_video_enable_key"
@ -90,7 +90,7 @@
android:title="@string/pref_video_codecs_title"> android:title="@string/pref_video_codecs_title">
<CheckBoxPreference android:key="@string/pref_video_codec_h264_key" <CheckBoxPreference android:key="@string/pref_video_codec_h264_key"
android:title="@string/pref_video_codec_h264_title" android:title="@string/pref_video_codec_h264_title"
android:defaultValue="true"></CheckBoxPreference> android:defaultValue="false"></CheckBoxPreference>
<CheckBoxPreference android:key="@string/pref_video_codec_mpeg4_key" <CheckBoxPreference android:key="@string/pref_video_codec_mpeg4_key"
android:title="@string/pref_video_codec_mpeg4_title" android:title="@string/pref_video_codec_mpeg4_title"
android:defaultValue="true"></CheckBoxPreference> android:defaultValue="true"></CheckBoxPreference>

View file

@ -108,7 +108,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
Settings.System mSystemSettings = new Settings.System(); Settings.System mSystemSettings = new Settings.System();
MediaPlayer mRingerPlayer; MediaPlayer mRingerPlayer;
LinphoneCall.State mCurrentCallState;
Vibrator mVibrator; Vibrator mVibrator;
/** /**
@ -236,7 +236,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
if (LinphoneService.isready()) { if (LinphoneService.isready()) {
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
if (lLinphoneCore.isIncall()) { if (lLinphoneCore.isIncall()) {
mCurrentCallState = lLinphoneCore.getCurrentCall().getState();
if(lLinphoneCore.isInComingInvitePending()) { if(lLinphoneCore.isInComingInvitePending()) {
callPending(lLinphoneCore.getCurrentCall()); callPending(lLinphoneCore.getCurrentCall());
} else { } else {
@ -448,11 +447,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig cfg,final LinphoneCore.RegistrationState state,final String smessage) {/*nop*/}; public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig cfg,final LinphoneCore.RegistrationState state,final String smessage) {/*nop*/};
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) { public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
if (mCurrentCallState == LinphoneCall.State.IncomingReceived) {
//previous state was ringing, so stop ringing
stoptRinging();
//routeAudioToReceiver();
}
if (state == LinphoneCall.State.OutgoingInit) { if (state == LinphoneCall.State.OutgoingInit) {
mWakeLock.acquire(); mWakeLock.acquire();
enterIncalMode(lc); enterIncalMode(lc);
@ -478,7 +473,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
} }
} }
} }
mCurrentCallState = state;
} }
public void show(LinphoneCore lc) { public void show(LinphoneCore lc) {
@ -576,7 +571,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
boolean prefAutomaticallyShareMyCamera = mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false); boolean prefAutomaticallyShareMyCamera = mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false);
getVideoManager().setMuted(!(prefVideoEnable && prefAutomaticallyShareMyCamera)); getVideoManager().setMuted(!(prefVideoEnable && prefAutomaticallyShareMyCamera));
call.enableCamera(prefAutomaticallyShareMyCamera); call.enableCamera(prefAutomaticallyShareMyCamera);
startRinging();
} }
public void newOutgoingCall(String aTo) { public void newOutgoingCall(String aTo) {
newOutgoingCall(aTo,null); newOutgoingCall(aTo,null);
@ -685,39 +679,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
private synchronized void startRinging() {
try {
if (mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER) && mVibrator !=null) {
long[] patern = {0,1000,1000};
mVibrator.vibrate(patern, 1);
}
if (mRingerPlayer == null) {
//mRingerPlayer = MediaPlayer.create(getApplicationContext(), RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
mRingerPlayer = new MediaPlayer();
mRingerPlayer.setAudioStreamType(AudioManager.STREAM_RING);
mRingerPlayer.setDataSource(getApplicationContext(), RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
mRingerPlayer.prepare();
//mRingerPlayer.setVolume(mAudioManager.getStreamVolume(AudioManager.STREAM_RING),mAudioManager.getStreamVolume(AudioManager.STREAM_RING));
mRingerPlayer.setLooping(true);
mRingerPlayer.start();
} else {
Log.w(LinphoneService.TAG,"already ringing");
}
} catch (Exception e) {
Log.e(LinphoneService.TAG, "cannot handle incoming call",e);
}
}
private synchronized void stoptRinging() {
if (mRingerPlayer !=null) {
mRingerPlayer.stop();
mRingerPlayer.release();
mRingerPlayer=null;
}
if (mVibrator!=null) {
mVibrator.cancel();
}
}
private AndroidCameraRecordManager getVideoManager() { private AndroidCameraRecordManager getVideoManager() {
return AndroidCameraRecordManager.getInstance(); return AndroidCameraRecordManager.getInstance();

View file

@ -145,7 +145,7 @@ public class LinphoneActivity extends TabActivity {
} else { } else {
mAudioManager.setSpeakerphoneOn(false); mAudioManager.setSpeakerphoneOn(false);
} }
stopProxymitySensor();//just in case
theLinphoneActivity = null; theLinphoneActivity = null;
} }
@ -249,9 +249,9 @@ public class LinphoneActivity extends TabActivity {
//Log.d(LinphoneService.TAG, "Proximity sensor report ["+event.values[0]+"] , for max range ["+event.sensor.getMaximumRange()+"]"); //Log.d(LinphoneService.TAG, "Proximity sensor report ["+event.values[0]+"] , for max range ["+event.sensor.getMaximumRange()+"]");
if (event.values[0] != event.sensor.getMaximumRange() ) { if (event.values[0] != event.sensor.getMaximumRange() ) {
LinphoneActivity.instance().hideScreen(true); hideScreen(true);
} else { } else {
LinphoneActivity.instance().hideScreen(false); hideScreen(false);
} }
} }

View file

@ -47,10 +47,15 @@ import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.RingtoneManager;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.PowerManager;
import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
@ -78,6 +83,10 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
final int IC_LEVEL_GREEN=1; final int IC_LEVEL_GREEN=1;
final int IC_LEVEL_RED=2; final int IC_LEVEL_RED=2;
MediaPlayer mRingerPlayer;
LinphoneCall.State mCurrentCallState;
Vibrator mVibrator;
private AudioManager mAudioManager;
private Handler mHandler = new Handler() ; private Handler mHandler = new Handler() ;
static boolean isready() { static boolean isready() {
@ -107,6 +116,8 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
mNotification.setLatestEventInfo(this, NOTIFICATION_TITLE,"", mNofificationContentIntent); mNotification.setLatestEventInfo(this, NOTIFICATION_TITLE,"", mNofificationContentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mNotification); mNotificationManager.notify(NOTIFICATION_ID, mNotification);
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
try { try {
copyAssetsFromPackage(); copyAssetsFromPackage();
@ -246,6 +257,11 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
} }
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) { public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
Log.i(TAG, "new state ["+state+"]"); Log.i(TAG, "new state ["+state+"]");
if (state == LinphoneCall.State.IncomingReceived && !call.equals(mLinphoneCore.getCurrentCall())) {
//no multicall support, just decline
mLinphoneCore.terminateCall(call);
return;
}
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
if (DialerActivity.getDialer()!=null) DialerActivity.getDialer().callState(lc,call,state,message); if (DialerActivity.getDialer()!=null) DialerActivity.getDialer().callState(lc,call,state,message);
@ -257,7 +273,14 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
lIntent.setClass(this, LinphoneActivity.class); lIntent.setClass(this, LinphoneActivity.class);
startActivity(lIntent); startActivity(lIntent);
startRinging();
} }
if (mCurrentCallState == LinphoneCall.State.IncomingReceived) {
//previous state was ringing, so stop ringing
stopRinging();
//routeAudioToReceiver();
}
mCurrentCallState=state;
} }
public void show(LinphoneCore lc) { public void show(LinphoneCore lc) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -439,5 +462,36 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
return instance().getLinphoneCore(); return instance().getLinphoneCore();
} }
private synchronized void startRinging() {
try {
if (mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER) && mVibrator !=null) {
long[] patern = {0,1000,1000};
mVibrator.vibrate(patern, 1);
}
if (mRingerPlayer == null) {
mRingerPlayer = new MediaPlayer();
mRingerPlayer.setAudioStreamType(AudioManager.STREAM_RING);
mRingerPlayer.setDataSource(getApplicationContext(), RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
mRingerPlayer.prepare();
mRingerPlayer.setLooping(true);
mRingerPlayer.start();
} else {
Log.w(LinphoneService.TAG,"already ringing");
}
} catch (Exception e) {
Log.e(LinphoneService.TAG, "cannot handle incoming call",e);
}
}
private synchronized void stopRinging() {
if (mRingerPlayer !=null) {
mRingerPlayer.stop();
mRingerPlayer.release();
mRingerPlayer=null;
}
if (mVibrator!=null) {
mVibrator.cancel();
}
}
} }

View file

@ -31,6 +31,7 @@ class LinphoneCallImpl implements LinphoneCall {
native private int getState(long nativePtr); native private int getState(long nativePtr);
private native long getCurrentParamsCopy(long nativePtr); private native long getCurrentParamsCopy(long nativePtr);
private native void enableCamera(long nativePtr, boolean enabled); private native void enableCamera(long nativePtr, boolean enabled);
protected LinphoneCallImpl(long aNativePtr) { protected LinphoneCallImpl(long aNativePtr) {
nativePtr = aNativePtr; nativePtr = aNativePtr;
@ -68,4 +69,7 @@ class LinphoneCallImpl implements LinphoneCall {
public void enableCamera(boolean enabled) { public void enableCamera(boolean enabled) {
enableCamera(nativePtr, enabled); enableCamera(nativePtr, enabled);
} }
public boolean equals(Object call) {
return nativePtr == ((LinphoneCallImpl)call).nativePtr;
}
} }