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

Commit 33837110 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Notify new adding calls if the ICS has already bound." into sc-dev

parents 1b4d30c3 f60accf6
Loading
Loading
Loading
Loading
+45 −31
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.os.RemoteException;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.DeviceConfig;
import android.telecom.CallAudioState;
import android.telecom.ConnectionService;
import android.telecom.InCallService;
@@ -282,7 +281,16 @@ public class InCallController extends CallsManagerListenerBase implements
        @Override
        public int connect(Call call) {
            if (mIsConnected) {
                Log.addEvent(call, LogUtils.Events.INFO, "Already connected, ignoring request.");
                Log.addEvent(call, LogUtils.Events.INFO, "Already connected, ignoring request: "
                        + mInCallServiceInfo);
                if (call != null) {
                    // Track the call if we don't already know about it.
                    addCall(call);

                    // Notify this new added call
                    sendCallToService(call, mInCallServiceInfo,
                            mInCallServices.get(mInCallServiceInfo));
                }
                return CONNECTION_SUCCEEDED;
            }

@@ -1864,11 +1872,29 @@ public class InCallController extends CallsManagerListenerBase implements
                "calls", calls.size(), info.getComponentName());
        int numCallsSent = 0;
        for (Call call : calls) {
            numCallsSent += sendCallToService(call, info, inCallService);
        }
        try {
            inCallService.onCallAudioStateChanged(mCallsManager.getAudioState());
            inCallService.onCanAddCallChanged(mCallsManager.canAddCall());
        } catch (RemoteException ignored) {
        }
        // Don't complete the binding future for non-ui incalls
        if (info.getType() != IN_CALL_SERVICE_TYPE_NON_UI && !mBindingFuture.isDone()) {
            mBindingFuture.complete(true);
        }

        Log.i(this, "%s calls sent to InCallService.", numCallsSent);
        return true;
    }

    private int sendCallToService(Call call, InCallServiceInfo info,
            IInCallService inCallService) {
        try {
            if ((call.isSelfManaged() && (!info.isSelfManagedCallsSupported()
                    || !call.visibleToInCallService())) ||
                    (call.isExternalCall() && !info.isExternalCallsSupported())) {
                    continue;
                return 0;
            }

            // Only send the RTT call if it's a UI in-call service
@@ -1879,7 +1905,6 @@ public class InCallController extends CallsManagerListenerBase implements

            // Track the call if we don't already know about it.
            addCall(call);
                numCallsSent += 1;
            ParcelableCall parcelableCall = ParcelableCallUtils.toParcelableCall(
                    call,
                    true /* includeVideoProvider */,
@@ -1890,21 +1915,10 @@ public class InCallController extends CallsManagerListenerBase implements
                            info.getType() == IN_CALL_SERVICE_TYPE_NON_UI);
            inCallService.addCall(sanitizeParcelableCallForService(info, parcelableCall));
            updateCallTracking(call, info, true /* isAdd */);
            return 1;
        } catch (RemoteException ignored) {
        }
        }
        try {
            inCallService.onCallAudioStateChanged(mCallsManager.getAudioState());
            inCallService.onCanAddCallChanged(mCallsManager.canAddCall());
        } catch (RemoteException ignored) {
        }
        // Don't complete the binding future for non-ui incalls
        if (info.getType() != IN_CALL_SERVICE_TYPE_NON_UI) {
            mBindingFuture.complete(true);
        }

        Log.i(this, "%s calls sent to InCallService.", numCallsSent);
        return true;
        return 0;
    }

    /**