Receiving side Call handover API implementation.
Bug: 65415068 Test: Manual Design doc: https://docs.google.com/document/d/1qY3oAzjff_4A1ttYb_CGrE_OwTRmXMG_KGsIuPT1ey8/edit#Bug: Change-Id: Ic0c4af19098252389648007628affc19a44f89dd
This commit is contained in:
@@ -21,6 +21,7 @@ import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
@@ -145,6 +146,7 @@ public abstract class ConnectionService extends Service {
|
||||
private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR";
|
||||
private static final String SESSION_CONNECTION_SERVICE_FOCUS_LOST = "CS.cSFL";
|
||||
private static final String SESSION_CONNECTION_SERVICE_FOCUS_GAINED = "CS.cSFG";
|
||||
private static final String SESSION_HANDOVER_FAILED = "CS.haF";
|
||||
|
||||
private static final int MSG_ADD_CONNECTION_SERVICE_ADAPTER = 1;
|
||||
private static final int MSG_CREATE_CONNECTION = 2;
|
||||
@@ -176,6 +178,7 @@ public abstract class ConnectionService extends Service {
|
||||
private static final int MSG_CREATE_CONNECTION_COMPLETE = 29;
|
||||
private static final int MSG_CONNECTION_SERVICE_FOCUS_LOST = 30;
|
||||
private static final int MSG_CONNECTION_SERVICE_FOCUS_GAINED = 31;
|
||||
private static final int MSG_HANDOVER_FAILED = 32;
|
||||
|
||||
private static Connection sNullConnection;
|
||||
|
||||
@@ -278,6 +281,22 @@ public abstract class ConnectionService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handoverFailed(String callId, ConnectionRequest request, int reason,
|
||||
Session.Info sessionInfo) {
|
||||
Log.startSession(sessionInfo, SESSION_HANDOVER_FAILED);
|
||||
try {
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = callId;
|
||||
args.arg2 = request;
|
||||
args.arg3 = Log.createSubsession();
|
||||
args.arg4 = reason;
|
||||
mHandler.obtainMessage(MSG_HANDOVER_FAILED, args).sendToTarget();
|
||||
} finally {
|
||||
Log.endSession();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abort(String callId, Session.Info sessionInfo) {
|
||||
Log.startSession(sessionInfo, SESSION_ABORT);
|
||||
@@ -747,6 +766,36 @@ public abstract class ConnectionService extends Service {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_HANDOVER_FAILED: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
Log.continueSession((Session) args.arg3, SESSION_HANDLER +
|
||||
SESSION_HANDOVER_FAILED);
|
||||
try {
|
||||
final String id = (String) args.arg1;
|
||||
final ConnectionRequest request = (ConnectionRequest) args.arg2;
|
||||
final int reason = (int) args.arg4;
|
||||
if (!mAreAccountsInitialized) {
|
||||
Log.d(this, "Enqueueing pre-init request %s", id);
|
||||
mPreInitializationConnectionRequests.add(
|
||||
new android.telecom.Logging.Runnable(
|
||||
SESSION_HANDLER
|
||||
+ SESSION_HANDOVER_FAILED + ".pICR",
|
||||
null /*lock*/) {
|
||||
@Override
|
||||
public void loggedRun() {
|
||||
handoverFailed(id, request, reason);
|
||||
}
|
||||
}.prepare());
|
||||
} else {
|
||||
Log.i(this, "createConnectionFailed %s", id);
|
||||
handoverFailed(id, request, reason);
|
||||
}
|
||||
} finally {
|
||||
args.recycle();
|
||||
Log.endSession();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_ABORT: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
Log.continueSession((Session) args.arg2, SESSION_HANDLER + SESSION_ABORT);
|
||||
@@ -1402,12 +1451,13 @@ public abstract class ConnectionService extends Service {
|
||||
isUnknown);
|
||||
|
||||
Connection connection = null;
|
||||
if (request.getExtras() != null && request.getExtras().getBoolean(
|
||||
TelecomManager.EXTRA_IS_HANDOVER,false)) {
|
||||
if (getApplicationContext().getApplicationInfo().targetSdkVersion >
|
||||
Build.VERSION_CODES.O_MR1 && request.getExtras() != null &&
|
||||
request.getExtras().getBoolean(TelecomManager.EXTRA_IS_HANDOVER,false)) {
|
||||
if (!isIncoming) {
|
||||
connection = onCreateOutgoingHandoverConnection(callManagerAccount, request);
|
||||
} else {
|
||||
// Todo: Call onCreateIncommingHandoverConnection()
|
||||
connection = onCreateIncomingHandoverConnection(callManagerAccount, request);
|
||||
}
|
||||
} else {
|
||||
connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request)
|
||||
@@ -1482,6 +1532,13 @@ public abstract class ConnectionService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private void handoverFailed(final String callId, final ConnectionRequest request,
|
||||
int reason) {
|
||||
|
||||
Log.i(this, "handoverFailed %s", callId);
|
||||
onHandoverFailed(request, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by Telecom when the creation of a new Connection has completed and it is now added
|
||||
* to Telecom.
|
||||
|
||||
@@ -104,4 +104,7 @@ oneway interface IConnectionService {
|
||||
void connectionServiceFocusLost(in Session.Info sessionInfo);
|
||||
|
||||
void connectionServiceFocusGained(in Session.Info sessionInfo);
|
||||
|
||||
void handoverFailed(String callId, in ConnectionRequest request,
|
||||
int error, in Session.Info sessionInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user