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

Commit 775a0f3a authored by Hall Liu's avatar Hall Liu
Browse files

Refactor startOutgoingCall in CallsManager

Modify startOutgoingCall to use futures to manage the asynchronous
elements of starting an outgoing call (e.g. phone account selection,
prompting for user input, etc). This is done in preparation for adding
the phone account suggestion feature.

Bug: 111455117
Test: unit, manual
Change-Id: Ia0074738b7c4b146b3c9dbb6e425fe43bb0ac122
parent a2e4a7f1
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -551,8 +551,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            CallsManager callsManager,
            TelecomSystem.SyncRoot lock,
            ConnectionServiceRepository repository,
            ContactsAsyncHelper contactsAsyncHelper,
            CallerInfoAsyncQueryFactory callerInfoAsyncQueryFactory,
            PhoneNumberUtilsAdapter phoneNumberUtilsAdapter,
            Uri handle,
            GatewayInfo gatewayInfo,
@@ -609,8 +607,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            CallsManager callsManager,
            TelecomSystem.SyncRoot lock,
            ConnectionServiceRepository repository,
            ContactsAsyncHelper contactsAsyncHelper,
            CallerInfoAsyncQueryFactory callerInfoAsyncQueryFactory,
            PhoneNumberUtilsAdapter phoneNumberUtilsAdapter,
            Uri handle,
            GatewayInfo gatewayInfo,
@@ -622,8 +618,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            long connectTimeMillis,
            long connectElapsedTimeMillis,
            ClockProxy clockProxy) {
        this(callId, context, callsManager, lock, repository, contactsAsyncHelper,
                callerInfoAsyncQueryFactory, phoneNumberUtilsAdapter, handle, gatewayInfo,
        this(callId, context, callsManager, lock, repository,
                phoneNumberUtilsAdapter, handle, gatewayInfo,
                connectionManagerPhoneAccountHandle, targetPhoneAccountHandle, callDirection,
                shouldAttachToExistingConnection, isConference, clockProxy);

+15 −4
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.telecom.DefaultDialerManager;
import android.telecom.Log;
import android.telecom.Logging.Session;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
@@ -19,6 +20,8 @@ import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.widget.Toast;

import java.util.concurrent.CompletableFuture;

/**
 * Single point of entry for all outgoing and incoming calls.
 * {@link com.android.server.telecom.components.UserCallIntentProcessor} serves as a trampoline that
@@ -146,13 +149,21 @@ public class CallIntentProcessor {
        UserHandle initiatingUser = intent.getParcelableExtra(KEY_INITIATING_USER);

        // Send to CallsManager to ensure the InCallUI gets kicked off before the broadcast returns
        Call call = callsManager
        CompletableFuture<Call> callFuture = callsManager
                .startOutgoingCall(handle, phoneAccountHandle, clientExtras, initiatingUser,
                        intent, callingPackage);

        final Session logSubsession = Log.createSubsession();
        callFuture.thenAccept((call) -> {
            if (call != null) {
                Log.continueSession(logSubsession, "CIP.sNOCI");
                try {
                    sendNewOutgoingCallIntent(context, call, callsManager, intent);
                } finally {
                    Log.endSession();
                }
            }
        });
    }

    static void sendNewOutgoingCallIntent(Context context, Call call, CallsManager callsManager,
+449 −208

File changed.

Preview size limit exceeded, changes collapsed.

+5 −2
Original line number Diff line number Diff line
@@ -243,6 +243,10 @@ public class TelecomSystem {
        mMissedCallNotifier = missedCallNotifierImplFactory
                .makeMissedCallNotifierImpl(mContext, mPhoneAccountRegistrar, defaultDialerCache);

        CallerInfoLookupHelper callerInfoLookupHelper =
                new CallerInfoLookupHelper(context, callerInfoAsyncQueryFactory,
                        mContactsAsyncHelper, mLock);

        EmergencyCallHelper emergencyCallHelper = new EmergencyCallHelper(mContext,
                mContext.getResources().getString(R.string.ui_default_package), timeoutsAdapter);

@@ -262,8 +266,7 @@ public class TelecomSystem {
        mCallsManager = new CallsManager(
                mContext,
                mLock,
                mContactsAsyncHelper,
                callerInfoAsyncQueryFactory,
                callerInfoLookupHelper,
                mMissedCallNotifier,
                mPhoneAccountRegistrar,
                headsetMediaButtonFactory,
+3 −0
Original line number Diff line number Diff line
@@ -338,6 +338,9 @@ public class BasicCallTests extends TelecomSystemTest {
                mInCallServiceFixtureY.getCall(callId).getState());
        mInCallServiceFixtureX.mInCallAdapter.phoneAccountSelected(callId,
                mPhoneAccountA0.getAccountHandle(), false);
        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
        verifyAndProcessOutgoingCallBroadcast(mPhoneAccountA0.getAccountHandle());

        IdPair ids = outgoingCallPhoneAccountSelected(mPhoneAccountA0.getAccountHandle(),
                startingNumConnections, startingNumCalls, mConnectionServiceFixtureA);
Loading