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

Commit 386e16ae authored by Stacie Mashnitskaya (xWF)'s avatar Stacie Mashnitskaya (xWF) Committed by Android Build Coastguard Worker
Browse files

Revert "DO NOT MERGE"

This reverts commit 917ee8d5749e47403cbb091bb5fe47b7d1ed659b.

Reason for revert:Causes NPE (b/293458004); will submit a clean fix after revert
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:728a93ed4e27259d0ca52c2bac77e00bbd07126f)
Merged-In: I610d6062d5b68708e94e71811e2f81de87df101e
Change-Id: I610d6062d5b68708e94e71811e2f81de87df101e
parent d5e47c12
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -1121,7 +1121,6 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        return (!mIsTransactionalCall ? mConnectionService : mTransactionalService);
    }

    @VisibleForTesting
    public int getState() {
        return mState;
    }
+2 −68
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import android.telecom.ConnectionService;
import android.telecom.DisconnectCause;
import android.telecom.GatewayInfo;
import android.telecom.Log;
import android.telecom.Logging.Runnable;
import android.telecom.Logging.Session;
import android.telecom.ParcelableConference;
import android.telecom.ParcelableConnection;
@@ -73,14 +72,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.Objects;

/**
 * Wrapper for {@link IConnectionService}s, handles binding to {@link IConnectionService} and keeps
@@ -97,11 +94,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
    private @Nullable CancellationSignal mOngoingQueryLocationRequest = null;
    private final ExecutorService mQueryLocationExecutor = Executors.newSingleThreadExecutor();

    private static final long SERVICE_BINDING_TIMEOUT = 15000L;
    private ScheduledExecutorService mScheduledExecutor =
            Executors.newSingleThreadScheduledExecutor();
    // Pre-allocate space for 2 calls; realistically thats all we should ever need (tm)
    private final Map<Call, ScheduledFuture<?>> mScheduledFutureMap = new ConcurrentHashMap<>(2);
    private final class Adapter extends IConnectionServiceAdapter.Stub {

        @Override
@@ -114,12 +106,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            try {
                synchronized (mLock) {
                    logIncoming("handleCreateConnectionComplete %s", callId);
                    Call call = mCallIdMapper.getCall(callId);
                    if (mScheduledFutureMap.containsKey(call)) {
                        ScheduledFuture<?> existingTimeout = mScheduledFutureMap.get(call);
                        existingTimeout.cancel(false /* cancelIfRunning */);
                        mScheduledFutureMap.remove(call);
                    }
                    // Check status hints image for cross user access
                    if (connection.getStatusHints() != null) {
                        Icon icon = connection.getStatusHints().getIcon();
@@ -164,12 +150,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                        conference.getStatusHints().setIcon(StatusHints.
                                validateAccountIconUserBoundary(icon, callingUserHandle));
                    }
                    Call call = mCallIdMapper.getCall(callId);
                    if (mScheduledFutureMap.containsKey(call)) {
                        ScheduledFuture<?> existingTimeout = mScheduledFutureMap.get(call);
                        existingTimeout.cancel(false /* cancelIfRunning */);
                        mScheduledFutureMap.remove(call);
                    }
                    ConnectionServiceWrapper.this
                            .handleCreateConferenceComplete(callId, request, conference);

