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

Commit 0e924492 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5726885 from fbe011ee to qt-qpr1-release

Change-Id: Id0b237a7d2626281627c64e794ddb5313ac51dcd
parents 47846ff0 fbe011ee
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -327,18 +327,25 @@ public class CallAudioModeStateMachine extends StateMachine {
                    }
                    return HANDLED;
                case NO_MORE_HOLDING_CALLS:
                    // Do nothing.
                    if (args.foregroundCallIsVoip) {
                        transitionTo(mVoipCallFocusState);
                    }
                    return HANDLED;
                case NEW_ACTIVE_OR_DIALING_CALL:
                    // Do nothing. Already active.
                    if (args.foregroundCallIsVoip) {
                        transitionTo(mVoipCallFocusState);
                    }
                    return HANDLED;
                case NEW_RINGING_CALL:
                    // Don't make a call ring over an active call, but do play a call waiting tone.
                    mCallAudioManager.startCallWaiting("call already active");
                    return HANDLED;
                case NEW_HOLDING_CALL:
                    // Don't do anything now. Putting an active call on hold will be handled when
                    // Just check the voip mode. Putting an active call on hold will be handled when
                    // NO_MORE_ACTIVE_CALLS is processed.
                    if (args.foregroundCallIsVoip) {
                        transitionTo(mVoipCallFocusState);
                    }
                    return HANDLED;
                case FOREGROUND_VOIP_MODE_CHANGE:
                    if (args.foregroundCallIsVoip) {
@@ -382,18 +389,25 @@ public class CallAudioModeStateMachine extends StateMachine {
                    }
                    return HANDLED;
                case NO_MORE_HOLDING_CALLS:
                    // Do nothing.
                    if (!args.foregroundCallIsVoip) {
                        transitionTo(mSimCallFocusState);
                    }
                    return HANDLED;
                case NEW_ACTIVE_OR_DIALING_CALL:
                    // Do nothing. Already active.
                    if (!args.foregroundCallIsVoip) {
                        transitionTo(mSimCallFocusState);
                    }
                    return HANDLED;
                case NEW_RINGING_CALL:
                    // Don't make a call ring over an active call, but do play a call waiting tone.
                    mCallAudioManager.startCallWaiting("call already active");
                    return HANDLED;
                case NEW_HOLDING_CALL:
                    // Don't do anything now. Putting an active call on hold will be handled when
                    // Just check the voip mode. Putting an active call on hold will be handled when
                    // NO_MORE_ACTIVE_CALLS is processed.
                    if (!args.foregroundCallIsVoip) {
                        transitionTo(mSimCallFocusState);
                    }
                    return HANDLED;
                case FOREGROUND_VOIP_MODE_CHANGE:
                    if (!args.foregroundCallIsVoip) {
+1 −1
Original line number Diff line number Diff line
@@ -1841,7 +1841,7 @@ public class CallsManager extends Call.ListenerBase
            mPendingUnredirectedOutgoingCallInfo.remove(callId);
        } else {
            Log.w(this, "processRedirectedOutgoingCallAfterUserInteraction for non-matched Call ID"
                    + " %s with handle %s and phoneAccountHandle %s", callId);
                    + " %s", callId);
        }
    }

