Merge "Fix Telecom unit tests for incoming calls."
diff --git a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
index 8ea3fbe..17a4d90 100644
--- a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
+++ b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
@@ -27,6 +27,7 @@
import org.mockito.Mockito;
import android.content.ComponentName;
+import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IInterface;
@@ -41,6 +42,7 @@
import android.telecom.ParcelableConnection;
import android.telecom.PhoneAccountHandle;
import android.telecom.StatusHints;
+import android.telecom.TelecomManager;
import java.lang.Override;
import java.util.ArrayList;
@@ -55,28 +57,33 @@
* to the Telecom framework.
*/
public class ConnectionServiceFixture implements TestFixture<IConnectionService> {
+ static int INVALID_VIDEO_STATE = -1;
/**
* Implementation of ConnectionService that performs no-ops for tasks normally meant for
* Telephony and reports success back to Telecom
*/
public class FakeConnectionServiceDelegate extends ConnectionService {
+ int mVideoState = INVALID_VIDEO_STATE;
+
@Override
public Connection onCreateUnknownConnection(
PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
- return new FakeConnection(request.getVideoState());
+ return new FakeConnection(request.getVideoState(), request.getAddress());
}
@Override
public Connection onCreateIncomingConnection(
PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
- return new FakeConnection(request.getVideoState());
+ return new FakeConnection(
+ mVideoState == INVALID_VIDEO_STATE ? request.getVideoState() : mVideoState,
+ request.getAddress());
}
@Override
public Connection onCreateOutgoingConnection(
PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
- return new FakeConnection(request.getVideoState());
+ return new FakeConnection(request.getVideoState(), request.getAddress());
}
@Override
@@ -92,7 +99,7 @@
}
public class FakeConnection extends Connection {
- public FakeConnection(int videoState) {
+ public FakeConnection(int videoState, Uri address) {
super();
int capabilities = getConnectionCapabilities();
capabilities |= CAPABILITY_MUTE;
@@ -101,6 +108,7 @@
setVideoState(videoState);
setConnectionCapabilities(capabilities);
setActive();
+ setAddress(address, TelecomManager.PRESENTATION_ALLOWED);
}
}
@@ -232,7 +240,7 @@
}
}
- private FakeConnectionServiceDelegate mConnectionServiceDelegate =
+ FakeConnectionServiceDelegate mConnectionServiceDelegate =
new FakeConnectionServiceDelegate();
private IConnectionService mConnectionServiceDelegateAdapter =
IConnectionService.Stub.asInterface(mConnectionServiceDelegate.onBind(null));
diff --git a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
index d3c3ff4..20f62f2 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
@@ -52,6 +52,7 @@
import com.android.internal.telecom.IInCallAdapter;
import com.android.server.telecom.BluetoothPhoneServiceImpl;
+import com.android.server.telecom.CallAudioManager;
import com.android.server.telecom.CallerInfoAsyncQueryFactory;
import com.android.server.telecom.CallsManager;
import com.android.server.telecom.CallsManagerListenerBase;
@@ -61,13 +62,11 @@
import com.android.server.telecom.InCallWakeLockController;
import com.android.server.telecom.InCallWakeLockControllerFactory;
import com.android.server.telecom.MissedCallNotifier;
-import com.android.server.telecom.CallAudioManager;
import com.android.server.telecom.PhoneAccountRegistrar;
import com.android.server.telecom.ProximitySensorManager;
import com.android.server.telecom.ProximitySensorManagerFactory;
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.components.UserCallIntentProcessor;
-import com.android.server.telecom.ui.MissedCallNotifierImpl;
import com.android.server.telecom.ui.MissedCallNotifierImpl.MissedCallNotifierImplFactory;
import com.google.common.base.Predicate;
@@ -486,6 +485,7 @@
final int startingNumConnections = connectionServiceFixture.mConnectionById.size();
final int startingNumCalls = mInCallServiceFixtureX.mCallById.size();
boolean hasInCallAdapter = mInCallServiceFixtureX.mInCallAdapter != null;
+ connectionServiceFixture.mConnectionServiceDelegate.mVideoState = videoState;
Bundle extras = new Bundle();
extras.putParcelable(
@@ -498,13 +498,12 @@
.createConnection(any(PhoneAccountHandle.class), anyString(),
any(ConnectionRequest.class), eq(true), eq(false));
- mConnectionServiceFixtureA.mConnectionById.get(
- connectionServiceFixture.mLatestConnectionId).videoState = videoState;
-
- connectionServiceFixture.sendHandleCreateConnectionComplete(
- connectionServiceFixture.mLatestConnectionId);
connectionServiceFixture.sendSetRinging(connectionServiceFixture.mLatestConnectionId);
- connectionServiceFixture.sendSetVideoState(connectionServiceFixture.mLatestConnectionId);
+
+ for (CallerInfoAsyncQueryFactoryFixture.Request request :
+ mCallerInfoAsyncQueryFactoryFixture.mRequests) {
+ request.reply();
+ }
// For the case of incoming calls, Telecom connecting the InCall services and adding the
// Call is triggered by the async completion of the CallerInfoAsyncQuery. Once the Call