Merge remote branch 'bc/master' into video
This commit is contained in:
commit
c95431295d
12 changed files with 87 additions and 24 deletions
|
@ -113,6 +113,7 @@
|
|||
<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.BOOT_COMPLETED"></uses-permission>
|
||||
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
package org.linphone;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.linphone.component.ToggleImageButton;
|
||||
import org.linphone.component.ToggleImageButton.OnCheckedChangeListener;
|
||||
import org.linphone.core.AndroidCameraRecord;
|
||||
|
@ -39,10 +41,15 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -101,6 +108,11 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
private static String CURRENT_ADDRESS = "org.linphone.current-address";
|
||||
private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
|
||||
static int VIDEO_VIEW_ACTIVITY = 100;
|
||||
|
||||
Settings.System mSystemSettings = new Settings.System();
|
||||
MediaPlayer mRingerPlayer;
|
||||
LinphoneCall.State mCurrentCallState;
|
||||
Vibrator mVibrator;
|
||||
/**
|
||||
*
|
||||
* @return null if not ready yet
|
||||
|
@ -122,6 +134,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
setContentView(R.layout.dialer);
|
||||
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_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");
|
||||
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
|
||||
|
@ -223,6 +236,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
if (LinphoneService.isready()) {
|
||||
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
|
||||
if (lLinphoneCore.isIncall()) {
|
||||
mCurrentCallState = lLinphoneCore.getCurrentCall().getState();
|
||||
if(lLinphoneCore.isInComingInvitePending()) {
|
||||
callPending();
|
||||
} else {
|
||||
|
@ -348,6 +362,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
// TODO Auto-generated method stub
|
||||
super.onDestroy();
|
||||
if (mWakeLock.isHeld()) mWakeLock.release();
|
||||
theDialer=null;
|
||||
}
|
||||
@Override
|
||||
protected void onResume() {
|
||||
|
@ -426,6 +441,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 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) {
|
||||
mWakeLock.acquire();
|
||||
enterIncalMode(lc);
|
||||
|
@ -448,6 +467,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
startVideoView();
|
||||
}
|
||||
}
|
||||
mCurrentCallState = state;
|
||||
}
|
||||
|
||||
public void show(LinphoneCore lc) {
|
||||
|
@ -523,6 +543,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
boolean prefVideoEnable = getPref(getApplicationContext().getString(R.string.pref_video_enable_key));
|
||||
boolean prefAutomaticallyShareMyCamera = getPref(getApplicationContext().getString(R.string.pref_video_automatically_share_my_video_key));
|
||||
AndroidCameraRecord.setMuteCamera(!(prefVideoEnable && prefAutomaticallyShareMyCamera));
|
||||
startRinging();
|
||||
}
|
||||
public void newOutgoingCall(String aTo) {
|
||||
newOutgoingCall(aTo,null);
|
||||
|
@ -640,5 +661,39 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -49,11 +49,13 @@ import android.app.Service;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||
|
@ -79,6 +81,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
final int IC_LEVEL_ORANGE=0;
|
||||
final int IC_LEVEL_GREEN=1;
|
||||
final int IC_LEVEL_RED=2;
|
||||
|
||||
|
||||
private Handler mHandler = new Handler() ;
|
||||
static boolean isready() {
|
||||
|
@ -117,6 +120,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
, null);
|
||||
|
||||
mLinphoneCore.setPlaybackGain(3);
|
||||
mLinphoneCore.setRing(null);
|
||||
|
||||
try {
|
||||
initFromConf();
|
||||
|
@ -237,22 +241,19 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
, mNofificationContentIntent);
|
||||
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
|
||||
}
|
||||
if (DialerActivity.getDialer()!=null) {
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
DialerActivity.getDialer().registrationState(lc,cfg,state,smessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
if (DialerActivity.getDialer()!=null) DialerActivity.getDialer().registrationState(lc,cfg,state,smessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
|
||||
if (DialerActivity.getDialer()!=null) {
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
DialerActivity.getDialer().callState(lc,call,state,message);
|
||||
}
|
||||
});
|
||||
}
|
||||
Log.i(TAG, "new state ["+state+"]");
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
if (DialerActivity.getDialer()!=null) DialerActivity.getDialer().callState(lc,call,state,message);
|
||||
}
|
||||
});
|
||||
if (state == LinphoneCall.State.IncomingReceived) {
|
||||
//wakeup linphone
|
||||
Intent lIntent = new Intent();
|
||||
|
@ -347,6 +348,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
|
||||
|
||||
//proxy
|
||||
mLinphoneCore.clearProxyConfigs();
|
||||
String lProxy = mPref.getString(getString(R.string.pref_proxy_key),null);
|
||||
if (lProxy == null || lProxy.length() == 0) {
|
||||
lProxy = "sip:"+lDomain;
|
||||
|
@ -432,5 +434,6 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,8 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native long createDefaultCallParams(long nativePtr);
|
||||
private native int updateCall(long ptrLc, long ptrCall, long ptrParams);
|
||||
|
||||
private native void setRing(long nativePtr, String path);
|
||||
private native String getRing(long nativePtr);
|
||||
|
||||
private static String TAG = "LinphoneCore";
|
||||
|
||||
|
@ -379,4 +381,10 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
|
||||
return updateCall(nativePtr, ptrCall, ptrParams);
|
||||
}
|
||||
public void setRing(String path) {
|
||||
setRing(nativePtr, path);
|
||||
}
|
||||
public String getRing() {
|
||||
return getRing(nativePtr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
package org.linphone.core;
|
||||
|
||||
import org.linphone.LinphoneService;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
|
||||
|
@ -35,7 +32,6 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
setProxy(proxy);
|
||||
enableRegister(enableRegister);
|
||||
ownPtr=true;
|
||||
Log.w(LinphoneService.TAG, "route ["+route+"] not used yet");
|
||||
}
|
||||
protected LinphoneProxyConfigImpl(long aNativePtr) {
|
||||
nativePtr = aNativePtr;
|
||||
|
|
|
@ -36,7 +36,7 @@ import android.widget.TextView;
|
|||
*/
|
||||
public class TutorialBuddyStatusActivity extends Activity {
|
||||
|
||||
private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059";
|
||||
private static final String defaultSipAddress = "sip:";
|
||||
private TextView sipAddressWidget;
|
||||
private TutorialBuddyStatus tutorial;
|
||||
private Handler mHandler = new Handler() ;
|
||||
|
|
|
@ -36,7 +36,7 @@ import android.widget.TextView;
|
|||
*/
|
||||
public class TutorialChatRoomActivity extends Activity {
|
||||
|
||||
private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059";
|
||||
private static final String defaultSipAddress = "sip:";
|
||||
private TextView sipAddressWidget;
|
||||
private TutorialChatRoom tutorial;
|
||||
private Handler mHandler = new Handler() ;
|
||||
|
|
|
@ -36,7 +36,7 @@ import android.widget.TextView;
|
|||
*/
|
||||
public class TutorialHelloWorldActivity extends Activity {
|
||||
|
||||
private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059";
|
||||
private static final String defaultSipAddress = "sip:";
|
||||
private TextView sipAddressWidget;
|
||||
private TutorialHelloWorld tutorial;
|
||||
private Handler mHandler = new Handler() ;
|
||||
|
|
|
@ -35,8 +35,8 @@ import android.widget.TextView;
|
|||
*/
|
||||
public class TutorialRegistrationActivity extends TutorialHelloWorldActivity {
|
||||
|
||||
private static final String defaultSipAddress = "sip:8182449901ip@mty11.axtel.net";
|
||||
private static final String defaultSipPassword = "49901";
|
||||
private static final String defaultSipAddress = "sip:";
|
||||
private static final String defaultSipPassword = "";
|
||||
private TextView sipAddressWidget;
|
||||
private TextView sipPasswordWidget;
|
||||
private TutorialRegistration tutorial;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 801508597b36e02e6d726851332a202529dc9025
|
||||
Subproject commit a9db49b15aee38098d23086fd574adb99a1afda3
|
Loading…
Reference in a new issue