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

Commit f0b2a955 authored by Grace Jia's avatar Grace Jia
Browse files

Revert "Implement new TelecomManager API for cross device calling."

Revert "Add API for cross device calling."

Revert "Add cts tests for new cross device calling api"

Revert submission 16308056-cross-api

Reason for revert: Don't want to launch this in T now
Reverted Changes:
I731226c0b:Add cts tests for new cross device calling api
I1a3aa6c1a:Add API for cross device calling.
I40f78925b:Implement new TelecomManager API for cross device ...

Change-Id: I809ce42e720135200f04b5abec63a0eb9e0df71e
parent 364e0d26
Loading
Loading
Loading
Loading
+12 −145
Original line number Original line Diff line number Diff line
@@ -41,7 +41,6 @@ import android.telecom.BluetoothCallQualityReport;
import android.telecom.CallAudioState;
import android.telecom.CallAudioState;
import android.telecom.CallDiagnosticService;
import android.telecom.CallDiagnosticService;
import android.telecom.CallDiagnostics;
import android.telecom.CallDiagnostics;
import android.telecom.CallEndpoint;
import android.telecom.CallerInfo;
import android.telecom.CallerInfo;
import android.telecom.Conference;
import android.telecom.Conference;
import android.telecom.Connection;
import android.telecom.Connection;
@@ -77,7 +76,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collection;
import java.util.Collections;
import java.util.Collections;
import java.util.Date;
import java.util.Date;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.LinkedList;
import java.util.List;
import java.util.List;
import java.util.Locale;
import java.util.Locale;
@@ -169,14 +167,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        void onReceivedDeviceToDeviceMessage(Call call, int messageType, int messageValue);
        void onReceivedDeviceToDeviceMessage(Call call, int messageType, int messageValue);
        void onReceivedCallQualityReport(Call call, CallQuality callQuality);
        void onReceivedCallQualityReport(Call call, CallQuality callQuality);
        void onCallerNumberVerificationStatusChanged(Call call, int callerNumberVerificationStatus);
        void onCallerNumberVerificationStatusChanged(Call call, int callerNumberVerificationStatus);
        void onActiveCallEndpointChanged(Call call, CallEndpoint callEndpoint);
        void onAvailableCallEndpointsChanged(Call call);
        void onCallPushFailed(Call call, CallEndpoint callEndpoint,
                @android.telecom.Call.Callback.PushFailedReason int reason);
        void onCallPullFailed(Call call,
                @android.telecom.Call.Callback.PullFailedReason int reason);
        void onAnswerFailed(Call call, CallEndpoint callEndpoint,
                @android.telecom.Call.Callback.AnswerFailedReason int reason);
    }
    }


    public abstract static class ListenerBase implements Listener {
    public abstract static class ListenerBase implements Listener {
@@ -277,19 +267,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        @Override
        @Override
        public void onCallerNumberVerificationStatusChanged(Call call,
        public void onCallerNumberVerificationStatusChanged(Call call,
                int callerNumberVerificationStatus) {}
                int callerNumberVerificationStatus) {}
        @Override
        public void onActiveCallEndpointChanged(Call call, CallEndpoint callEndpoint) {}
        @Override
        public void onAvailableCallEndpointsChanged(Call call) {}
        @Override
        public void onCallPushFailed(Call call, CallEndpoint callEndpoint,
                @android.telecom.Call.Callback.PushFailedReason int reason) {}
        @Override
        public void onCallPullFailed(Call call,
                @android.telecom.Call.Callback.PullFailedReason int reason) {}
        @Override
        public void onAnswerFailed(Call call, CallEndpoint callEndpoint,
                @android.telecom.Call.Callback.AnswerFailedReason int reason) {}
    }
    }


    private final CallerInfoLookupHelper.OnQueryCompleteListener mCallerInfoQueryListener =
    private final CallerInfoLookupHelper.OnQueryCompleteListener mCallerInfoQueryListener =
@@ -498,9 +475,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    /** Whether an attempt has been made to load the text message responses. */
    /** Whether an attempt has been made to load the text message responses. */
    private boolean mCannedSmsResponsesLoadingStarted = false;
    private boolean mCannedSmsResponsesLoadingStarted = false;


    private CallEndpoint mActiveCallEndpoint = null;
    private Set<CallEndpoint> mAvailableCallEndpoints = new HashSet<>();

    private IVideoProvider mVideoProvider;
    private IVideoProvider mVideoProvider;
    private VideoProviderProxy mVideoProviderProxy;
    private VideoProviderProxy mVideoProviderProxy;


