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

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

Snap for 4683893 from 1f3efbd7 to pi-release

Change-Id: I1d2676186c9e462db2199e102e223040ab4bedc9
parents 155c1a99 1f3efbd7
Loading
Loading
Loading
Loading
+26 −8
Original line number Diff line number Diff line
@@ -1734,20 +1734,28 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        disconnect(0);
    }

    @VisibleForTesting
    public void disconnect(String reason) {
        disconnect(0, reason);
    }

    /**
     * Attempts to disconnect the call through the connection service.
     */
    @VisibleForTesting
    public void disconnect(long disconnectionTimeout) {
        disconnect(disconnectionTimeout, "internal" /** callingPackage */);
        disconnect(disconnectionTimeout, "internal" /** reason */);
    }

    /**
     * Attempts to disconnect the call through the connection service.
     * @param reason the reason for the disconnect; used for logging purposes only.  In some cases
     *               this can be a package name if the disconnect was initiated through an API such
     *               as TelecomManager.
     */
    @VisibleForTesting
    public void disconnect(long disconnectionTimeout, String callingPackage) {
        Log.addEvent(this, LogUtils.Events.REQUEST_DISCONNECT, callingPackage);
    public void disconnect(long disconnectionTimeout, String reason) {
        Log.addEvent(this, LogUtils.Events.REQUEST_DISCONNECT, reason);

        // Track that the call is now locally disconnecting.
        setLocallyDisconnecting(true);
@@ -1868,7 +1876,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    @VisibleForTesting
    public void reject(boolean rejectWithMessage, String textMessage) {
        reject(rejectWithMessage, textMessage, "internal" /** callingPackage */);
        reject(rejectWithMessage, textMessage, "internal" /** reason */);
    }

    /**
@@ -1876,9 +1884,11 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     *
     * @param rejectWithMessage Whether to send a text message as part of the call rejection.
     * @param textMessage An optional text message to send as part of the rejection.
     * @param reason The reason for the reject; used for logging purposes.  May be a package name
     *               if the reject is initiated from an API such as TelecomManager.
     */
    @VisibleForTesting
    public void reject(boolean rejectWithMessage, String textMessage, String callingPackage) {
    public void reject(boolean rejectWithMessage, String textMessage, String reason) {
        // Check to verify that the call is still in the ringing state. A call can change states
        // between the time the user hits 'reject' and Telecomm receives the command.
        if (isRinging("reject")) {
@@ -1891,7 +1901,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                Log.e(this, new NullPointerException(),
                        "reject call failed due to null CS callId=%s", getId());
            }
            Log.addEvent(this, LogUtils.Events.REQUEST_REJECT, callingPackage);
            Log.addEvent(this, LogUtils.Events.REQUEST_REJECT, reason);
        }
    }

@@ -1900,6 +1910,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    @VisibleForTesting
    public void hold() {
        hold(null /* reason */);
    }

    public void hold(String reason) {
        if (mState == CallState.ACTIVE) {
            if (mConnectionService != null) {
                mConnectionService.hold(this);
@@ -1907,7 +1921,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                Log.e(this, new NullPointerException(),
                        "hold call failed due to null CS callId=%s", getId());
            }
            Log.addEvent(this, LogUtils.Events.REQUEST_HOLD);
            Log.addEvent(this, LogUtils.Events.REQUEST_HOLD, reason);
        }
    }

@@ -1916,6 +1930,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    @VisibleForTesting
    public void unhold() {
        unhold(null /* reason */);
    }

    public void unhold(String reason) {
        if (mState == CallState.ON_HOLD) {
            if (mConnectionService != null) {
                mConnectionService.unhold(this);
@@ -1923,7 +1941,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                Log.e(this, new NullPointerException(),
                        "unhold call failed due to null CS callId=%s", getId());
            }
            Log.addEvent(this, LogUtils.Events.REQUEST_UNHOLD);
            Log.addEvent(this, LogUtils.Events.REQUEST_UNHOLD, reason);
        }
    }

+2 −1
Original line number Diff line number Diff line
@@ -388,7 +388,8 @@ public class CallAudioManager extends CallsManagerListenerBase {

    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public void onRingerModeChange() {
        mCallAudioModeStateMachine.sendMessage(CallAudioModeStateMachine.RINGER_MODE_CHANGE);
        mCallAudioModeStateMachine.sendMessageWithArgs(
                CallAudioModeStateMachine.RINGER_MODE_CHANGE, makeArgsForModeStateMachine());
    }

    @VisibleForTesting
+26 −19
Original line number Diff line number Diff line
@@ -286,7 +286,8 @@ public class CallsManager extends Call.ListenerBase
                        ConnectionServiceFocusManager.ConnectionServiceFocus connectionService) {
                    mCalls.stream()
                            .filter(c -> c.getConnectionServiceWrapper().equals(connectionService))
                            .forEach(c -> c.disconnect());
                            .forEach(c -> c.disconnect("release " +
                                    connectionService.getComponentName().getPackageName()));
                }

                @Override
@@ -1491,7 +1492,7 @@ public class CallsManager extends Call.ListenerBase
                    // service, then disconnect it, otherwise allow the connection service to
                    // figure out the right states.
                    if (activeCall.getConnectionService() != call.getConnectionService()) {
                        activeCall.disconnect();
                        activeCall.disconnect("Can't hold when answering " + call.getId());
                    }
                }
            }
