use default ring file instead of oldring.wav
This commit is contained in:
parent
008c73783a
commit
4e7ae1bc8f
9 changed files with 122 additions and 21 deletions
|
@ -102,6 +102,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>
|
||||
|
||||
|
||||
</manifest>
|
||||
|
|
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.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
|
@ -35,10 +37,15 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
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;
|
||||
|
@ -100,6 +107,10 @@ 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";
|
||||
|
||||
Settings.System mSystemSettings = new Settings.System();
|
||||
MediaPlayer mRingerPlayer;
|
||||
LinphoneCall.State mCurrentCallState;
|
||||
Vibrator mVibrator;
|
||||
/**
|
||||
*
|
||||
* @return null if not ready yet
|
||||
|
@ -121,6 +132,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());
|
||||
|
||||
|
@ -205,9 +217,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
getIntent().setData(null);
|
||||
}
|
||||
if (LinphoneService.isready()) {
|
||||
LinphoneCore lLinphoenCore = LinphoneService.instance().getLinphoneCore();
|
||||
if (lLinphoenCore.isIncall()) {
|
||||
if(lLinphoenCore.isInComingInvitePending()) {
|
||||
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
|
||||
if (lLinphoneCore.isIncall()) {
|
||||
mCurrentCallState = lLinphoneCore.getCurrentCall().getState();
|
||||
if(lLinphoneCore.isInComingInvitePending()) {
|
||||
callPending();
|
||||
} else {
|
||||
mCall.setEnabled(false);
|
||||
|
@ -216,17 +229,17 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
mInCallControlRow.setVisibility(View.VISIBLE);
|
||||
mAddressLayout.setVisibility(View.GONE);
|
||||
mInCallAddressLayout.setVisibility(View.VISIBLE);
|
||||
mMute.setChecked(!lLinphoenCore.isMicMuted());
|
||||
mMute.setChecked(!lLinphoneCore.isMicMuted());
|
||||
mMute.setCompoundDrawablesWithIntrinsicBounds(0
|
||||
, mMute.isChecked()?R.drawable.mic_active:R.drawable.mic_muted
|
||||
, 0
|
||||
, 0);
|
||||
|
||||
String DisplayName = lLinphoenCore.getRemoteAddress().getDisplayName();
|
||||
String DisplayName = lLinphoneCore.getRemoteAddress().getDisplayName();
|
||||
if (DisplayName!=null) {
|
||||
mDisplayNameView.setText(DisplayName);
|
||||
} else {
|
||||
mDisplayNameView.setText(lLinphoenCore.getRemoteAddress().getUserName());
|
||||
mDisplayNameView.setText(lLinphoneCore.getRemoteAddress().getUserName());
|
||||
}
|
||||
if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getMode() == AudioManager.MODE_NORMAL)
|
||||
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) {
|
||||
|
@ -343,6 +356,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() {
|
||||
|
@ -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 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);
|
||||
|
@ -431,6 +449,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
} else if (state == LinphoneCall.State.CallEnd) {
|
||||
exitCallMode();
|
||||
}
|
||||
mCurrentCallState = state;
|
||||
}
|
||||
|
||||
public void show(LinphoneCore lc) {
|
||||
|
@ -498,6 +517,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
private void callPending() {
|
||||
mDecline.setEnabled(true);
|
||||
routeAudioToSpeaker();
|
||||
startRinging();
|
||||
}
|
||||
public void newOutgoingCall(String aTo) {
|
||||
newOutgoingCall(aTo,null);
|
||||
|
@ -599,4 +619,38 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,11 +48,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 {
|
||||
|
@ -78,6 +80,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() {
|
||||
|
@ -116,6 +119,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
, null);
|
||||
|
||||
mLinphoneCore.setPlaybackGain(3);
|
||||
mLinphoneCore.setRing(null);
|
||||
|
||||
try {
|
||||
initFromConf();
|
||||
|
@ -236,22 +240,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();
|
||||
|
@ -339,6 +340,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;
|
||||
|
@ -424,5 +426,6 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,9 @@ class LinphoneCallImpl implements LinphoneCall {
|
|||
public State getState() {
|
||||
return LinphoneCall.State.fromInt(getState(nativePtr));
|
||||
}
|
||||
public LinphoneCallParams getCurrentParamsReadOnly() {
|
||||
throw new RuntimeException("Not Implemenetd yet");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -42,5 +42,9 @@ class LinphoneCallLogImpl implements LinphoneCallLog {
|
|||
public LinphoneAddress getTo() {
|
||||
return new LinphoneAddressImpl(getTo(nativePtr));
|
||||
}
|
||||
public CallStatus getStatus() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native void addFriend(long nativePtr,long friend);
|
||||
private native void setPresenceInfo(long nativePtr,int minute_away, String alternative_contact,int status);
|
||||
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 {
|
||||
mListener=listener;
|
||||
|
@ -309,5 +311,39 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
// 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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2d03d1603176079b550746e5615d0a872ee07407
|
||||
Subproject commit a9db49b15aee38098d23086fd574adb99a1afda3
|
Loading…
Reference in a new issue