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

This commit is contained in:
Guillaume Beraudo 2010-12-13 15:22:11 +01:00
commit a6bbf5ce94
11 changed files with 166 additions and 33 deletions

View file

@ -102,6 +102,7 @@
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
<uses-permission android:name="android.permission.BOOT_COMPLETED"></uses-permission> <uses-permission android:name="android.permission.BOOT_COMPLETED"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
</manifest> </manifest>

Binary file not shown.

Binary file not shown.

View file

@ -1,18 +1,31 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical"> android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <LinearLayout android:layout_width="wrap_content"
<EditText android:layout_height="wrap_content" android:id="@+id/AddressId" android:hint="sip:user@host:port" android:layout_width="fill_parent" android:layout_weight="1" android:text="sip:[user@]host[:port]"></EditText> android:layout_height="wrap_content">
<Button android:layout_height="wrap_content" android:id="@+id/CallButton" android:text="Call" android:layout_width="wrap_content"></Button> <EditText android:layout_height="wrap_content" android:id="@+id/AddressId"
android:hint="sip:user@host:port" android:layout_width="fill_parent"
android:layout_weight="1" android:text="sip:[user@]host[:port]"></EditText>
<Button android:layout_height="wrap_content" android:id="@+id/CallButton"
android:text="Call" android:layout_width="wrap_content"></Button>
</LinearLayout><EditText android:hint="password" android:id="@+id/Password" android:layout_width="fill_parent" android:layout_height="wrap_content" android:visibility="gone"></EditText> </LinearLayout>
<EditText android:layout_height="wrap_content" android:id="@+id/MyAddressId"
android:hint="enter my sip identity (sip:[user@]host)" android:layout_width="fill_parent"
android:visibility="gone" android:text=""></EditText>
<EditText android:hint="my password" android:id="@+id/Password"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:visibility="gone"></EditText>
<TextView android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/OutputText" android:text="Debug"></TextView> <TextView android:layout_weight="1" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/OutputText"
android:text="Debug"></TextView>
<Button android:text="STOP" android:id="@+id/ButtonStop" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button> <Button android:text="STOP" android:id="@+id/ButtonStop"
android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
</LinearLayout> </LinearLayout>

View file

