Add handover permission, fill in some missing API gaps.
Adding the ACCEPT_HANDOVER runtime permission which an app must have in order to accept handovers (this is per design). Adding missing onHandoverComplete method in the android.telecom.Connection API (per design). Finishing plumbing for android.telecom.Call#onHandoverComplete API. Fix issue where the new handover API methods would never get called; the legacy handover extra was being used in this case when it should not have been. Bug: 65415068 Test: Verified using new CTS tests Change-Id: If1558f6a23911862c02ac5b18fb62d86911ed7e2 Merged-In: If1558f6a23911862c02ac5b18fb62d86911ed7e2
This commit is contained in:
@@ -140,6 +140,7 @@ public abstract class ConnectionService extends Service {
|
||||
private static final String SESSION_POST_DIAL_CONT = "CS.oPDC";
|
||||
private static final String SESSION_PULL_EXTERNAL_CALL = "CS.pEC";
|
||||
private static final String SESSION_SEND_CALL_EVENT = "CS.sCE";
|
||||
private static final String SESSION_HANDOVER_COMPLETE = "CS.hC";
|
||||
private static final String SESSION_EXTRAS_CHANGED = "CS.oEC";
|
||||
private static final String SESSION_START_RTT = "CS.+RTT";
|
||||
private static final String SESSION_STOP_RTT = "CS.-RTT";
|
||||
@@ -179,6 +180,7 @@ public abstract class ConnectionService extends Service {
|
||||
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 final int MSG_HANDOVER_COMPLETE = 33;
|
||||
|
||||
private static Connection sNullConnection;
|
||||
|
||||
@@ -297,6 +299,19 @@ public abstract class ConnectionService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handoverComplete(String callId, Session.Info sessionInfo) {
|
||||
Log.startSession(sessionInfo, SESSION_HANDOVER_COMPLETE);
|
||||
try {
|
||||
SomeArgs args = SomeArgs.obtain();
|
||||
args.arg1 = callId;
|
||||
args.arg2 = Log.createSubsession();
|
||||
mHandler.obtainMessage(MSG_HANDOVER_COMPLETE, args).sendToTarget();
|
||||
} finally {
|
||||
Log.endSession();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abort(String callId, Session.Info sessionInfo) {
|
||||
Log.startSession(sessionInfo, SESSION_ABORT);
|
||||
@@ -1028,6 +1043,19 @@ public abstract class ConnectionService extends Service {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_HANDOVER_COMPLETE: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
try {
|
||||
Log.continueSession((Session) args.arg2,
|
||||
SESSION_HANDLER + SESSION_HANDOVER_COMPLETE);
|
||||
String callId = (String) args.arg1;
|
||||
notifyHandoverComplete(callId);
|
||||
} finally {
|
||||
args.recycle();
|
||||
Log.endSession();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_ON_EXTRAS_CHANGED: {
|
||||
SomeArgs args = (SomeArgs) msg.obj;
|
||||
try {
|
||||
@@ -1445,19 +1473,24 @@ public abstract class ConnectionService extends Service {
|
||||
final ConnectionRequest request,
|
||||
boolean isIncoming,
|
||||
boolean isUnknown) {
|
||||
boolean isLegacyHandover = request.getExtras() != null &&
|
||||
request.getExtras().getBoolean(TelecomManager.EXTRA_IS_HANDOVER, false);
|
||||
boolean isHandover = request.getExtras() != null && request.getExtras().getBoolean(
|
||||
TelecomManager.EXTRA_IS_HANDOVER_CONNECTION, false);
|
||||
Log.d(this, "createConnection, callManagerAccount: %s, callId: %s, request: %s, " +
|
||||
"isIncoming: %b, isUnknown: %b", callManagerAccount, callId, request,
|
||||
isIncoming,
|
||||
isUnknown);
|
||||
"isIncoming: %b, isUnknown: %b, isLegacyHandover: %b, isHandover: %b",
|
||||
callManagerAccount, callId, request, isIncoming, isUnknown, isLegacyHandover,
|
||||
isHandover);
|
||||
|
||||
Connection connection = null;
|
||||
if (getApplicationContext().getApplicationInfo().targetSdkVersion >
|
||||
Build.VERSION_CODES.O_MR1 && request.getExtras() != null &&
|
||||
request.getExtras().getBoolean(TelecomManager.EXTRA_IS_HANDOVER,false)) {
|
||||
if (isHandover) {
|
||||
PhoneAccountHandle fromPhoneAccountHandle = request.getExtras() != null
|
||||
? (PhoneAccountHandle) request.getExtras().getParcelable(
|
||||
TelecomManager.EXTRA_HANDOVER_FROM_PHONE_ACCOUNT) : null;
|
||||
if (!isIncoming) {
|
||||
connection = onCreateOutgoingHandoverConnection(callManagerAccount, request);
|
||||
connection = onCreateOutgoingHandoverConnection(fromPhoneAccountHandle, request);
|
||||
} else {
|
||||
connection = onCreateIncomingHandoverConnection(callManagerAccount, request);
|
||||
connection = onCreateIncomingHandoverConnection(fromPhoneAccountHandle, request);
|
||||
}
|
||||
} else {
|
||||
connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request)
|
||||
@@ -1753,6 +1786,19 @@ public abstract class ConnectionService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies a {@link Connection} that a handover has completed.
|
||||
*
|
||||
* @param callId The ID of the call which completed handover.
|
||||
*/
|
||||
private void notifyHandoverComplete(String callId) {
|
||||
Log.d(this, "notifyHandoverComplete(%s)", callId);
|
||||
Connection connection = findConnectionForAction(callId, "notifyHandoverComplete");
|
||||
if (connection != null) {
|
||||
connection.onHandoverComplete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies a {@link Connection} or {@link Conference} of a change to the extras from Telecom.
|
||||
* <p>
|
||||
|
||||
Reference in New Issue
Block a user