Revert "Unbind ConnectionService if connection creation timed out."
This reverts commit c6048375671e6ec5ead4d8bbae7afbe8678cd245.
Reason for revert: Security fix should not be guarded by a flag(b/293458004 comment#35)
Change-Id: Ib93a20f0a55bc4535d4775a324001bddbf310985
diff --git a/flags/telecom_api_flags.aconfig b/flags/telecom_api_flags.aconfig
index 36f20d8..21b83b2 100644
--- a/flags/telecom_api_flags.aconfig
+++ b/flags/telecom_api_flags.aconfig
@@ -14,13 +14,6 @@
bug: "301713560"
}
-flag {
- name: "unbind_timeout_connections"
- namespace: "telecom"
- description: "When set, Telecom will auto-unbind if a ConnectionService returns no connections after some time."
- bug: "293458004"
-}
-
flag{
name: "add_call_uri_for_missed_calls"
namespace: "telecom"
diff --git a/src/com/android/server/telecom/ConnectionServiceWrapper.java b/src/com/android/server/telecom/ConnectionServiceWrapper.java
index 5936730..43ceff3 100644
--- a/src/com/android/server/telecom/ConnectionServiceWrapper.java
+++ b/src/com/android/server/telecom/ConnectionServiceWrapper.java
@@ -33,6 +33,7 @@
import android.os.CancellationSignal;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
+import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.UserHandle;
@@ -73,14 +74,13 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.Set;
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.TimeUnit;
+import java.util.Objects;
/**
* Wrapper for {@link IConnectionService}s, handles binding to {@link IConnectionService} and keeps
@@ -93,12 +93,9 @@
ConnectionServiceFocusManager.ConnectionServiceFocus {
private static final String TELECOM_ABBREVIATION = "cast";
- private static final long SERVICE_BINDING_TIMEOUT = 15000L;
private CompletableFuture<Pair<Integer, Location>> mQueryLocationFuture = null;
private @Nullable CancellationSignal mOngoingQueryLocationRequest = null;
private final ExecutorService mQueryLocationExecutor = Executors.newSingleThreadExecutor();
- private ScheduledExecutorService mScheduledExecutor =
- Executors.newSingleThreadScheduledExecutor();
private final class Adapter extends IConnectionServiceAdapter.Stub {
@@ -1603,22 +1600,6 @@
.setParticipants(call.getParticipants())
.setIsAdhocConferenceCall(call.isAdhocConferenceCall())
.build();
- if (Flags.unbindTimeoutConnections()) {
- android.telecom.Logging.Runnable r =
- new android.telecom.Logging.Runnable("CSW.cC", mLock) {
- @Override
- public void loggedRun() {
- if (!call.isCreateConnectionComplete()) {
- Log.e(this, new Exception(), "Conference %s creation timeout",
- getComponentName());
- response.handleCreateConferenceFailure(
- new DisconnectCause(DisconnectCause.ERROR));
- }
- }
- };
- mScheduledExecutor.schedule(r.getRunnableToCancel(), SERVICE_BINDING_TIMEOUT,
- TimeUnit.MILLISECONDS);
- }
try {
mServiceInterface.createConference(
call.getConnectionManagerPhoneAccount(),
@@ -1659,7 +1640,6 @@
Log.i(ConnectionServiceWrapper.this, "Call not present"
+ " in call id mapper, maybe it was aborted before the bind"
+ " completed successfully?");
-
response.handleCreateConnectionFailure(
new DisconnectCause(DisconnectCause.CANCELED));
return;
@@ -1720,24 +1700,6 @@
.setRttPipeFromInCall(call.getInCallToCsRttPipeForCs())
.setRttPipeToInCall(call.getCsToInCallRttPipeForCs())
.build();
-
- if (Flags.unbindTimeoutConnections()) {
- android.telecom.Logging.Runnable r =
- new android.telecom.Logging.Runnable("CSW.cC", mLock) {
- @Override
- public void loggedRun() {
- if (!call.isCreateConnectionComplete()) {
- Log.e(this, new Exception(),
- "Connection %s creation timeout",
- getComponentName());
- response.handleCreateConnectionFailure(
- new DisconnectCause(DisconnectCause.ERROR));
- }
- }
- };
- mScheduledExecutor.schedule(r.getRunnableToCancel(), SERVICE_BINDING_TIMEOUT,
- TimeUnit.MILLISECONDS);
- }
try {
mServiceInterface.createConnection(
call.getConnectionManagerPhoneAccount(),
@@ -1746,6 +1708,7 @@
call.shouldAttachToExistingConnection(),
call.isUnknown(),
Log.getExternalSession(TELECOM_ABBREVIATION));
+
} catch (RemoteException e) {
Log.e(this, e, "Failure to createConnection -- %s", getComponentName());
mPendingResponses.remove(callId).handleCreateConnectionFailure(
@@ -2194,8 +2157,7 @@
}
}
- @VisibleForTesting
- public void addCall(Call call) {
+ void addCall(Call call) {
if (mCallIdMapper.getCallId(call) == null) {
mCallIdMapper.addCall(call);
}
@@ -2663,9 +2625,4 @@
sb.append("]");
return sb.toString();
}
-
- @VisibleForTesting
- public void setScheduledExecutorService(ScheduledExecutorService service) {
- mScheduledExecutor = service;
- }
}
diff --git a/tests/src/com/android/server/telecom/tests/BasicCallTests.java b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
index 1e655e4..9ca3de1 100644
--- a/tests/src/com/android/server/telecom/tests/BasicCallTests.java
+++ b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
@@ -1035,7 +1035,6 @@
call.setTargetPhoneAccount(mPhoneAccountA1.getAccountHandle());
assert(call.isVideoCallingSupportedByPhoneAccount());
assertEquals(VideoProfile.STATE_BIDIRECTIONAL, call.getVideoState());
- call.setIsCreateConnectionComplete(true);
}
/**
@@ -1059,7 +1058,6 @@
call.setTargetPhoneAccount(mPhoneAccountA2.getAccountHandle());
assert(!call.isVideoCallingSupportedByPhoneAccount());
assertEquals(VideoProfile.STATE_AUDIO_ONLY, call.getVideoState());
- call.setIsCreateConnectionComplete(true);
}
/**
diff --git a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
index 70f1708..be00125 100644
--- a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
@@ -56,7 +56,6 @@
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;
@@ -64,7 +63,6 @@
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
-import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.BlockedNumberContract;
import android.telecom.CallException;
import android.telecom.CallScreeningService;
@@ -104,7 +102,6 @@
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;
@@ -131,9 +128,8 @@
import com.android.server.telecom.bluetooth.BluetoothStateReceiver;
import com.android.server.telecom.callfiltering.BlockedNumbersAdapter;
import com.android.server.telecom.callfiltering.CallFilteringResult;
-import com.android.server.telecom.callfiltering.IncomingCallFilterGraph;
import com.android.server.telecom.flags.FeatureFlags;
-import com.android.server.telecom.flags.Flags;
+import com.android.server.telecom.callfiltering.IncomingCallFilterGraph;
import com.android.server.telecom.ui.AudioProcessingNotification;
import com.android.server.telecom.ui.CallStreamingNotification;
import com.android.server.telecom.ui.DisconnectedCallNotifier;
@@ -142,7 +138,6 @@
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -291,10 +286,7 @@
@Mock private CallAudioCommunicationDeviceTracker mCommunicationDeviceTracker;
@Mock private CallStreamingNotification mCallStreamingNotification;
@Mock private FeatureFlags mFeatureFlags;
-
@Mock private IncomingCallFilterGraph mIncomingCallFilterGraph;
- @Mock private IConnectionService mIConnectionService;
- @Rule public SetFlagsRule mSetRlagsRule = new SetFlagsRule();
private CallsManager mCallsManager;
@Override
@@ -382,17 +374,11 @@
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(
- SIM_1_ACCOUNT.getAccountHandle().getComponentName(), mIConnectionService);
}
@Override
@After
public void tearDown() throws Exception {
- mComponentContextFixture.removeConnectionService(
- SIM_1_ACCOUNT.getAccountHandle().getComponentName(), mIConnectionService);
super.tearDown();
}
@@ -2841,37 +2827,6 @@
assertTrue(result.contains("onReceiveResult"));
}
- @Test
- public void testConnectionServiceCreateConnectionTimeout() throws Exception {
- mSetRlagsRule.enableFlags(Flags.FLAG_UNBIND_TIMEOUT_CONNECTIONS);
- ConnectionServiceWrapper service = new ConnectionServiceWrapper(
- SIM_1_ACCOUNT.getAccountHandle().getComponentName(), null,
- mPhoneAccountRegistrar, mCallsManager, mContext, mLock, null,
- mFeatureFlags);
- 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");
- scheduledExecutorService.advanceTime(15000L);
- verify(response).handleCreateConnectionFailure(
- eq(new DisconnectCause(DisconnectCause.ERROR)));
- }
-
@SmallTest
@Test
public void testOnFailedOutgoingCallUnholdsCallAfterLocallyDisconnect() {
@@ -3457,19 +3412,4 @@
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();
- }
}