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

Commit f60accf6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Grace Jia
Browse files

Notify new adding calls if the ICS has already bound.

For some reason, ICS may got bound before a new call added to
InCallController. In these cases, make sure that ICS got notified about
these calls.

Bug: 193596941
Test: TelecomUnitTests, manually test if a new incoming call during VOIP
can route to BT properly

Change-Id: Id4835922af707c7aa87b03f14af4eb61df2aca77
parent 38adb951
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;
    }

    /**