Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 151c1544 authored by Sanket Padawe's avatar Sanket Padawe Committed by android-build-merger
Browse files

Merge "Receiving side Call handover API implementation."

am: 3c7bc2dc

Change-Id: I7badcfaf9d308fb05745b0f37ee99603f5eee1c2
parents fa7f4015 3c7bc2dc
Loading
Loading
Loading
Loading
+60 −3
Original line number Diff line number Diff line
@@ -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;
@@ -143,6 +144,7 @@ public abstract class ConnectionService extends Service {
    private static final String SESSION_START_RTT = "CS.+RTT";
    private static final String SESSION_STOP_RTT = "CS.-RTT";
    private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR";
    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;
@@ -172,6 +174,7 @@ public abstract class ConnectionService extends Service {
    private static final int MSG_ON_STOP_RTT = 27;
    private static final int MSG_RTT_UPGRADE_RESPONSE = 28;
    private static final int MSG_CREATE_CONNECTION_COMPLETE = 29;
    private static final int MSG_HANDOVER_FAILED = 32;

    private static Connection sNullConnection;

@@ -274,6 +277,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);
@@ -723,6 +742,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);
@@ -1372,12 +1421,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)
@@ -1452,6 +1502,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.
+3 −0
Original line number Diff line number Diff line
@@ -100,4 +100,7 @@ oneway interface IConnectionService {

    void respondToRttUpgradeRequest(String callId, in ParcelFileDescriptor fromInCall,
    in ParcelFileDescriptor toInCall, in Session.Info sessionInfo);

    void handoverFailed(String callId, in ConnectionRequest request,
            int error, in Session.Info sessionInfo);
}