Update test for Comms API change
Bug: 268779678
Test: atest android.car.cts.CarOccupantConnectionManagerTest
Change-Id: I357bef41b9337b3aae1f69aeadfde7e5f888584d
diff --git a/tests/tests/car/src/android/car/cts/CarOccupantConnectionManagerTest.java b/tests/tests/car/src/android/car/cts/CarOccupantConnectionManagerTest.java
index 6e176c34..429be37 100644
--- a/tests/tests/car/src/android/car/cts/CarOccupantConnectionManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarOccupantConnectionManagerTest.java
@@ -141,11 +141,6 @@
}
@Override
- public void onRejected(@NonNull OccupantZoneInfo receiverZone,
- int rejectionReason) {
- }
-
- @Override
public void onFailed(@NonNull OccupantZoneInfo receiverZone,
int connectionError) {
}
@@ -195,8 +190,8 @@
TestReceiverService receiverService = bindToLocalReceiverServiceAndWait();
boolean[] onConnectedInvoked = new boolean[1];
- boolean[] onRejectedInvoked = new boolean[1];
- int[] rejectionReasons = new int[1];
+ boolean[] onFailedInvoked = new boolean[1];
+ int[] connectionErrors = new int[1];
ConnectionRequestCallback connectionRequestCallback = new ConnectionRequestCallback() {
@Override
public void onConnected(@NonNull OccupantZoneInfo receiverZone) {
@@ -204,15 +199,10 @@
}
@Override
- public void onRejected(@NonNull OccupantZoneInfo receiverZone,
- int rejectionReason) {
- onRejectedInvoked[0] = true;
- rejectionReasons[0] = rejectionReason;
- }
-
- @Override
public void onFailed(@NonNull OccupantZoneInfo receiverZone,
int connectionError) {
+ onFailedInvoked[0] = true;
+ connectionErrors[0] = connectionError;
}
@Override
@@ -225,18 +215,18 @@
mOccupantConnectionManager.requestConnection(mActivePeerZone, mExecutor,
connectionRequestCallback);
PollingCheck.waitFor(CALLBACK_TIMEOUT_MS,
- () -> !onConnectedInvoked[0] && onRejectedInvoked[0]
- && rejectionReasons[0] == TestReceiverService.REJECTION_REASON);
+ () -> !onConnectedInvoked[0] && onFailedInvoked[0]
+ && connectionErrors[0] == TestReceiverService.REJECTION_REASON);
Log.v(TAG, "Sender's first request is rejected");
// The receiver service will accept the second request.
Log.v(TAG, "Sender requests another connection");
onConnectedInvoked[0] = false;
- onRejectedInvoked[0] = false;
+ onFailedInvoked[0] = false;
mOccupantConnectionManager.requestConnection(mActivePeerZone, mExecutor,
connectionRequestCallback);
PollingCheck.waitFor(CALLBACK_TIMEOUT_MS,
- () -> onConnectedInvoked[0] && !onRejectedInvoked[0]);
+ () -> onConnectedInvoked[0] && !onFailedInvoked[0]);
Log.v(TAG, "Sender's second request is accepted");
assertWithMessage("It should be connected to %s", mActivePeerZone)
@@ -352,8 +342,11 @@
}
@Override
- public void onRejected(@NonNull OccupantZoneInfo receiverZone,
- int rejectionReason) {
+ public void onFailed(@NonNull OccupantZoneInfo receiverZone,
+ int connectionError) {
+ if (connectionError != REJECTION_REASON) {
+ return;
+ }
// We foresee that the other receiver service would reject the first
// request. This is fine, because it will accept the second request.
Log.v(TAG, "Receiver service requests another connection to the"
@@ -364,11 +357,6 @@
}
@Override
- public void onFailed(@NonNull OccupantZoneInfo receiverZone,
- int connectionError) {
- }
-
- @Override
public void onDisconnected(@NonNull OccupantZoneInfo receiverZone) {
}
};
@@ -400,7 +388,7 @@
}
@Override
- public void onConnectionInitiated(OccupantZoneInfo senderZone, int senderAppState) {
+ public void onConnectionInitiated(OccupantZoneInfo senderZone) {
// Wait a while to allow some time for the sender to cancel the request.
try {
Thread.sleep(WAIT_BEFORE_RESPOND_TO_REQUEST_MS);