Add Connection.startActivityFromInCall

This CL adds a new public API to allow Connections
to start an activity on top of the in-call UI.

The Connection passes a PendingIntent to Telecomm which
then forwards it on to InCallUI. The Connection can cancel
the operation by calling PendingIntent.cancel().

This allows services like SIP and Hangouts to show dialogs
to the user when making a call.

Change-Id: I65119a89c925a93467d1b27304ffec9b088b172f
This commit is contained in:
Sailesh Nepal
2014-07-18 14:49:18 -07:00
parent 480315939d
commit 2ab88cc313
12 changed files with 130 additions and 7 deletions

View File

@@ -16,6 +16,7 @@
package android.telecomm;
import android.app.PendingIntent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -40,6 +41,7 @@ public abstract class InCallService {
private static final int MSG_SET_POST_DIAL_WAIT = 5;
private static final int MSG_ON_AUDIO_STATE_CHANGED = 6;
private static final int MSG_BRING_TO_FOREGROUND = 7;
private static final int MSG_START_ACTIVITY = 8;
/** Default Handler used to consolidate binder method calls onto a single thread. */
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@@ -84,6 +86,15 @@ public abstract class InCallService {
case MSG_BRING_TO_FOREGROUND:
mPhone.internalBringToForeground(msg.arg1 == 1);
break;
case MSG_START_ACTIVITY:
SomeArgs args = (SomeArgs) msg.obj;
try {
mPhone.internalStartActivity(
(String) args.arg1, (PendingIntent) args.arg2);
} finally {
args.recycle();
}
break;
default:
break;
}
@@ -137,6 +148,15 @@ public abstract class InCallService {
public void bringToForeground(boolean showDialpad) {
mHandler.obtainMessage(MSG_BRING_TO_FOREGROUND, showDialpad ? 1 : 0, 0).sendToTarget();
}
/** {@inheritDoc} */
@Override
public void startActivity(String callId, PendingIntent intent) {
SomeArgs args = SomeArgs.obtain();
args.arg1 = callId;
args.arg2 = intent;
mHandler.obtainMessage(MSG_START_ACTIVITY, args).sendToTarget();
}
}
private Phone mPhone;