+2 −0
Original line number Diff line number Diff line
@@ -288,6 +288,7 @@ public class NewOutgoingCallIntentBroadcaster {
                    return result;
                } else {
                    result.callImmediately = true;
                    result.requestRedirection = false;
                }
            }
        } else if (Intent.ACTION_CALL_EMERGENCY.equals(action)) {
@@ -298,6 +299,7 @@ public class NewOutgoingCallIntentBroadcaster {
                return result;
            }
            result.callImmediately = true;
            result.requestRedirection = false;
        } else {
            Log.w(this, "Unhandled Intent %s. Ignoring and not placing call.", intent);
            result.disconnectCause = DisconnectCause.INVALID_NUMBER;
+48 −23
Original line number Diff line number Diff line
@@ -43,19 +43,38 @@ public class CallRedirectionConfirmDialogActivity extends Activity {
    public static final String EXTRA_REDIRECTION_APP_NAME =
            "android.telecom.extra.REDIRECTION_APP_NAME";

    private String mCallId;
    private AlertDialog mConfirmDialog;
    /**
     * Tracks whether the activity has stopped due to a loss of focus (e.g. use hitting the home
     * button) or whether its going to stop because a button in the dialog was pressed.
     */
    private boolean mHasLostFocus = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i(this, "CallRedirectionConfirmDialogActivity onCreate.");
        final CharSequence redirectionAppName = getIntent().getStringExtra(
                EXTRA_REDIRECTION_APP_NAME);
        mCallId = getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID);
        showDialog(redirectionAppName);
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (mHasLostFocus) {
            Log.i(this, "onStop: dialog lost focus; canceling redirection for call %s", mCallId);
            mConfirmDialog.dismiss();
            cancelRedirection();
        }
    }

    private void showDialog(final CharSequence redirectionAppName) {
        Log.i(this, "showDialog: confirming redirection with %s", redirectionAppName);

        final AlertDialog confirmDialog = new AlertDialog.Builder(this).create();
        mConfirmDialog = new AlertDialog.Builder(this).create();
        LayoutInflater layoutInflater = LayoutInflater.from(this);
        View dialogView = layoutInflater.inflate(R.layout.call_redirection_confirm_dialog, null);

@@ -67,10 +86,10 @@ public class CallRedirectionConfirmDialogActivity extends Activity {
                        TelecomBroadcastIntentProcessor.ACTION_PLACE_UNREDIRECTED_CALL,
                        null, CallRedirectionConfirmDialogActivity.this,
                        TelecomBroadcastReceiver.class);
                proceedWithoutRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
                        getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
                proceedWithoutRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID, mCallId);
                sendBroadcast(proceedWithoutRedirectedCall);
                confirmDialog.dismiss();
                mConfirmDialog.dismiss();
                mHasLostFocus = false;
                finish();
            }
        });
@@ -86,10 +105,10 @@ public class CallRedirectionConfirmDialogActivity extends Activity {
                                .ACTION_PLACE_REDIRECTED_CALL, null,
                        CallRedirectionConfirmDialogActivity.this,
                        TelecomBroadcastReceiver.class);
                proceedWithRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
                        getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
                proceedWithRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID, mCallId);
                sendBroadcast(proceedWithRedirectedCall);
                confirmDialog.dismiss();
                mConfirmDialog.dismiss();
                mHasLostFocus = false;
                finish();
            }
        });