@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
package org.linphone; package org.linphone;
import java.io.IOException;
import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneChatRoom; import org.linphone.core.LinphoneChatRoom;
@ -35,10 +37,15 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.Html; import android.text.Html;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -100,6 +107,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
private static String CURRENT_ADDRESS = "org.linphone.current-address"; private static String CURRENT_ADDRESS = "org.linphone.current-address";
private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname"; private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
Settings.System mSystemSettings = new Settings.System();
MediaPlayer mRingerPlayer;
LinphoneCall.State mCurrentCallState;
Vibrator mVibrator;
/** /**
* *
* @return null if not ready yet * @return null if not ready yet
@ -121,6 +132,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
setContentView(R.layout.dialer); setContentView(R.layout.dialer);
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE)); mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone"); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone");
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
@ -205,9 +217,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
getIntent().setData(null); getIntent().setData(null);
} }
if (LinphoneService.isready()) { if (LinphoneService.isready()) {
LinphoneCore lLinphoenCore = LinphoneService.instance().getLinphoneCore(); LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
if (lLinphoenCore.isIncall()) { if (lLinphoneCore.isIncall()) {
if(lLinphoenCore.isInComingInvitePending()) { mCurrentCallState = lLinphoneCore.getCurrentCall().getState();
if(lLinphoneCore.isInComingInvitePending()) {
callPending(); callPending();
} else { } else {
mCall.setEnabled(false); mCall.setEnabled(false);
@ -216,17 +229,17 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mInCallControlRow.setVisibility(View.VISIBLE); mInCallControlRow.setVisibility(View.VISIBLE);
mAddressLayout.setVisibility(View.GONE); mAddressLayout.setVisibility(View.GONE);
mInCallAddressLayout.setVisibility(View.VISIBLE); mInCallAddressLayout.setVisibility(View.VISIBLE);
mMute.setChecked(!lLinphoenCore.isMicMuted()); mMute.setChecked(!lLinphoneCore.isMicMuted());
mMute.setCompoundDrawablesWithIntrinsicBounds(0 mMute.setCompoundDrawablesWithIntrinsicBounds(0
, mMute.isChecked()?R.drawable.mic_active:R.drawable.mic_muted , mMute.isChecked()?R.drawable.mic_active:R.drawable.mic_muted
, 0 , 0
, 0); , 0);
String DisplayName = lLinphoenCore.getRemoteAddress().getDisplayName(); String DisplayName = lLinphoneCore.getRemoteAddress().getDisplayName();
if (DisplayName!=null) { if (DisplayName!=null) {
mDisplayNameView.setText(DisplayName); mDisplayNameView.setText(DisplayName);
} else { } else {
mDisplayNameView.setText(lLinphoenCore.getRemoteAddress().getUserName()); mDisplayNameView.setText(lLinphoneCore.getRemoteAddress().getUserName());
} }
if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getMode() == AudioManager.MODE_NORMAL) if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getMode() == AudioManager.MODE_NORMAL)
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) { || Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) {
@ -343,6 +356,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
// TODO Auto-generated method stub // TODO Auto-generated method stub
super.onDestroy(); super.onDestroy();
if (mWakeLock.isHeld()) mWakeLock.release(); if (mWakeLock.isHeld()) mWakeLock.release();
theDialer=null;
} }
@Override @Override
protected void onResume() { protected void onResume() {
@ -413,6 +427,10 @@ 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();
}
if (state == LinphoneCall.State.OutgoingInit) { if (state == LinphoneCall.State.OutgoingInit) {
mWakeLock.acquire(); mWakeLock.acquire();
enterIncalMode(lc); enterIncalMode(lc);
@ -431,6 +449,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
} else if (state == LinphoneCall.State.CallEnd) { } else if (state == LinphoneCall.State.CallEnd) {
exitCallMode(); exitCallMode();
} }
mCurrentCallState = state;
} }
public void show(LinphoneCore lc) { public void show(LinphoneCore lc) {
@ -498,6 +517,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
private void callPending() { private void callPending() {
mDecline.setEnabled(true); mDecline.setEnabled(true);
routeAudioToSpeaker(); routeAudioToSpeaker();
startRinging();
} }
public void newOutgoingCall(String aTo) { public void newOutgoingCall(String aTo) {
newOutgoingCall(aTo,null); newOutgoingCall(aTo,null);
@ -599,4 +619,38 @@ 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();
}
}
} }

View file

@ -48,11 +48,13 @@ 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.MediaPlayer;
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.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log; import android.util.Log;
public class LinphoneService extends Service implements LinphoneCoreListener { public class LinphoneService extends Service implements LinphoneCoreListener {
@ -78,6 +80,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
final int IC_LEVEL_ORANGE=0; final int IC_LEVEL_ORANGE=0;
final int IC_LEVEL_GREEN=1; final int IC_LEVEL_GREEN=1;
final int IC_LEVEL_RED=2; final int IC_LEVEL_RED=2;
private Handler mHandler = new Handler() ; private Handler mHandler = new Handler() ;
static boolean isready() { static boolean isready() {
@ -116,6 +119,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
, null); , null);
mLinphoneCore.setPlaybackGain(3); mLinphoneCore.setPlaybackGain(3);
mLinphoneCore.setRing(null);
try { try {
initFromConf(); initFromConf();
@ -236,22 +240,19 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
, mNofificationContentIntent); , mNofificationContentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mNotification); mNotificationManager.notify(NOTIFICATION_ID, mNotification);
} }
if (DialerActivity.getDialer()!=null) { mHandler.post(new Runnable() {
mHandler.post(new Runnable() { public void run() {
public void run() { if (DialerActivity.getDialer()!=null) DialerActivity.getDialer().registrationState(lc,cfg,state,smessage);
DialerActivity.getDialer().registrationState(lc,cfg,state,smessage); }
} });
});
}
} }
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 (DialerActivity.getDialer()!=null) { Log.i(TAG, "new state ["+state+"]");
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
DialerActivity.getDialer().callState(lc,call,state,message); if (DialerActivity.getDialer()!=null) DialerActivity.getDialer().callState(lc,call,state,message);
} }
}); });
}
if (state == LinphoneCall.State.IncomingReceived) { if (state == LinphoneCall.State.IncomingReceived) {
//wakeup linphone //wakeup linphone
Intent lIntent = new Intent(); Intent lIntent = new Intent();
@ -339,6 +340,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
//proxy //proxy
mLinphoneCore.clearProxyConfigs();
String lProxy = mPref.getString(getString(R.string.pref_proxy_key),null); String lProxy = mPref.getString(getString(R.string.pref_proxy_key),null);
if (lProxy == null || lProxy.length() == 0) { if (lProxy == null || lProxy.length() == 0) {
lProxy = "sip:"+lDomain; lProxy = "sip:"+lDomain;
@ -424,5 +426,6 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
} }
} }

View file

@ -58,6 +58,9 @@ class LinphoneCallImpl implements LinphoneCall {
public State getState() { public State getState() {
return LinphoneCall.State.fromInt(getState(nativePtr)); return LinphoneCall.State.fromInt(getState(nativePtr));
} }
public LinphoneCallParams getCurrentParamsReadOnly() {
throw new RuntimeException("Not Implemenetd yet");
}
} }

View file

@ -42,5 +42,9 @@ class LinphoneCallLogImpl implements LinphoneCallLog {
public LinphoneAddress getTo() { public LinphoneAddress getTo() {
return new LinphoneAddressImpl(getTo(nativePtr)); return new LinphoneAddressImpl(getTo(nativePtr));
} }
public CallStatus getStatus() {
// TODO Auto-generated method stub
return null;
}
} }

View file

@ -67,6 +67,8 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void addFriend(long nativePtr,long friend); private native void addFriend(long nativePtr,long friend);
private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status); private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status);
private native long createChatRoom(long nativePtr,String to); private native long createChatRoom(long nativePtr,String to);
private native void setRing(long nativePtr, String path);
private native String getRing(long nativePtr);
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
mListener=listener; mListener=listener;
@ -292,14 +294,56 @@ class LinphoneCoreImpl implements LinphoneCore {
public LinphoneChatRoom createChatRoom(String to) { public LinphoneChatRoom createChatRoom(String to) {
return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to)); return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to));
} }
public void setPreviewWindow(VideoWindow w) { public void setPreviewWindow(Object w) {
throw new RuntimeException("not implemented yet"); throw new RuntimeException("not implemented yet");
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void setVideoWindow(VideoWindow w) { public void setVideoWindow(Object w) {
throw new RuntimeException("not implemented yet"); throw new RuntimeException("not implemented yet");
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void enableVideo(boolean vcap_enabled, boolean display_enabled) {
// TODO Auto-generated method stub
}
public boolean isVideoEnabled() {
// TODO Auto-generated method stub
return false;
}
public void setStunServer(String stun_server) {
// TODO Auto-generated method stub
}
public String getStunServer() {
// TODO Auto-generated method stub
return null;
}
public void setFirewallPolicy(FirewallPolicy pol) {
// TODO Auto-generated method stub
}
public FirewallPolicy getFirewallPolicy() {
// TODO Auto-generated method stub
return null;
}
public void setRing(String path) {
setRing(nativePtr,path);
}
public String getRing() {
return getRing(nativePtr);
}
public LinphoneCall inviteAddressWithParams(LinphoneAddress destination,
LinphoneCallParams params) throws LinphoneCoreException {
throw new RuntimeException("Not Implemenetd yet");
}
public int updateCall(LinphoneCall call, LinphoneCallParams params) {
throw new RuntimeException("Not Implemenetd yet");
}
public LinphoneCallParams createDefaultCallParameters() {
throw new RuntimeException("Not Implemenetd yet");
}
} }

View file

@ -38,6 +38,9 @@ public class TutorialBuddyStatusActivity extends Activity {
private static final String defaultSipAddress = "sip:"; private static final String defaultSipAddress = "sip:";
private TextView sipAddressWidget; private TextView sipAddressWidget;
private TextView mySipAddressWidget;
private TextView mySipPasswordWidget;
private TutorialBuddyStatus tutorial; private TutorialBuddyStatus tutorial;
private Handler mHandler = new Handler() ; private Handler mHandler = new Handler() ;
private Button buttonCall; private Button buttonCall;
@ -49,6 +52,12 @@ public class TutorialBuddyStatusActivity extends Activity {
sipAddressWidget = (TextView) findViewById(R.id.AddressId); sipAddressWidget = (TextView) findViewById(R.id.AddressId);
sipAddressWidget.setText(defaultSipAddress); sipAddressWidget.setText(defaultSipAddress);
mySipAddressWidget = (TextView) findViewById(R.id.MyAddressId);
mySipAddressWidget.setVisibility(View.VISIBLE);
mySipPasswordWidget = (TextView) findViewById(R.id.Password);
mySipPasswordWidget.setVisibility(TextView.VISIBLE);
// Output text to the outputText widget // Output text to the outputText widget
final TextView outputText = (TextView) findViewById(R.id.OutputText); final TextView outputText = (TextView) findViewById(R.id.OutputText);
final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText);
@ -84,7 +93,9 @@ public class TutorialBuddyStatusActivity extends Activity {
public void run() { public void run() {
super.run(); super.run();
try { try {
tutorial.launchTutorial(sipAddressWidget.getText().toString()); String myIdentity = mySipAddressWidget.getText().length()>0?mySipAddressWidget.getText().toString():null;
String myPassword = mySipPasswordWidget.getText().length()>0?mySipPasswordWidget.getText().toString():null;
tutorial.launchTutorial(sipAddressWidget.getText().toString(), myIdentity, myPassword);
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
public void run() { public void run() {
buttonCall.setEnabled(true); buttonCall.setEnabled(true);

@ -1 +1 @@
Subproject commit 7db8fc8c965d7c482bec62d84c8030469f2fdef3 Subproject commit e559cf6defcc5e517f8116b314b399e8cec9a26d