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

Commit 036cbeb4 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Remove unused handover code.

Remove unused hidden handover code.

These extras are not used anywhere.  Removing them and the associated
code.

Flag: Code cleanup only; no functional impact since this is orphaned code.
Test: Compile code to verify no build errors.
Bug: 308003610
Change-Id: I59bc7fefcdf7d2c9f40c06b0a1a44809db055067
parent 450039ae
Loading
Loading
Loading
Loading
+9 −55
Original line number Diff line number Diff line
@@ -3427,51 +3427,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    public void sendCallEvent(String event, int targetSdkVer, Bundle extras) {
        if (mConnectionService != null || mTransactionalService != null) {
            if (android.telecom.Call.EVENT_REQUEST_HANDOVER.equals(event)) {
                if (targetSdkVer > Build.VERSION_CODES.P) {
                    Log.e(this, new Exception(), "sendCallEvent failed. Use public api handoverTo" +
                            " for API > 28(P)");
                    // Event-based Handover APIs are deprecated, so inform the user.
                    mHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            mToastFactory.makeText(mContext,
                                    "WARNING: Event-based handover APIs are deprecated and will no"
                                            + " longer function in Android Q.",
                                    Toast.LENGTH_LONG).show();
                        }
                    });

                    // Uncomment and remove toast at feature complete: return;
                }

                // Handover requests are targeted at Telecom, not the ConnectionService.
                if (extras == null) {
                    Log.w(this, "sendCallEvent: %s event received with null extras.",
                            android.telecom.Call.EVENT_REQUEST_HANDOVER);
                    sendEventToService(this, android.telecom.Call.EVENT_HANDOVER_FAILED,
                            null);
                    return;
                }
                Parcelable parcelable = extras.getParcelable(
                        android.telecom.Call.EXTRA_HANDOVER_PHONE_ACCOUNT_HANDLE);
                if (!(parcelable instanceof PhoneAccountHandle) || parcelable == null) {
                    Log.w(this, "sendCallEvent: %s event received with invalid handover acct.",
                            android.telecom.Call.EVENT_REQUEST_HANDOVER);
                    sendEventToService(this, android.telecom.Call.EVENT_HANDOVER_FAILED, null);
                    return;
                }
                PhoneAccountHandle phoneAccountHandle = (PhoneAccountHandle) parcelable;
                int videoState = extras.getInt(android.telecom.Call.EXTRA_HANDOVER_VIDEO_STATE,
                        VideoProfile.STATE_AUDIO_ONLY);
                Parcelable handoverExtras = extras.getParcelable(
                        android.telecom.Call.EXTRA_HANDOVER_EXTRAS);
                Bundle handoverExtrasBundle = null;
                if (handoverExtras instanceof Bundle) {
                    handoverExtrasBundle = (Bundle) handoverExtras;
                }
                requestHandover(phoneAccountHandle, videoState, handoverExtrasBundle, true);
            } else {
            // Relay bluetooth call quality reports to the call diagnostic service.
            if (BluetoothCallQualityReport.EVENT_BLUETOOTH_CALL_QUALITY_REPORT.equals(event)
                    && extras.containsKey(
@@ -3482,7 +3437,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            }
            Log.addEvent(this, LogUtils.Events.CALL_EVENT, event);
            sendEventToService(this, event, extras);
            }
        } else {
            Log.e(this, new NullPointerException(),
                    "sendCallEvent failed due to null CS callId=%s", getId());
+1 −33
Original line number Diff line number Diff line
@@ -1298,9 +1298,7 @@ public class CallsManager extends Call.ListenerBase
    @Override
    public void onHandoverRequested(Call call, PhoneAccountHandle handoverTo, int videoState,
                                    Bundle extras, boolean isLegacy) {
        if (isLegacy) {
            requestHandoverViaEvents(call, handoverTo, videoState, extras);
        } else {
        if (!isLegacy) {
            requestHandover(call, handoverTo, videoState, extras);
        }
    }
@@ -4557,10 +4555,6 @@ public class CallsManager extends Call.ListenerBase
            if (handoverState == HandoverState.HANDOVER_FROM_STARTED) {
                // Disconnect before handover was accepted.
                Log.i(this, "setCallState: disconnect before handover accepted");
                // Let the handover destination know that the source has disconnected prior to
                // completion of the handover.
                call.getHandoverDestinationCall().sendCallEvent(
                        android.telecom.Call.EVENT_HANDOVER_SOURCE_DISCONNECTED, null);
            } else if (handoverState == HandoverState.HANDOVER_ACCEPTED) {
                Log.i(this, "setCallState: handover from complete");
                completeHandoverFrom(call);
@@ -4578,11 +4572,9 @@ public class CallsManager extends Call.ListenerBase
        // Inform the "from" Call (ie the source call) that the handover from it has
        // completed; this allows the InCallService to be notified that a handover it
        // initiated completed.
        call.onConnectionEvent(Connection.EVENT_HANDOVER_COMPLETE, null);
        call.onHandoverComplete();

        // Inform the "to" ConnectionService that handover to it has completed.
        handoverTo.sendCallEvent(android.telecom.Call.EVENT_HANDOVER_COMPLETE, null);
        handoverTo.onHandoverComplete();
        answerCall(handoverTo, handoverTo.getVideoState());
        call.markFinishedHandoverStateAndCleanup(HandoverState.HANDOVER_COMPLETE);
@@ -4605,7 +4597,6 @@ public class CallsManager extends Call.ListenerBase
        // Inform the "from" Call (ie the source call) that the handover from it has
        // failed; this allows the InCallService to be notified that a handover it
        // initiated failed.
        handoverFrom.onConnectionEvent(Connection.EVENT_HANDOVER_FAILED, null);
        handoverFrom.onHandoverFailed(android.telecom.Call.Callback.HANDOVER_FAILURE_USER_REJECTED);

        // Inform the "to" ConnectionService that handover to it has failed.  This
@@ -4614,7 +4605,6 @@ public class CallsManager extends Call.ListenerBase
            // Only attempt if the call has a bound ConnectionService if handover failed
            // early on in the handover process, the CS will be unbound and we won't be
            // able to send the call event.
            handoverTo.sendCallEvent(android.telecom.Call.EVENT_HANDOVER_FAILED, null);
            handoverTo.getConnectionService().handoverFailed(handoverTo,
                    android.telecom.Call.Callback.HANDOVER_FAILURE_USER_REJECTED);
        }
@@ -5907,28 +5897,6 @@ public class CallsManager extends Call.ListenerBase
        call.disconnect("handover failed");
    }

    /**
     * Called in response to a {@link Call} receiving a {@link Call#sendCallEvent(String, Bundle)}
     * of type {@link android.telecom.Call#EVENT_REQUEST_HANDOVER} indicating the
     * {@link android.telecom.InCallService} has requested a handover to another
     * {@link android.telecom.ConnectionService}.
     *
     * We will explicitly disallow a handover when there is an emergency call present.
     *
     * @param handoverFromCall The {@link Call} to be handed over.
     * @param handoverToHandle The {@link PhoneAccountHandle} to hand over the call to.
     * @param videoState The desired video state of {@link Call} after handover.
     * @param initiatingExtras Extras associated with the handover, to be passed to the handover
     *               {@link android.telecom.ConnectionService}.
     */
    private void requestHandoverViaEvents(Call handoverFromCall,
                                          PhoneAccountHandle handoverToHandle,
                                          int videoState, Bundle initiatingExtras) {

        handoverFromCall.sendCallEvent(android.telecom.Call.EVENT_HANDOVER_FAILED, null);
        Log.addEvent(handoverFromCall, LogUtils.Events.HANDOVER_REQUEST, "legacy request denied");
    }

    /**
     * Called in response to a {@link Call} receiving a {@link Call#handoverTo(PhoneAccountHandle,
     * int, Bundle)} indicating the {@link android.telecom.InCallService} has requested a
+0 −11
Original line number Diff line number Diff line
@@ -3077,11 +3077,9 @@ public class CallsManagerTest extends TelecomTestCase {
        mCallsManager.createActionSetCallStateAndPerformAction(
                call, CallState.DISCONNECTED, "");

        verify(sourceCall).onConnectionEvent(eq(Connection.EVENT_HANDOVER_FAILED), any());
        verify(sourceCall).onHandoverFailed(
                    android.telecom.Call.Callback.HANDOVER_FAILURE_USER_REJECTED);

        verify(call).sendCallEvent(eq(android.telecom.Call.EVENT_HANDOVER_FAILED), any());
        verify(call).markFinishedHandoverStateAndCleanup(HandoverState.HANDOVER_FAILED);
    }

@@ -3094,9 +3092,6 @@ public class CallsManagerTest extends TelecomTestCase {
        when(call.getHandoverState()).thenReturn(HandoverState.HANDOVER_FROM_STARTED);
        mCallsManager.createActionSetCallStateAndPerformAction(
                call, CallState.DISCONNECTED, "");

        verify(destinationCall).sendCallEvent(
                eq(android.telecom.Call.EVENT_HANDOVER_SOURCE_DISCONNECTED), any());
    }

    @SmallTest
@@ -3110,11 +3105,8 @@ public class CallsManagerTest extends TelecomTestCase {
        mCallsManager.createActionSetCallStateAndPerformAction(
                call, CallState.DISCONNECTED, "");

        verify(call).onConnectionEvent(eq(Connection.EVENT_HANDOVER_COMPLETE), any());
        verify(call).onHandoverComplete();
        verify(call).markFinishedHandoverStateAndCleanup(HandoverState.HANDOVER_COMPLETE);
        verify(destinationCall).sendCallEvent(
                eq(android.telecom.Call.EVENT_HANDOVER_COMPLETE), any());
        verify(destinationCall).onHandoverComplete();
    }

@@ -3131,11 +3123,8 @@ public class CallsManagerTest extends TelecomTestCase {
        mCallsManager.createActionSetCallStateAndPerformAction(
                call, CallState.DISCONNECTED, "");

        verify(call).onConnectionEvent(eq(Connection.EVENT_HANDOVER_COMPLETE), any());
        verify(call).onHandoverComplete();
        verify(call).markFinishedHandoverStateAndCleanup(HandoverState.HANDOVER_COMPLETE);
        verify(destinationCall).sendCallEvent(
                eq(android.telecom.Call.EVENT_HANDOVER_COMPLETE), any());
        verify(destinationCall).onHandoverComplete();
        verify(otherCall).disconnect();
    }