1 /* 2 * Copyright (C) 2024 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 17 package com.android.server.telecom; 18 19 import android.telecom.CallEndpoint; 20 21 import java.util.Objects; 22 import java.util.Set; 23 24 public class CachedAvailableEndpointsChange implements CachedCallback { 25 public static final String ID = CachedAvailableEndpointsChange.class.getSimpleName(); 26 Set<CallEndpoint> mAvailableEndpoints; 27 getAvailableEndpoints()28 public Set<CallEndpoint> getAvailableEndpoints() { 29 return mAvailableEndpoints; 30 } 31 CachedAvailableEndpointsChange(Set<CallEndpoint> endpoints)32 public CachedAvailableEndpointsChange(Set<CallEndpoint> endpoints) { 33 mAvailableEndpoints = endpoints; 34 } 35 36 @Override getCacheType()37 public int getCacheType() { 38 return TYPE_STATE; 39 } 40 41 @Override executeCallback(CallSourceService service, Call call)42 public void executeCallback(CallSourceService service, Call call) { 43 service.onAvailableCallEndpointsChanged(call, mAvailableEndpoints); 44 } 45 46 @Override getCallbackId()47 public String getCallbackId() { 48 return ID; 49 } 50 51 @Override hashCode()52 public int hashCode() { 53 return Objects.hashCode(mAvailableEndpoints); 54 } 55 56 @Override equals(Object obj)57 public boolean equals(Object obj) { 58 if (obj == null) { 59 return false; 60 } 61 if (!(obj instanceof CachedAvailableEndpointsChange other)) { 62 return false; 63 } 64 if (mAvailableEndpoints.size() != other.mAvailableEndpoints.size()) { 65 return false; 66 } 67 for (CallEndpoint e : mAvailableEndpoints) { 68 if (!other.getAvailableEndpoints().contains(e)) { 69 return false; 70 } 71 } 72 return true; 73 } 74 } 75 76