@@ -1683,25 +1684,27 @@ public class CallsManager extends Call.ListenerBase
            Log.w(this, "Unknown call (%s) asked to be removed from hold", call);
        } else {
            Call activeCall = (Call) mConnectionSvrFocusMgr.getCurrentFocusCall();
            String activeCallId = null;
            if (activeCall != null) {
                activeCallId = activeCall.getId();
                if (canHold(activeCall)) {
                    activeCall.hold();
                    Log.addEvent(activeCall, LogUtils.Events.SWAP);
                    Log.addEvent(call, LogUtils.Events.SWAP);
                    activeCall.hold("Swap to " + call.getId());
                    Log.addEvent(activeCall, LogUtils.Events.SWAP, "To " + call.getId());
                    Log.addEvent(call, LogUtils.Events.SWAP, "From " + activeCall.getId());
                } else {
                    // This call does not support hold. If it is from a different connection
                    // service, then disconnect it, otherwise invoke call.hold() and allow the
                    // connection service to handle the situation.
                    if (activeCall.getConnectionService() != call.getConnectionService()) {
                        activeCall.disconnect();
                        activeCall.disconnect("Swap to " + call.getId());
                    } else {
                        activeCall.hold();
                        activeCall.hold("Swap to " + call.getId());
                    }
                }
            }
            mConnectionSvrFocusMgr.requestFocus(
                    call,
                    new RequestCallback(new ActionUnHoldCall(call)));
                    new RequestCallback(new ActionUnHoldCall(call, activeCallId)));
        }
    }

@@ -1879,7 +1882,7 @@ public class CallsManager extends Call.ListenerBase
            if (makeRoomForOutgoingCall(call, false /* isEmergencyCall */)) {
                call.startCreateConnection(mPhoneAccountRegistrar);
            } else {
                call.disconnect();
                call.disconnect("no room");
            }

            if (setDefault) {
@@ -2838,7 +2841,7 @@ public class CallsManager extends Call.ListenerBase
            if (isEmergency && !canHold(liveCall)) {
                call.getAnalytics().setCallIsAdditional(true);
                liveCall.getAnalytics().setCallIsInterrupted(true);
                liveCall.disconnect();
                liveCall.disconnect("emergency, can't hold");
                return true;
            }

@@ -2881,7 +2884,7 @@ public class CallsManager extends Call.ListenerBase
                Log.i(this, "makeRoomForOutgoingCall: holding live call.");
                call.getAnalytics().setCallIsAdditional(true);
                liveCall.getAnalytics().setCallIsInterrupted(true);
                liveCall.hold();
                liveCall.hold("calling " + call.getId());
                return true;
            }

