diff --git a/Makefile b/Makefile index 4137a808c..f3053b233 100644 --- a/Makefile +++ b/Makefile @@ -338,24 +338,12 @@ run-linphone: ant run run-basic-tests: - ant partial-clean && \ - $(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone.test - $(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone - @cd $(TOPDIR)/tests/ && \ - $(SDK_PATH)/android update test-project --path . -m ../ && \ - ant debug && \ - ant installd && \ - adb shell am instrument -w -e size small org.linphone.test/android.test.InstrumentationTestRunner + ant partial-clean + $(MAKE) -C tests run-all-tests: - ant partial-clean && \ - $(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone.test - $(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone - @cd $(TOPDIR)/tests/ && \ - $(SDK_PATH)/android update test-project --path . -m ../ && \ - ant debug && \ - ant installd && \ - adb shell am instrument -w -e size large org.linphone.test/android.test.InstrumentationTestRunner + ant partial-clean + $(MAKE) -C tests clean-ndk-build: $(NDK_PATH)/ndk-build clean $(LIBLINPHONE_OPTIONS) diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index f959d143a..bfd7ea9f9 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -26,6 +26,7 @@ import static org.linphone.core.LinphoneCall.State.Error; import static org.linphone.core.LinphoneCall.State.IncomingReceived; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -95,6 +96,7 @@ import android.media.AudioManager; import android.media.MediaPlayer; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.net.Uri; import android.os.Build; import android.os.PowerManager; import android.os.PowerManager.WakeLock; @@ -201,7 +203,7 @@ public class LinphoneManager implements LinphoneCoreListener { //Compatibility.setAudioManagerInCallMode(mAudioManager); mAudioManager.stopBluetoothSco(); mAudioManager.setBluetoothScoOn(false); - mBluetoothStarted=false; + mBluetoothStarted = false; } if (!speakerOn) { @@ -579,7 +581,7 @@ public class LinphoneManager implements LinphoneCoreListener { mLc.setZrtpSecretsCache(basePath + "/zrtp_secrets"); - mLc.setRing(mPrefs.getRingtone(null)); + mLc.setRing(null); mLc.setRootCA(mLinphoneRootCaFile); mLc.setPlayFile(mPauseSoundFile); mLc.setChatDatabasePath(mChatDatabaseFile); @@ -608,9 +610,9 @@ public class LinphoneManager implements LinphoneCoreListener { } private void copyAssetsFromPackage() throws IOException { - copyIfNotExist(R.raw.oldphone_mono,mRingSoundFile); - copyIfNotExist(R.raw.ringback,mRingbackSoundFile); - copyIfNotExist(R.raw.toy_mono,mPauseSoundFile); + copyIfNotExist(R.raw.oldphone_mono, mRingSoundFile); + copyIfNotExist(R.raw.ringback, mRingbackSoundFile); + copyIfNotExist(R.raw.toy_mono, mPauseSoundFile); copyIfNotExist(R.raw.linphonerc_default, mLinphoneConfigFile); copyFromPackage(R.raw.linphonerc_factory, new File(mLinphoneFactoryConfigFile).getName()); copyIfNotExist(R.raw.lpconfig, mLPConfigXsd); @@ -1007,14 +1009,14 @@ public class LinphoneManager implements LinphoneCoreListener { private void requestAudioFocus(){ if (!mAudioFocused){ - int res=mAudioManager.requestAudioFocus(null, AudioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT ); + int res = mAudioManager.requestAudioFocus(null, AudioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT ); Log.d("Audio focus requested: " + (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED ? "Granted" : "Denied")); - if (res==AudioManager.AUDIOFOCUS_REQUEST_GRANTED) mAudioFocused=true; + if (res == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) mAudioFocused=true; } } private synchronized void startRinging() { - if (disableRinging ) { + if (disableRinging) { return; } @@ -1023,7 +1025,7 @@ public class LinphoneManager implements LinphoneCoreListener { } try { - if ((mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE || mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) && mVibrator !=null) { + if ((mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE || mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) && mVibrator != null) { long[] patern = {0,1000,1000}; mVibrator.vibrate(patern, 1); } @@ -1031,7 +1033,20 @@ public class LinphoneManager implements LinphoneCoreListener { requestAudioFocus(); mRingerPlayer = new MediaPlayer(); mRingerPlayer.setAudioStreamType(STREAM_RING); - mListenerDispatcher.onRingerPlayerCreated(mRingerPlayer); + + String ringtone = LinphonePreferences.instance().getRingtone(android.provider.Settings.System.DEFAULT_RINGTONE_URI.toString()); + try { + if (ringtone.startsWith("content://")) { + mRingerPlayer.setDataSource(mServiceContext, Uri.parse(ringtone)); + } else { + FileInputStream fis = new FileInputStream(ringtone); + mRingerPlayer.setDataSource(fis.getFD()); + fis.close(); + } + } catch (IOException e) { + Log.e(e, "Cannot set ringtone"); + } + mRingerPlayer.prepare(); mRingerPlayer.setLooping(true); mRingerPlayer.start(); @@ -1045,12 +1060,12 @@ public class LinphoneManager implements LinphoneCoreListener { } private synchronized void stopRinging() { - if (mRingerPlayer !=null) { + if (mRingerPlayer != null) { mRingerPlayer.stop(); mRingerPlayer.release(); - mRingerPlayer=null; + mRingerPlayer = null; } - if (mVibrator!=null) { + if (mVibrator != null) { mVibrator.cancel(); } @@ -1297,10 +1312,6 @@ public class LinphoneManager implements LinphoneCoreListener { } } - public void onRingerPlayerCreated(MediaPlayer mRingerPlayer) { - if (serviceListener != null) serviceListener.onRingerPlayerCreated(mRingerPlayer); - } - public void tryingNewOutgoingCallButAlreadyInCall() { if (serviceListener != null) serviceListener.tryingNewOutgoingCallButAlreadyInCall(); } diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java index 49e2854b2..9bfa01306 100644 --- a/src/org/linphone/LinphoneService.java +++ b/src/org/linphone/LinphoneService.java @@ -18,8 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone; -import java.io.FileInputStream; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -51,7 +49,6 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.media.MediaPlayer; import android.net.Uri; import android.net.wifi.WifiManager; import android.net.wifi.WifiManager.WifiLock; @@ -611,21 +608,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis void onCallStateChanged(LinphoneCall call, State state, String message); } - public void onRingerPlayerCreated(MediaPlayer mRingerPlayer) { - String uriString = LinphonePreferences.instance().getRingtone(android.provider.Settings.System.DEFAULT_RINGTONE_URI.toString()); - try { - if (uriString.startsWith("content://")) { - mRingerPlayer.setDataSource(this, Uri.parse(uriString)); - } else { - FileInputStream fis = new FileInputStream(uriString); - mRingerPlayer.setDataSource(fis.getFD()); - fis.close(); - } - } catch (IOException e) { - Log.e(e, "Cannot set ringtone"); - } - } - public void tryingNewOutgoingCallButAlreadyInCall() { mHandler.post(new Runnable() { public void run() { diff --git a/src/org/linphone/LinphoneSimpleListener.java b/src/org/linphone/LinphoneSimpleListener.java index 7864a20ba..cd503d7af 100644 --- a/src/org/linphone/LinphoneSimpleListener.java +++ b/src/org/linphone/LinphoneSimpleListener.java @@ -26,7 +26,6 @@ import org.linphone.core.LinphoneCore.GlobalState; import org.linphone.core.LinphoneCore.RegistrationState; import android.content.Context; -import android.media.MediaPlayer; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -41,7 +40,6 @@ public interface LinphoneSimpleListener { void tryingNewOutgoingCallButWrongDestinationAddress(); void tryingNewOutgoingCallButAlreadyInCall(); void onRegistrationStateChanged(RegistrationState state, String message); - void onRingerPlayerCreated(MediaPlayer mRingerPlayer); void onDisplayStatus(String message); } diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 000000000..cdc238939 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,18 @@ +SDK_PATH=$(shell dirname `which android`) +SDK_PLATFORM_TOOLS_PATH=$(shell dirname `which adb`) + +run-basic-tests: + $(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone.test + $(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone + $(SDK_PATH)/android update test-project --path . -m ../ + ant debug + ant installd + adb shell am instrument -w -e size small org.linphone.test/android.test.InstrumentationTestRunner + +run-all-tests: + $(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone.test + $(SDK_PLATFORM_TOOLS_PATH)/adb uninstall org.linphone + $(SDK_PATH)/android update test-project --path . -m ../ + ant debug + ant installd + adb shell am instrument -w -e size large org.linphone.test/android.test.InstrumentationTestRunner