1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package android.car.occupantconnection; 17 18 import android.car.CarOccupantZoneManager.OccupantZoneInfo; 19 import android.content.Intent; 20 import android.os.Binder; 21 import android.os.IBinder; 22 import android.util.Pair; 23 24 import androidx.annotation.Nullable; 25 26 import java.util.ArrayList; 27 import java.util.List; 28 29 final class TestReceiverService extends AbstractReceiverService { 30 31 // The following lists are used to verify an onFoo() method was invoked with certain parameters. 32 public final List<Pair<OccupantZoneInfo, Payload>> onPayloadReceivedInvokedRecords = 33 new ArrayList<>(); 34 public final List<String> onReceiverRegisteredInvokedRecords = new ArrayList<>(); 35 public final List<OccupantZoneInfo> onConnectionInitiatedInvokedRecords = new ArrayList<>(); 36 public final List<OccupantZoneInfo> onConnectedInvokedRecords = new ArrayList<>(); 37 public final List<OccupantZoneInfo> onConnectionCanceledInvokedRecords = new ArrayList<>(); 38 public final List<OccupantZoneInfo> onDisconnectedInvokedRecords = new ArrayList<>(); 39 40 public final Binder localBinder = new Binder(); 41 42 @Override onPayloadReceived(OccupantZoneInfo senderZone, Payload payload)43 public void onPayloadReceived(OccupantZoneInfo senderZone, Payload payload) { 44 onPayloadReceivedInvokedRecords.add(new Pair(senderZone, payload)); 45 } 46 47 @Override onReceiverRegistered(String receiverEndpointId)48 public void onReceiverRegistered(String receiverEndpointId) { 49 onReceiverRegisteredInvokedRecords.add(receiverEndpointId); 50 } 51 52 @Override onConnectionInitiated(OccupantZoneInfo senderZone)53 public void onConnectionInitiated(OccupantZoneInfo senderZone) { 54 onConnectionInitiatedInvokedRecords.add(senderZone); 55 } 56 57 @Override onConnected(OccupantZoneInfo senderZone)58 public void onConnected(OccupantZoneInfo senderZone) { 59 onConnectedInvokedRecords.add(senderZone); 60 } 61 62 @Override onConnectionCanceled(OccupantZoneInfo senderZone)63 public void onConnectionCanceled(OccupantZoneInfo senderZone) { 64 onConnectionCanceledInvokedRecords.add(senderZone); 65 } 66 67 @Override onDisconnected(OccupantZoneInfo senderZone)68 public void onDisconnected(OccupantZoneInfo senderZone) { 69 onDisconnectedInvokedRecords.add(senderZone); 70 } 71 72 @Nullable 73 @Override onLocalServiceBind(Intent intent)74 public IBinder onLocalServiceBind(Intent intent) { 75 return localBinder; 76 } 77 } 78