@@ -510,7 +484,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    private final ConnectionServiceRepository mRepository;
    private final ConnectionServiceRepository mRepository;
    private final Context mContext;
    private final Context mContext;
    private final CallsManager mCallsManager;
    private final CallsManager mCallsManager;
    private final CallEndpointController mCallEndpointController;
    private final ClockProxy mClockProxy;
    private final ClockProxy mClockProxy;
    private final ToastFactory mToastFactory;
    private final ToastFactory mToastFactory;
    private final TelecomSystem.SyncRoot mLock;
    private final TelecomSystem.SyncRoot mLock;
@@ -523,7 +496,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    private boolean mWasHighDefAudio = false;
    private boolean mWasHighDefAudio = false;
    private boolean mWasWifi = false;
    private boolean mWasWifi = false;
    private boolean mWasVolte = false;
    private boolean mWasVolte = false;
    private boolean mTethered = false;


    // For conferences which support merge/swap at their level, we retain a notion of an active
    // For conferences which support merge/swap at their level, we retain a notion of an active
    // call. This is used for BluetoothPhoneService.  In order to support hold/merge, it must have
    // call. This is used for BluetoothPhoneService.  In order to support hold/merge, it must have
@@ -784,8 +756,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                CallState.ACTIVE : CallState.NEW;
                CallState.ACTIVE : CallState.NEW;
        mContext = context;
        mContext = context;
        mCallsManager = callsManager;
        mCallsManager = callsManager;
        mCallEndpointController = mCallsManager.getCallEndpointController();
        mAvailableCallEndpoints = mCallEndpointController.getCallEndpoints();
        mLock = lock;
        mLock = lock;
        mRepository = repository;
        mRepository = repository;
        mPhoneNumberUtilsAdapter = phoneNumberUtilsAdapter;
        mPhoneNumberUtilsAdapter = phoneNumberUtilsAdapter;
@@ -1679,10 +1649,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                Connection.PROPERTY_IS_EXTERNAL_CALL;
                Connection.PROPERTY_IS_EXTERNAL_CALL;
    }
    }


    public boolean isTetheredCall() {
        return mTethered;
    }

    public boolean isWorkCall() {
    public boolean isWorkCall() {
        return mIsWorkCall;
        return mIsWorkCall;
    }
    }
@@ -2000,19 +1966,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        return capabilities;
        return capabilities;
    }
    }


    public void setTethered(boolean isTethered) {
        boolean wasTethered = mTethered;
        if (wasTethered != isTethered) {
            Log.v(this, "setConnectionProperties: tethered call changed isTethered = %b, ",
                    isTethered);
            Log.addEvent(this, LogUtils.Events.IS_TETHERED, isTethered);
            for (Listener l : mListeners) {
                l.onTetheredCallChanged(this, isTethered);
            }
        }
        mTethered = isTethered;
    }

    public void setConnectionProperties(int connectionProperties) {
    public void setConnectionProperties(int connectionProperties) {
        Log.v(this, "setConnectionProperties: %s", Connection.propertiesToString(
        Log.v(this, "setConnectionProperties: %s", Connection.propertiesToString(
                connectionProperties));
                connectionProperties));
@@ -2067,6 +2020,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                    == Connection.PROPERTY_IS_EXTERNAL_CALL;
                    == Connection.PROPERTY_IS_EXTERNAL_CALL;
            boolean isExternal = (connectionProperties & Connection.PROPERTY_IS_EXTERNAL_CALL)
            boolean isExternal = (connectionProperties & Connection.PROPERTY_IS_EXTERNAL_CALL)
                    == Connection.PROPERTY_IS_EXTERNAL_CALL;
                    == Connection.PROPERTY_IS_EXTERNAL_CALL;
            boolean wasTethered = (previousProperties & Connection.PROPERTY_TETHERED_CALL)
                    == Connection.PROPERTY_TETHERED_CALL;
            boolean isTethered = (connectionProperties & Connection.PROPERTY_TETHERED_CALL)
                    == Connection.PROPERTY_TETHERED_CALL;
            if (wasExternal != isExternal) {
            if (wasExternal != isExternal) {
                Log.v(this, "setConnectionProperties: external call changed isExternal = %b, ",
                Log.v(this, "setConnectionProperties: external call changed isExternal = %b, ",
                        isExternal);
                        isExternal);
@@ -2081,6 +2038,14 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                    l.onExternalCallChanged(this, isExternal);
                    l.onExternalCallChanged(this, isExternal);
                }
                }
            }
            }
            if (wasTethered != isTethered) {
                Log.v(this, "setConnectionProperties: tethered call changed isTethered = %b, ",
                        isTethered);
                Log.addEvent(this, LogUtils.Events.IS_TETHERED, isTethered);
                for (Listener l : mListeners) {
                    l.onTetheredCallChanged(this, isTethered);
                }
            }


            boolean wasDowngradedConference =
            boolean wasDowngradedConference =
                    (previousProperties & Connection.PROPERTY_IS_DOWNGRADED_CONFERENCE) != 0;
                    (previousProperties & Connection.PROPERTY_IS_DOWNGRADED_CONFERENCE) != 0;