@@ -1623,26 +1603,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                        .setIsAdhocConferenceCall(call.isAdhocConferenceCall())
                        .build();

                Runnable r = new Runnable("CSW.cC", mLock) {
                            @Override
                            public void loggedRun() {
                                if (!call.isCreateConnectionComplete()) {
                                    Log.e(this, new Exception(),
                                            "Conference %s creation timeout",
                                            getComponentName());
                                    Log.addEvent(call, LogUtils.Events.CREATE_CONFERENCE_TIMEOUT,
                                            Log.piiHandle(call.getHandle()) + " via:" +
                                                    getComponentName().getPackageName());
                                    response.handleCreateConferenceFailure(
                                            new DisconnectCause(DisconnectCause.ERROR));
                                }
                            }
                        };
                // Post cleanup to the executor service and cache the future, so we can cancel it if
                // needed.
                ScheduledFuture<?> future = mScheduledExecutor.schedule(r.getRunnableToCancel(),
                        SERVICE_BINDING_TIMEOUT, TimeUnit.MILLISECONDS);
                mScheduledFutureMap.put(call, future);
                try {
                    mServiceInterface.createConference(
                            call.getConnectionManagerPhoneAccount(),
@@ -1745,26 +1705,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                        .setRttPipeToInCall(call.getCsToInCallRttPipeForCs())
                        .build();

                Runnable r = new Runnable("CSW.cC", mLock) {
                            @Override
                            public void loggedRun() {
                                if (!call.isCreateConnectionComplete()) {
                                    Log.e(this, new Exception(),
                                            "Connection %s creation timeout",
                                            getComponentName());
                                    Log.addEvent(call, LogUtils.Events.CREATE_CONNECTION_TIMEOUT,
                                            Log.piiHandle(call.getHandle()) + " via:" +
                                                    getComponentName().getPackageName());
                                    response.handleCreateConnectionFailure(
                                            new DisconnectCause(DisconnectCause.ERROR));
                                }
                            }
                        };
                // Post cleanup to the executor service and cache the future, so we can cancel it if
                // needed.
                ScheduledFuture<?> future = mScheduledExecutor.schedule(r.getRunnableToCancel(),
                        SERVICE_BINDING_TIMEOUT, TimeUnit.MILLISECONDS);
                mScheduledFutureMap.put(call, future);
                try {
                    mServiceInterface.createConnection(
                            call.getConnectionManagerPhoneAccount(),
@@ -2222,8 +2162,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        }
    }

    @VisibleForTesting
    public void addCall(Call call) {
    void addCall(Call call) {
        if (mCallIdMapper.getCallId(call) == null) {
            mCallIdMapper.addCall(call);
        }
@@ -2690,9 +2629,4 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        sb.append("]");
        return sb.toString();
    }

    @VisibleForTesting
    public void setScheduledExecutorService(ScheduledExecutorService service) {
        mScheduledExecutor = service;
    }
}
+0 −2
Original line number Diff line number Diff line
@@ -139,10 +139,8 @@ public class LogUtils {
        public static final String STOP_CALL_WAITING_TONE = "STOP_CALL_WAITING_TONE";
        public static final String START_CONNECTION = "START_CONNECTION";
        public static final String CREATE_CONNECTION_FAILED = "CREATE_CONNECTION_FAILED";
        public static final String CREATE_CONNECTION_TIMEOUT = "CREATE_CONNECTION_TIMEOUT";
        public static final String START_CONFERENCE = "START_CONFERENCE";
        public static final String CREATE_CONFERENCE_FAILED = "CREATE_CONFERENCE_FAILED";
        public static final String CREATE_CONFERENCE_TIMEOUT = "CREATE_CONFERENCE_TIMEOUT";
        public static final String BIND_CS = "BIND_CS";
        public static final String CS_BOUND = "CS_BOUND";
        public static final String CONFERENCE_WITH = "CONF_WITH";
+0 −2
Original line number Diff line number Diff line
@@ -995,7 +995,6 @@ public class BasicCallTests extends TelecomSystemTest {
        call.setTargetPhoneAccount(mPhoneAccountA1.getAccountHandle());
        assert(call.isVideoCallingSupportedByPhoneAccount());
        assertEquals(VideoProfile.STATE_BIDIRECTIONAL, call.getVideoState());
        call.setIsCreateConnectionComplete(true);
    }

    /**
@@ -1019,7 +1018,6 @@ public class BasicCallTests extends TelecomSystemTest {
        call.setTargetPhoneAccount(mPhoneAccountA2.getAccountHandle());
        assert(!call.isVideoCallingSupportedByPhoneAccount());
        assertEquals(VideoProfile.STATE_AUDIO_ONLY, call.getVideoState());
        call.setIsCreateConnectionComplete(true);
    }

    /**
+0 −53
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static java.lang.Thread.sleep;

import android.Manifest;
import android.content.ComponentName;
@@ -55,7 +54,6 @@ import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.OutcomeReceiver;
import android.os.Process;
@@ -82,7 +80,6 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.util.Pair;
import android.widget.Toast;

import com.android.internal.telecom.IConnectionService;
import com.android.server.telecom.AnomalyReporterAdapter;
import com.android.server.telecom.AsyncRingtonePlayer;
import com.android.server.telecom.Call;
@@ -100,7 +97,6 @@ import com.android.server.telecom.ClockProxy;
import com.android.server.telecom.ConnectionServiceFocusManager;
import com.android.server.telecom.ConnectionServiceFocusManager.ConnectionServiceFocusManagerFactory;
import com.android.server.telecom.ConnectionServiceWrapper;
import com.android.server.telecom.CreateConnectionResponse;
import com.android.server.telecom.DefaultDialerCache;
import com.android.server.telecom.EmergencyCallDiagnosticLogger;
import com.android.server.telecom.EmergencyCallHelper;
@@ -281,7 +277,6 @@ public class CallsManagerTest extends TelecomTestCase {
    @Mock private BlockedNumbersAdapter mBlockedNumbersAdapter;
    @Mock private PhoneCapability mPhoneCapability;
    @Mock private CallStreamingNotification mCallStreamingNotification;
    @Mock private IConnectionService mIConnectionService;

    private CallsManager mCallsManager;

@@ -365,19 +360,11 @@ public class CallsManagerTest extends TelecomTestCase {
                eq(WORK_HANDLE), any())).thenReturn(WORK_ACCOUNT);
        when(mToastFactory.makeText(any(), anyInt(), anyInt())).thenReturn(mToast);
        when(mToastFactory.makeText(any(), any(), anyInt())).thenReturn(mToast);
        when(mIConnectionService.asBinder()).thenReturn(mock(IBinder.class));

        mComponentContextFixture.addConnectionService(new ComponentName(mContext.getPackageName(),
                mContext.getPackageName().getClass().getName()), mIConnectionService);
    }

    @Override
    @After
    public void tearDown() throws Exception {
        mComponentContextFixture.removeConnectionService(
                new ComponentName(mContext.getPackageName(),
                        mContext.getPackageName().getClass().getName()),
                mock(IConnectionService.class));
        super.tearDown();
    }

@@ -3263,31 +3250,6 @@ public class CallsManagerTest extends TelecomTestCase {
        assertTrue(mCallsManager.isInSelfManagedCall(TEST_PACKAGE_NAME, TEST_USER_HANDLE));
    }

    @Test
    public void testConnectionServiceCreateConnectionTimeout() throws Exception {
        ConnectionServiceWrapper service = new ConnectionServiceWrapper(new ComponentName(
                mContext.getPackageName(), mContext.getPackageName().getClass().getName()), null,
                mPhoneAccountRegistrar, mCallsManager, mContext, mLock, null);
        TestScheduledExecutorService scheduledExecutorService = new TestScheduledExecutorService();
        service.setScheduledExecutorService(scheduledExecutorService);
        Call call = addSpyCall();
        service.addCall(call);
        when(call.isCreateConnectionComplete()).thenReturn(false);
        CreateConnectionResponse response = mock(CreateConnectionResponse.class);

        service.createConnection(call, response);
        waitUntilConditionIsTrueOrTimeout(new Condition() {
            @Override
            public Object expected() {
                return true;
            }

            @Override
            public Object actual() {
                return scheduledExecutorService.isRunnableScheduledAtTime(15000L);
            }
        }, 5000L, "Expected job failed to schedule");
    }

    private Call addSpyCall() {
        return addSpyCall(SIM_2_HANDLE, CallState.ACTIVE);
@@ -3391,19 +3353,4 @@ public class CallsManagerTest extends TelecomTestCase {
        when(mockTelephonyManager.getPhoneCapability()).thenReturn(mPhoneCapability);
        when(mPhoneCapability.getMaxActiveVoiceSubscriptions()).thenReturn(num);
    }

    private void waitUntilConditionIsTrueOrTimeout(Condition condition, long timeout,
            String description) throws InterruptedException {
        final long start = System.currentTimeMillis();
        while (!condition.expected().equals(condition.actual())
                && System.currentTimeMillis() - start < timeout) {
            sleep(50);
        }
        assertEquals(description, condition.expected(), condition.actual());
    }

    protected interface Condition {
        Object expected();
        Object actual();
    }
}
Loading