DTMF dialing support in frameworks/base
Change-Id: I86695161fab9c4fbd4a021ba69cc61ec5e585adc
This commit is contained in:
@@ -23,6 +23,7 @@ import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.android.internal.os.SomeArgs;
|
||||
import com.android.internal.telecomm.IInCallAdapter;
|
||||
import com.android.internal.telecomm.IInCallService;
|
||||
|
||||
@@ -41,6 +42,10 @@ public abstract class InCallService extends Service {
|
||||
private static final int MSG_SET_DISCONNECTED = 4;
|
||||
private static final int MSG_SET_HOLD = 5;
|
||||
private static final int MSG_ON_AUDIO_STATE_CHANGED = 6;
|
||||
private static final int MSG_SET_DIALING = 7;
|
||||
private static final int MSG_SET_RINGING = 8;
|
||||
private static final int MSG_SET_POST_DIAL = 9;
|
||||
private static final int MSG_SET_POST_DIAL_WAIT = 10;
|
||||
|
||||
/** Default Handler used to consolidate binder method calls onto a single thread. */
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
|
||||
@@ -57,6 +62,34 @@ public abstract class InCallService extends Service {
|
||||
case MSG_SET_ACTIVE:
|
||||
setActive((String) msg.obj);
|
||||
break;
|
||||
case MSG_SET_DIALING:
|
||||
setDialing((String) msg.obj);
|
||||
break;
|
||||
case MSG_SET_RINGING:
|
||||
setRinging((String) msg.obj);
|
||||
break;
|
||||
case MSG_SET_POST_DIAL: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
try {
|
||||
String callId = (String) args.arg1;
|
||||
String remaining = (String) args.arg2;
|
||||
setPostDial(callId, remaining);
|
||||
} finally {
|
||||
args.recycle();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_SET_POST_DIAL_WAIT: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
try {
|
||||
String callId = (String) args.arg1;
|
||||
String remaining = (String) args.arg2;
|
||||
setPostDialWait(callId, remaining);
|
||||
} finally {
|
||||
args.recycle();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_SET_DISCONNECTED:
|
||||
setDisconnected((String) msg.obj, msg.arg1);
|
||||
break;
|
||||
@@ -108,6 +141,32 @@ public abstract class InCallService extends Service {
|
||||
public void onAudioStateChanged(CallAudioState audioState) {
|
||||
mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, audioState).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDialing(String callId) {
|
||||
mHandler.obtainMessage(MSG_SET_DIALING, callId).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRinging(String callId) {
|
||||
mHandler.obtainMessage(MSG_SET_RINGING, callId).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPostDial(String callId, String remaining) {
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = callId;
|
||||
args.arg2 = remaining;
|
||||
mHandler.obtainMessage(MSG_SET_POST_DIAL, args).sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPostDialWait(String callId, String remaining) {
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = callId;
|
||||
args.arg2 = remaining;
|
||||
mHandler.obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
private final InCallServiceBinder mBinder;
|
||||
@@ -140,12 +199,35 @@ public abstract class InCallService extends Service {
|
||||
protected abstract void addCall(CallInfo callInfo);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that a call has moved to the {@link CallState#ACTIVE} state.
|
||||
* Indicates to the in-call app that the specified call is currently connected to another party
|
||||
* and a communication channel is open between them. Normal transitions are to
|
||||
* {@link #setDisconnected(String)} when the call is complete.
|
||||
*
|
||||
* @param callId The identifier of the call that became active.
|
||||
* @param callId The identifier of the call changing state.
|
||||
*/
|
||||
protected abstract void setActive(String callId);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that the specified call is outgoing and in the dialing state.
|
||||
* Normal transition are to {@link #setActive(String)} if the call was answered,
|
||||
* {@link #setPostDial(String,String)} if the dialed number includes a post-dial DTMF string, or
|
||||
* {@link #setDisconnected(String)} if the call was disconnected immediately.
|
||||
*
|
||||
* @param callId The identifier of the call changing state.
|
||||
*/
|
||||
protected abstract void setDialing(String callId);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that the specified call is incoming and the user still has the
|
||||
* option of answering, rejecting, or doing nothing with the call. This state is usually
|
||||
* associated with some type of audible ringtone. Normal transitions are to
|
||||
* {@link #setActive(String)} if the call is answered, or {@link #setDisconnected(String)} if
|
||||
* the call is not answered or is otherwise disconnected for some reason.
|
||||
*
|
||||
* @param callId The identifier of the call changing state.
|
||||
*/
|
||||
protected abstract void setRinging(String callId);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that a call has been moved to the
|
||||
* {@link CallState#DISCONNECTED} and the user should be notified.
|
||||
@@ -170,4 +252,29 @@ public abstract class InCallService extends Service {
|
||||
* @param audioState The new {@link CallAudioState}.
|
||||
*/
|
||||
protected abstract void onAudioStateChanged(CallAudioState audioState);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that the specified call is active but in a "post-dial" state
|
||||
* where Telecomm is now sending some dual-tone multi-frequency signaling (DTMF) tones appended
|
||||
* to the dialed number. Normal transitions are to {@link #setPostDialWait(String,String)} when
|
||||
* the post-dial string requires user confirmation to proceed, {@link #setActive(String)} when
|
||||
* the post-dial tones are completed, or {@link #setDisconnected(String)} if the call is
|
||||
* disconnected.
|
||||
*
|
||||
* @param callId The identifier of the call changing state.
|
||||
* @param remaining The remaining postdial string to be dialed.
|
||||
*/
|
||||
protected abstract void setPostDial(String callId, String remaining);
|
||||
|
||||
/**
|
||||
* Indicates to the in-call app that the specified call was in the
|
||||
* {@link #setPostDial(String,String)} state but is now waiting for user confirmation before the
|
||||
* remaining digits can be sent. Normal transitions are to {@link #setPostDial(String,String)}
|
||||
* when the user asks Telecomm to proceed with the post-dial sequence and the in-call app
|
||||
* informs Telecomm of this by invoking {@link IInCallAdapter#postDialContinue(String)}.
|
||||
*
|
||||
* @param callId The identifier of the call changing state.
|
||||
* @param remaining The remaining postdial string to be dialed.
|
||||
*/
|
||||
protected abstract void setPostDialWait(String callId, String remaining);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user