@@ -2539,33 +2504,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        }
        }
    }
    }


    /**
     * Answers the call via given {@link CallEndpoint} if it is ringing.
     *
     * @param callEndpoint The call endpoint on which the call will be answered.
     * @param videoState The video state in which to answer the call.
     */
    @VisibleForTesting
    public void answer(CallEndpoint callEndpoint, int videoState) {
        // Check to verify that the call is still in the ringing state.
        if (isRinging("answer")) {
            if (!isVideoCallingSupportedByPhoneAccount() && VideoProfile.isVideo(videoState)) {
                // Video calling is not supported, yet the InCallService is attempting to answer as
                // video.  We will simply answer as audio-only.
                videoState = VideoProfile.STATE_AUDIO_ONLY;
            }
            if (mConnectionService != null) {
                if (callEndpoint.getType() == CallEndpoint.ENDPOINT_TYPE_TETHERED) {
                    mCallEndpointController.requestAnswerCall(this, callEndpoint, videoState);
                }
            } else {
                Log.e(this, new NullPointerException(),
                        "answer call externally failed due to null CS callId=%s", getId());
            }
            Log.addEvent(this, LogUtils.Events.REQUEST_ACCEPT);
        }
    }

    /**
    /**
     * Answers the call on the connectionservice side in order to start audio processing.
     * Answers the call on the connectionservice side in order to start audio processing.
     *
     *
@@ -3070,29 +3008,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        mConnectionService.pullExternalCall(this);
        mConnectionService.pullExternalCall(this);
    }
    }


    /**
     * Initiates a request to push the call to a {@link CallEndpoint}.
     * @param endpoint
     */
    public void pushCall(CallEndpoint endpoint) {
        if (mConnectionService == null) {
            Log.w(this, "pushCall - call %s don't have a connection service.");
        }

        if (mCallsManager.isInEmergencyCall()) {
            Log.w(this, "pushCall - call %s can not be pushed while an emergency"
                    + " call is in progress.", mId);
            mToastFactory.makeText(mContext, R.string.toast_emergency_can_not_pull_call,
                    Toast.LENGTH_LONG).show();
            return;
        }

        Log.addEvent(this, LogUtils.Events.REQUEST_PULL);
        if (endpoint.getType() == CallEndpoint.ENDPOINT_TYPE_TETHERED) {
            mCallEndpointController.requestPushCall(this, endpoint);
        }
    }

    /**
    /**
     * Sends a call event to the {@link ConnectionService} for this call. This function is
     * Sends a call event to the {@link ConnectionService} for this call. This function is
     * called for event other than {@link Call#EVENT_REQUEST_HANDOVER}
     * called for event other than {@link Call#EVENT_REQUEST_HANDOVER}
@@ -4348,52 +4263,4 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            mDisconnectFuture = null;
            mDisconnectFuture = null;
        }
        }
    }
    }

    public void setActiveCallEndpoint(CallEndpoint callEndpoint) {
        if (mActiveCallEndpoint == null || !mActiveCallEndpoint.equals(callEndpoint)) {
            if (callEndpoint != null) {
                // Set mTethered according to call endpoint type
                setTethered(callEndpoint.getType() == CallEndpoint.ENDPOINT_TYPE_TETHERED);
            } else {
                // Set off mTethered
                setTethered(false /* isTethered */);
            }

            mActiveCallEndpoint = callEndpoint;
            for (Listener listener : mListeners) {
                listener.onActiveCallEndpointChanged(this, callEndpoint);
            }
        }
    }

    public CallEndpoint getActiveCallEndpoint() {
        return mActiveCallEndpoint;
    }

    public void updateAvailableCallEndpoints(Set<CallEndpoint> callEndpoints) {
        if (callEndpoints != null) {
            mAvailableCallEndpoints = callEndpoints;
            for (Listener listener : mListeners) {
                listener.onAvailableCallEndpointsChanged(this);
            }
        }
    }

    public void onAnswerFailed(CallEndpoint callEndpoint,
            @android.telecom.Call.Callback.AnswerFailedReason int reason) {
        for (Listener listener : mListeners) {
            listener.onAnswerFailed(this, callEndpoint, reason);
        }
    }

    public void onPushFailed(CallEndpoint callEndpoint,
            @android.telecom.Call.Callback.PullFailedReason int reason) {
        for (Listener listener : mListeners) {
            listener.onCallPushFailed(this, callEndpoint, reason);
        }
    }

    public Set<CallEndpoint> getAvailableCallEndpoints() {
        return mAvailableCallEndpoints;
    }
}
}
+23 −42
Original line number Original line Diff line number Diff line
@@ -160,19 +160,17 @@ public class CallAudioManager extends CallsManagerListenerBase {
            newBinForCall.add(call);
            newBinForCall.add(call);
        }
        }
        updateForegroundCall();
        updateForegroundCall();
        if (!call.isExternalCall()) {
        mCalls.add(call);
        mCalls.add(call);
        } else if (call.isTetheredCall() && mTetheredCalls.add(call)) {
            onCallBecomingTethered();
        }
        sendCallStatusToBluetoothStateReceiver();
        sendCallStatusToBluetoothStateReceiver();


        onCallEnteringState(call, call.getState());
        onCallEnteringState(call, call.getState());
    }
    }


    private void removeCall(Call call) {
    private void removeCall(Call call) {
        if (mCalls.contains(call)) {
        if (!mCalls.contains(call)) {
            // No guarantees that the same call won't get removed twice.
            return; // No guarantees that the same call won't get removed twice.
        }

        Log.d(LOG_TAG, "Call removed with id TC@%s in state %s", call.getId(),
        Log.d(LOG_TAG, "Call removed with id TC@%s in state %s", call.getId(),
                CallState.toString(call.getState()));
                CallState.toString(call.getState()));


@@ -180,14 +178,9 @@ public class CallAudioManager extends CallsManagerListenerBase {


        updateForegroundCall();
        updateForegroundCall();
        mCalls.remove(call);
        mCalls.remove(call);

        sendCallStatusToBluetoothStateReceiver();
        sendCallStatusToBluetoothStateReceiver();


        onCallLeavingState(call, call.getState());
        onCallLeavingState(call, call.getState());
        } else if (mTetheredCalls.contains(call)) {
            mTetheredCalls.remove(call);
            onCallLeavingTethered();
        }
    }
    }


    private void sendCallStatusToBluetoothStateReceiver() {
    private void sendCallStatusToBluetoothStateReceiver() {
@@ -234,15 +227,19 @@ public class CallAudioManager extends CallsManagerListenerBase {
    public void onTetheredCallChanged(Call call, boolean isTetheredCall) {
    public void onTetheredCallChanged(Call call, boolean isTetheredCall) {
        if (isTetheredCall) {
        if (isTetheredCall) {
            Log.d(LOG_TAG, "Switching to external route because call %s became tethered "
            Log.d(LOG_TAG, "Switching to external route because call %s became tethered "
                    + "call.", call.getId());
                    + " external call.", call.getId());
            if (mTetheredCalls.add(call)) {
            removeCall(call);
                onCallBecomingTethered();
            mTetheredCalls.add(call);
            }
            mCallAudioModeStateMachine.sendMessageWithArgs(
                    CallAudioModeStateMachine.NEW_TETHERED_EXTERNAL_CALL,
                    makeArgsForModeStateMachine());
        } else {
        } else {
            Log.d(LOG_TAG, "Exit external route because call %s is no longer a tethered "
                    + "call.", call.getId());
            mTetheredCalls.remove(call);
            mTetheredCalls.remove(call);
            onCallLeavingTethered();
            if (mTetheredCalls.size() == 0) {
                mCallAudioModeStateMachine.sendMessageWithArgs(
                        CallAudioModeStateMachine.NO_MORE_TETHERED_CALLS,
                        makeArgsForModeStateMachine());
            }
        }
        }
    }
    }


@@ -255,7 +252,7 @@ public class CallAudioManager extends CallsManagerListenerBase {
         * otherwise
         * otherwise
         */
         */
    private boolean shouldIgnoreCallForAudio(Call call) {
    private boolean shouldIgnoreCallForAudio(Call call) {
        return call.getParentCall() != null || (call.isExternalCall() && !call.isTetheredCall());
        return call.getParentCall() != null || call.isExternalCall();
    }
    }


    @Override
    @Override
@@ -723,22 +720,6 @@ public class CallAudioManager extends CallsManagerListenerBase {
        }
        }
    }
    }


    private void onCallBecomingTethered() {
        if (mTetheredCalls.size() != 0) {
            mCallAudioModeStateMachine.sendMessageWithArgs(
                    CallAudioModeStateMachine.NEW_TETHERED_EXTERNAL_CALL,
                    makeArgsForModeStateMachine());
        }
    }

    private void onCallLeavingTethered() {
        if (mTetheredCalls.size() == 0) {
            mCallAudioModeStateMachine.sendMessageWithArgs(
                    CallAudioModeStateMachine.NO_MORE_TETHERED_CALLS,
                    makeArgsForModeStateMachine());
        }
    }

    private void updateForegroundCall() {
    private void updateForegroundCall() {
        Call oldForegroundCall = mForegroundCall;
        Call oldForegroundCall = mForegroundCall;
        if (mActiveDialingOrConnectingCalls.size() > 0) {
        if (mActiveDialingOrConnectingCalls.size() > 0) {
+0 −432

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −26
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.telecom;

import android.content.Context;

/**
 * Abstracts out creation of CallEndpointController for unit test purposes.
 */
public interface CallEndpointControllerFactory {
    CallEndpointController create(TelecomSystem.SyncRoot lock, CallsManager callsManager);
}
+0 −91
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.telecom;

import android.os.Handler;
import android.os.Looper;
import android.telecom.CallEndpoint;
import android.telecom.VideoProfile;

import com.android.internal.telecom.ICallEndpointCallback;

public class CallEndpointSessionTracker {
    private final Handler mHandler = new Handler(Looper.getMainLooper());

    private final Call mCall;
    private final CallEndpoint mCallEndpoint;
    private final int mRequestType;
    private final @VideoProfile.VideoState int mVideoState;
    private InternalCallEndpointSession mSession;
    private ICallEndpointCallback mCallEndpointCallback;
    private boolean mRequestHandled;

    public CallEndpointSessionTracker(InternalCallEndpointSession internalCallEndpointSession,
            int requestType) {
        this(internalCallEndpointSession, requestType, 0 /* VideoState */);
    }

    public CallEndpointSessionTracker(InternalCallEndpointSession internalCallEndpointSession,
            int requestType, @VideoProfile.VideoState int videoState) {
        mSession = internalCallEndpointSession;
        mCall = mSession.getCall();
        mCallEndpoint = mSession.getCallEndpoint();
        mRequestType = requestType;
        mVideoState = videoState;
        mRequestHandled = false;
    }

    public InternalCallEndpointSession getSession() {
        return mSession;
    }

    public void setCallEndpointCallback(ICallEndpointCallback callEndpointCallback) {
        mCallEndpointCallback = callEndpointCallback;
    }

    public ICallEndpointCallback getCallEndpointCallback() {
        return mCallEndpointCallback;
    }

    public Handler getHandler() {
        return mHandler;
    }

    public boolean isRequestHandled() {
        return mRequestHandled;
    }

    public void setRequestHandled(boolean requestHandled) {
        mRequestHandled = requestHandled;
    }

    public CallEndpoint getCallEndpoint() {
        return mCallEndpoint;
    }

    public int getRequestType() {
        return mRequestType;
    }

    public @VideoProfile.VideoState int getVideoState() {
        return mVideoState;
    }

    public Call getCall() {
        return mCall;
    }
}
Loading