@@ -101,36 +120,42 @@ public class CallRedirectionConfirmDialogActivity extends Activity {
                        TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL,
                        null, CallRedirectionConfirmDialogActivity.this,
                        TelecomBroadcastReceiver.class);
                cancelRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
                        getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
                cancelRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID, mCallId);
                sendBroadcast(cancelRedirectedCall);
                confirmDialog.dismiss();
                mConfirmDialog.dismiss();
                mHasLostFocus = false;
                finish();
            }
        });

        confirmDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        mConfirmDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                Intent cancelRedirectedCall = new Intent(
                        TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL,
                        null, CallRedirectionConfirmDialogActivity.this,
                        TelecomBroadcastReceiver.class);
                cancelRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID,
                        getIntent().getStringExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID));
                sendBroadcast(cancelRedirectedCall);
                cancelRedirection();
                dialog.dismiss();
                mHasLostFocus = false;
                finish();
            }
        });

        confirmDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        mConfirmDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

        confirmDialog.setCancelable(false);
        confirmDialog.setCanceledOnTouchOutside(false);
        mConfirmDialog.setCancelable(false);
        mConfirmDialog.setCanceledOnTouchOutside(false);
        mConfirmDialog.setView(dialogView);

        confirmDialog.setView(dialogView);
        mConfirmDialog.show();
    }

        confirmDialog.show();
    /**
     * Signals to Telecom that redirection of the call is to be cancelled.
     */
    private void cancelRedirection() {
        Intent cancelRedirectedCall = new Intent(
                TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL,
                null, CallRedirectionConfirmDialogActivity.this,
                TelecomBroadcastReceiver.class);
        cancelRedirectedCall.putExtra(EXTRA_REDIRECTION_OUTGOING_CALL_ID, mCallId);
        sendBroadcast(cancelRedirectedCall);
    }
}
+76 −0
Original line number Diff line number Diff line
@@ -413,6 +413,82 @@ public class CallAudioModeTransitionTests extends TelecomTestCase {
                NO_CHANGE // expectedCallWaitingInteraction
        ));

        result.add(new ModeTestParameters(
                "Swap between voip and sim calls - 1",
                CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState
                CallAudioModeStateMachine.NEW_HOLDING_CALL, // messageType
                new CallAudioModeStateMachine.MessageArgs(
                        false, // hasActiveOrDialingCalls
                        false, // hasRingingCalls
                        true, // hasHoldingCalls
                        false, // isTonePlaying
                        true, // foregroundCallIsVoip
                        null // session
                ),
                CallAudioModeStateMachine.COMMS_STATE_NAME, // expectedFinalStateName
                FOCUS_VOICE, // expectedFocus
                AudioManager.MODE_IN_COMMUNICATION, // expectedMode
                NO_CHANGE, // expectedRingingInteraction
                NO_CHANGE // expectedCallWaitingInteraction
        ));

        result.add(new ModeTestParameters(
                "Swap between voip and sim calls - 2",
                CallAudioModeStateMachine.ENTER_COMMS_FOCUS_FOR_TESTING, // initialAudioState
                CallAudioModeStateMachine.NEW_HOLDING_CALL, // messageType
                new CallAudioModeStateMachine.MessageArgs(
                        false, // hasActiveOrDialingCalls
                        false, // hasRingingCalls
                        true, // hasHoldingCalls
                        false, // isTonePlaying
                        false, // foregroundCallIsVoip
                        null // session
                ),
                CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName
                FOCUS_VOICE, // expectedFocus
                AudioManager.MODE_IN_CALL, // expectedMode
                NO_CHANGE, // expectedRingingInteraction
                NO_CHANGE // expectedCallWaitingInteraction
        ));

        result.add(new ModeTestParameters(
                "Swap between voip and sim calls - 3",
                CallAudioModeStateMachine.ENTER_COMMS_FOCUS_FOR_TESTING, // initialAudioState
                CallAudioModeStateMachine.NEW_ACTIVE_OR_DIALING_CALL, // messageType
                new CallAudioModeStateMachine.MessageArgs(
                        false, // hasActiveOrDialingCalls
                        false, // hasRingingCalls
                        true, // hasHoldingCalls
                        false, // isTonePlaying
                        false, // foregroundCallIsVoip
                        null // session
                ),
                CallAudioModeStateMachine.CALL_STATE_NAME, // expectedFinalStateName
                FOCUS_VOICE, // expectedFocus
                AudioManager.MODE_IN_CALL, // expectedMode
                NO_CHANGE, // expectedRingingInteraction
                NO_CHANGE // expectedCallWaitingInteraction
        ));

        result.add(new ModeTestParameters(
                "Swap between voip and sim calls - 4",
                CallAudioModeStateMachine.ENTER_CALL_FOCUS_FOR_TESTING, // initialAudioState
                CallAudioModeStateMachine.NEW_HOLDING_CALL, // messageType
                new CallAudioModeStateMachine.MessageArgs(
                        false, // hasActiveOrDialingCalls
                        false, // hasRingingCalls
                        true, // hasHoldingCalls
                        false, // isTonePlaying
                        true, // foregroundCallIsVoip
                        null // session
                ),
                CallAudioModeStateMachine.COMMS_STATE_NAME, // expectedFinalStateName
                FOCUS_VOICE, // expectedFocus
                AudioManager.MODE_IN_COMMUNICATION, // expectedMode
                NO_CHANGE, // expectedRingingInteraction
                NO_CHANGE // expectedCallWaitingInteraction
        ));

        result.add(new ModeTestParameters(
                "Call is taken off hold - 1",
                CallAudioModeStateMachine.ENTER_TONE_OR_HOLD_FOCUS_FOR_TESTING, // initialAudioState