Merge "Remove ringtone API from SipAudioCall." into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
1180f2a099
@@ -96518,32 +96518,6 @@
|
|||||||
<parameter name="callbackImmediately" type="boolean">
|
<parameter name="callbackImmediately" type="boolean">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
<method name="setRingbackToneEnabled"
|
|
||||||
return="void"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
<parameter name="enabled" type="boolean">
|
|
||||||
</parameter>
|
|
||||||
</method>
|
|
||||||
<method name="setRingtoneEnabled"
|
|
||||||
return="void"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
<parameter name="enabled" type="boolean">
|
|
||||||
</parameter>
|
|
||||||
</method>
|
|
||||||
<method name="setSpeakerMode"
|
<method name="setSpeakerMode"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -97242,25 +97216,6 @@
|
|||||||
<exception name="SipException" type="android.net.sip.SipException">
|
<exception name="SipException" type="android.net.sip.SipException">
|
||||||
</exception>
|
</exception>
|
||||||
</method>
|
</method>
|
||||||
<method name="takeAudioCall"
|
|
||||||
return="android.net.sip.SipAudioCall"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
<parameter name="incomingCallIntent" type="android.content.Intent">
|
|
||||||
</parameter>
|
|
||||||
<parameter name="listener" type="android.net.sip.SipAudioCall.Listener">
|
|
||||||
</parameter>
|
|
||||||
<parameter name="ringtoneEnabled" type="boolean">
|
|
||||||
</parameter>
|
|
||||||
<exception name="SipException" type="android.net.sip.SipException">
|
|
||||||
</exception>
|
|
||||||
</method>
|
|
||||||
<method name="unregister"
|
<method name="unregister"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
|
|||||||
@@ -714,7 +714,6 @@ public class SipPhone extends SipPhoneBase {
|
|||||||
setState(Call.State.DIALING);
|
setState(Call.State.DIALING);
|
||||||
mSipAudioCall = mSipManager.makeAudioCall(mProfile, mPeer, null,
|
mSipAudioCall = mSipManager.makeAudioCall(mProfile, mPeer, null,
|
||||||
TIMEOUT_MAKE_CALL);
|
TIMEOUT_MAKE_CALL);
|
||||||
mSipAudioCall.setRingbackToneEnabled(false);
|
|
||||||
mSipAudioCall.setListener(mAdapter);
|
mSipAudioCall.setListener(mAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ package android.net.sip;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.Ringtone;
|
|
||||||
import android.media.RingtoneManager;
|
|
||||||
import android.media.ToneGenerator;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.net.rtp.AudioCodec;
|
import android.net.rtp.AudioCodec;
|
||||||
import android.net.rtp.AudioGroup;
|
import android.net.rtp.AudioGroup;
|
||||||
import android.net.rtp.AudioStream;
|
import android.net.rtp.AudioStream;
|
||||||
@@ -30,8 +26,6 @@ import android.net.sip.SimpleSessionDescription.Media;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.Vibrator;
|
|
||||||
import android.provider.Settings;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -175,11 +169,6 @@ public class SipAudioCall {
|
|||||||
private boolean mMuted = false;
|
private boolean mMuted = false;
|
||||||
private boolean mHold = false;
|
private boolean mHold = false;
|
||||||
|
|
||||||
private boolean mRingbackToneEnabled = true;
|
|
||||||
private boolean mRingtoneEnabled = true;
|
|
||||||
private Ringtone mRingtone;
|
|
||||||
private ToneGenerator mRingbackTone;
|
|
||||||
|
|
||||||
private SipProfile mPendingCallRequest;
|
private SipProfile mPendingCallRequest;
|
||||||
private WifiManager mWm;
|
private WifiManager mWm;
|
||||||
private WifiManager.WifiLock mWifiHighPerfLock;
|
private WifiManager.WifiLock mWifiHighPerfLock;
|
||||||
@@ -285,8 +274,6 @@ public class SipAudioCall {
|
|||||||
|
|
||||||
private synchronized void close(boolean closeRtp) {
|
private synchronized void close(boolean closeRtp) {
|
||||||
if (closeRtp) stopCall(RELEASE_SOCKET);
|
if (closeRtp) stopCall(RELEASE_SOCKET);
|
||||||
stopRingbackTone();
|
|
||||||
stopRinging();
|
|
||||||
|
|
||||||
mInCall = false;
|
mInCall = false;
|
||||||
mHold = false;
|
mHold = false;
|
||||||
@@ -366,7 +353,6 @@ public class SipAudioCall {
|
|||||||
@Override
|
@Override
|
||||||
public void onRingingBack(SipSession session) {
|
public void onRingingBack(SipSession session) {
|
||||||
Log.d(TAG, "sip call ringing back: " + session);
|
Log.d(TAG, "sip call ringing back: " + session);
|
||||||
if (!mInCall) startRingbackTone();
|
|
||||||
Listener listener = mListener;
|
Listener listener = mListener;
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
try {
|
try {
|
||||||
@@ -403,8 +389,6 @@ public class SipAudioCall {
|
|||||||
@Override
|
@Override
|
||||||
public void onCallEstablished(SipSession session,
|
public void onCallEstablished(SipSession session,
|
||||||
String sessionDescription) {
|
String sessionDescription) {
|
||||||
stopRingbackTone();
|
|
||||||
stopRinging();
|
|
||||||
mPeerSd = sessionDescription;
|
mPeerSd = sessionDescription;
|
||||||
Log.v(TAG, "onCallEstablished()" + mPeerSd);
|
Log.v(TAG, "onCallEstablished()" + mPeerSd);
|
||||||
|
|
||||||
@@ -533,10 +517,6 @@ public class SipAudioCall {
|
|||||||
Log.v(TAG, "attachCall()" + mPeerSd);
|
Log.v(TAG, "attachCall()" + mPeerSd);
|
||||||
try {
|
try {
|
||||||
session.setListener(createListener());
|
session.setListener(createListener());
|
||||||
|
|
||||||
if (getState() == SipSession.State.INCOMING_CALL) {
|
|
||||||
startRinging();
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.e(TAG, "attachCall()", e);
|
Log.e(TAG, "attachCall()", e);
|
||||||
throwSipException(e);
|
throwSipException(e);
|
||||||
@@ -580,7 +560,6 @@ public class SipAudioCall {
|
|||||||
*/
|
*/
|
||||||
public void endCall() throws SipException {
|
public void endCall() throws SipException {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
stopRinging();
|
|
||||||
stopCall(RELEASE_SOCKET);
|
stopCall(RELEASE_SOCKET);
|
||||||
mInCall = false;
|
mInCall = false;
|
||||||
|
|
||||||
@@ -625,7 +604,6 @@ public class SipAudioCall {
|
|||||||
*/
|
*/
|
||||||
public void answerCall(int timeout) throws SipException {
|
public void answerCall(int timeout) throws SipException {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
stopRinging();
|
|
||||||
try {
|
try {
|
||||||
mAudioStream = new AudioStream(InetAddress.getByName(
|
mAudioStream = new AudioStream(InetAddress.getByName(
|
||||||
getLocalIp()));
|
getLocalIp()));
|
||||||
@@ -1024,69 +1002,6 @@ public class SipAudioCall {
|
|||||||
return mSipSession.getLocalIp();
|
return mSipSession.getLocalIp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables/disables the ring-back tone.
|
|
||||||
*
|
|
||||||
* @param enabled true to enable; false to disable
|
|
||||||
*/
|
|
||||||
public void setRingbackToneEnabled(boolean enabled) {
|
|
||||||
synchronized (this) {
|
|
||||||
mRingbackToneEnabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables/disables the ring tone.
|
|
||||||
*
|
|
||||||
* @param enabled true to enable; false to disable
|
|
||||||
*/
|
|
||||||
public void setRingtoneEnabled(boolean enabled) {
|
|
||||||
synchronized (this) {
|
|
||||||
mRingtoneEnabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startRingbackTone() {
|
|
||||||
if (!mRingbackToneEnabled) return;
|
|
||||||
if (mRingbackTone == null) {
|
|
||||||
// The volume relative to other sounds in the stream
|
|
||||||
int toneVolume = 80;
|
|
||||||
mRingbackTone = new ToneGenerator(
|
|
||||||
AudioManager.STREAM_VOICE_CALL, toneVolume);
|
|
||||||
}
|
|
||||||
mRingbackTone.startTone(ToneGenerator.TONE_CDMA_LOW_PBX_L);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopRingbackTone() {
|
|
||||||
if (mRingbackTone != null) {
|
|
||||||
mRingbackTone.stopTone();
|
|
||||||
mRingbackTone.release();
|
|
||||||
mRingbackTone = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startRinging() {
|
|
||||||
if (!mRingtoneEnabled) return;
|
|
||||||
((Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE))
|
|
||||||
.vibrate(new long[] {0, 1000, 1000}, 1);
|
|
||||||
AudioManager am = (AudioManager)
|
|
||||||
mContext.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
if (am.getStreamVolume(AudioManager.STREAM_RING) > 0) {
|
|
||||||
String ringtoneUri =
|
|
||||||
Settings.System.DEFAULT_RINGTONE_URI.toString();
|
|
||||||
mRingtone = RingtoneManager.getRingtone(mContext,
|
|
||||||
Uri.parse(ringtoneUri));
|
|
||||||
mRingtone.play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopRinging() {
|
|
||||||
((Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE))
|
|
||||||
.cancel();
|
|
||||||
if (mRingtone != null) mRingtone.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void throwSipException(Throwable throwable) throws SipException {
|
private void throwSipException(Throwable throwable) throws SipException {
|
||||||
if (throwable instanceof SipException) {
|
if (throwable instanceof SipException) {
|
||||||
throw (SipException) throwable;
|
throw (SipException) throwable;
|
||||||
|
|||||||
@@ -350,17 +350,6 @@ public class SipManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The method calls {@code takeAudioCall(incomingCallIntent,
|
|
||||||
* listener, true}.
|
|
||||||
*
|
|
||||||
* @see #takeAudioCall(Intent, SipAudioCall.Listener, boolean)
|
|
||||||
*/
|
|
||||||
public SipAudioCall takeAudioCall(Intent incomingCallIntent,
|
|
||||||
SipAudioCall.Listener listener) throws SipException {
|
|
||||||
return takeAudioCall(incomingCallIntent, listener, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link SipAudioCall} to take an incoming call. Before the call
|
* Creates a {@link SipAudioCall} to take an incoming call. Before the call
|
||||||
* is returned, the listener will receive a
|
* is returned, the listener will receive a
|
||||||
@@ -374,8 +363,7 @@ public class SipManager {
|
|||||||
* @throws SipException if calling the SIP service results in an error
|
* @throws SipException if calling the SIP service results in an error
|
||||||
*/
|
*/
|
||||||
public SipAudioCall takeAudioCall(Intent incomingCallIntent,
|
public SipAudioCall takeAudioCall(Intent incomingCallIntent,
|
||||||
SipAudioCall.Listener listener, boolean ringtoneEnabled)
|
SipAudioCall.Listener listener) throws SipException {
|
||||||
throws SipException {
|
|
||||||
if (incomingCallIntent == null) return null;
|
if (incomingCallIntent == null) return null;
|
||||||
|
|
||||||
String callId = getCallId(incomingCallIntent);
|
String callId = getCallId(incomingCallIntent);
|
||||||
@@ -394,7 +382,6 @@ public class SipManager {
|
|||||||
if (session == null) return null;
|
if (session == null) return null;
|
||||||
SipAudioCall call = new SipAudioCall(
|
SipAudioCall call = new SipAudioCall(
|
||||||
mContext, session.getLocalProfile());
|
mContext, session.getLocalProfile());
|
||||||
call.setRingtoneEnabled(ringtoneEnabled);
|
|
||||||
call.attachCall(new SipSession(session), offerSd);
|
call.attachCall(new SipSession(session), offerSd);
|
||||||
call.setListener(listener);
|
call.setListener(listener);
|
||||||
return call;
|
return call;
|
||||||
|
|||||||
Reference in New Issue
Block a user