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 static com.android.server.telecom.callsequencing.voip.VideoStateTranslation 20 .TransactionalVideoStateToString; 21 22 import android.telecom.Log; 23 24 public class CachedVideoStateChange implements CachedCallback { 25 public static final String ID = CachedVideoStateChange.class.getSimpleName(); 26 int mCurrentVideoState; 27 getCurrentCallEndpoint()28 public int getCurrentCallEndpoint() { 29 return mCurrentVideoState; 30 } 31 CachedVideoStateChange(int videoState)32 public CachedVideoStateChange(int videoState) { 33 mCurrentVideoState = videoState; 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.onVideoStateChanged(call, mCurrentVideoState); 44 Log.addEvent(call, LogUtils.Events.VIDEO_STATE_CHANGED, 45 TransactionalVideoStateToString(mCurrentVideoState)); 46 } 47 48 @Override getCallbackId()49 public String getCallbackId() { 50 return ID; 51 } 52 53 @Override hashCode()54 public int hashCode() { 55 return mCurrentVideoState; 56 } 57 58 @Override equals(Object obj)59 public boolean equals(Object obj){ 60 if (obj == null) { 61 return false; 62 } 63 if (!(obj instanceof CachedVideoStateChange other)) { 64 return false; 65 } 66 return mCurrentVideoState == other.mCurrentVideoState; 67 } 68 } 69 70