@@ -3180,7 +3183,7 @@ public class CallsManager extends Call.ListenerBase

            // We are going to place the new outgoing call, so disconnect any ongoing self-managed
            // calls which are ongoing at this time.
            disconnectSelfManagedCalls();
            disconnectSelfManagedCalls("outgoing call " + callId);

            // Kick of the new outgoing call intent from where it left off prior to confirming the
            // call.
@@ -3242,14 +3245,14 @@ public class CallsManager extends Call.ListenerBase
    /**
     * Disconnects all self-managed calls.
     */
    private void disconnectSelfManagedCalls() {
    private void disconnectSelfManagedCalls(String reason) {
        // Disconnect all self-managed calls to make priority for emergency call.
        // Use Call.disconnect() to command the ConnectionService to disconnect the calls.
        // CallsManager.markCallAsDisconnected doesn't actually tell the ConnectionService to
        // disconnect.
        mCalls.stream()
                .filter(c -> c.isSelfManaged())
                .forEach(c -> c.disconnect());
                .forEach(c -> c.disconnect(reason));

        // When disconnecting all self-managed calls, switch audio routing back to the baseline
        // route.  This ensures if, for example, the self-managed ConnectionService was routed to
@@ -3259,11 +3262,13 @@ public class CallsManager extends Call.ListenerBase
    }

    private void disconnectCallsHaveDifferentConnectionService(Call exceptCall) {
        String csPackage = exceptCall.getConnectionService() != null ?
                exceptCall.getConnectionService().getComponentName().toShortString() : "null";
        mCalls.stream().filter(c ->
                c.getConnectionService() != exceptCall.getConnectionService()
                        && c.getConnectionManagerPhoneAccount()
                        != exceptCall.getConnectionManagerPhoneAccount())
                .forEach(c -> c.disconnect());
                .forEach(c -> c.disconnect("CS not " + csPackage));
    }

    /**
@@ -3392,7 +3397,7 @@ public class CallsManager extends Call.ListenerBase
        ConnectionServiceWrapper service = call.getConnectionService();
        service.handoverFailed(call, reason);
        call.setDisconnectCause(new DisconnectCause(DisconnectCause.CANCELED));
        call.disconnect();
        call.disconnect("handover failed");
    }

    /**
@@ -3572,7 +3577,7 @@ public class CallsManager extends Call.ListenerBase
        } else {
            if (call.isEmergencyCall()) {
                // Disconnect all self-managed calls to make priority for emergency call.
                disconnectSelfManagedCalls();
                disconnectSelfManagedCalls("emergency call");
            }

            call.startCreateConnection(mPhoneAccountRegistrar);
@@ -3789,15 +3794,17 @@ public class CallsManager extends Call.ListenerBase

    private final class ActionUnHoldCall implements PendingAction {
        private final Call mCall;
        private final String mPreviouslyHeldCallId;

        ActionUnHoldCall(Call call) {
        ActionUnHoldCall(Call call, String previouslyHeldCallId) {
            mCall = call;
            mPreviouslyHeldCallId = previouslyHeldCallId;
        }

        @Override
        public void performAction() {
            Log.d(this, "perform unhold call for %s", mCall);
            mCall.unhold();
            mCall.unhold("held " + mPreviouslyHeldCallId);
        }
    }

+7 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.telecom;

import android.annotation.Nullable;
import android.content.ComponentName;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -64,6 +65,12 @@ public class ConnectionServiceFocusManager {
         * @see {@link ConnectionServiceFocusListener}.
         */
        void setConnectionServiceFocusListener(ConnectionServiceFocusListener listener);

        /**
         * Get the {@link ComponentName} of the ConnectionService for logging purposes.
         * @return the {@link ComponentName}.
         */
        ComponentName getComponentName();
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -309,7 +309,7 @@ abstract class ServiceBinder {
        }
    }

    final ComponentName getComponentName() {
    public final ComponentName getComponentName() {
        return mComponentName;
    }

Loading