am 1180f2a0: Merge "Remove ringtone API from SipAudioCall." into gingerbread

Merge commit '1180f2a099a134c40f923c7e4162a5e7d7ca0184' into gingerbread-plus-aosp

* commit '1180f2a099a134c40f923c7e4162a5e7d7ca0184':
  Remove ringtone API from SipAudioCall.
This commit is contained in:
Hung-ying Tyan
2010-10-20 13:54:25 -07:00
committed by Android Git Automerger
4 changed files with 1 additions and 145 deletions

View File

@@ -98580,32 +98580,6 @@
<parameter name="callbackImmediately" type="boolean">
</parameter>
</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"
return="void"
abstract="false"
@@ -99304,25 +99278,6 @@
<exception name="SipException" type="android.net.sip.SipException">
</exception>
</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"
return="void"
abstract="false"

View File

@@ -714,7 +714,6 @@ public class SipPhone extends SipPhoneBase {
setState(Call.State.DIALING);
mSipAudioCall = mSipManager.makeAudioCall(mProfile, mPeer, null,
TIMEOUT_MAKE_CALL);
mSipAudioCall.setRingbackToneEnabled(false);
mSipAudioCall.setListener(mAdapter);
}

View File

@@ -18,10 +18,6 @@ package android.net.sip;
import android.content.Context;
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.AudioGroup;
import android.net.rtp.AudioStream;
@@ -30,8 +26,6 @@ import android.net.sip.SimpleSessionDescription.Media;
import android.net.wifi.WifiManager;
import android.os.Message;
import android.os.RemoteException;
import android.os.Vibrator;
import android.provider.Settings;
import android.util.Log;
import java.io.IOException;
@@ -175,11 +169,6 @@ public class SipAudioCall {
private boolean mMuted = false;
private boolean mHold = false;
private boolean mRingbackToneEnabled = true;
private boolean mRingtoneEnabled = true;
private Ringtone mRingtone;
private ToneGenerator mRingbackTone;
private SipProfile mPendingCallRequest;
private WifiManager mWm;
private WifiManager.WifiLock mWifiHighPerfLock;
@@ -285,8 +274,6 @@ public class SipAudioCall {
private synchronized void close(boolean closeRtp) {
if (closeRtp) stopCall(RELEASE_SOCKET);
stopRingbackTone();
stopRinging();
mInCall = false;
mHold = false;
@@ -366,7 +353,6 @@ public class SipAudioCall {
@Override
public void onRingingBack(SipSession session) {
Log.d(TAG, "sip call ringing back: " + session);
if (!mInCall) startRingbackTone();
Listener listener = mListener;
if (listener != null) {
try {
@@ -403,8 +389,6 @@ public class SipAudioCall {
@Override
public void onCallEstablished(SipSession session,
String sessionDescription) {
stopRingbackTone();
stopRinging();
mPeerSd = sessionDescription;
Log.v(TAG, "onCallEstablished()" + mPeerSd);
@@ -533,10 +517,6 @@ public class SipAudioCall {
Log.v(TAG, "attachCall()" + mPeerSd);
try {
session.setListener(createListener());
if (getState() == SipSession.State.INCOMING_CALL) {
startRinging();
}
} catch (Throwable e) {
Log.e(TAG, "attachCall()", e);
throwSipException(e);
@@ -580,7 +560,6 @@ public class SipAudioCall {
*/
public void endCall() throws SipException {
synchronized (this) {
stopRinging();
stopCall(RELEASE_SOCKET);
mInCall = false;
@@ -625,7 +604,6 @@ public class SipAudioCall {
*/
public void answerCall(int timeout) throws SipException {
synchronized (this) {
stopRinging();
try {
mAudioStream = new AudioStream(InetAddress.getByName(
getLocalIp()));
@@ -1024,69 +1002,6 @@ public class SipAudioCall {
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 {
if (throwable instanceof SipException) {
throw (SipException) throwable;

View File

@@ -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
* 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
*/
public SipAudioCall takeAudioCall(Intent incomingCallIntent,
SipAudioCall.Listener listener, boolean ringtoneEnabled)
throws SipException {
SipAudioCall.Listener listener) throws SipException {
if (incomingCallIntent == null) return null;
String callId = getCallId(incomingCallIntent);
@@ -394,7 +382,6 @@ public class SipManager {
if (session == null) return null;
SipAudioCall call = new SipAudioCall(
mContext, session.getLocalProfile());
call.setRingtoneEnabled(ringtoneEnabled);
call.attachCall(new SipSession(session), offerSd);
call.setListener(listener);
return call;