1 /* 2 * Copyright (C) 2015 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 android.telecom.cts; 18 19 import android.telecom.Call; 20 import android.telecom.InCallService; 21 import android.telecom.VideoProfile; 22 import android.telecom.VideoProfile.CameraCapabilities; 23 24 /** 25 * Mock video call Callback class. 26 */ 27 public class MockVideoCallCallback extends InCallService.VideoCall.Callback { 28 private Call mCall; 29 private CameraCapabilities mCameraCapabilities; 30 private long mDataUsage = MockVideoProvider.DATA_USAGE_UNDEFINED; 31 private int mVideoQuality = MockVideoProvider.VIDEO_QUALITY_UNDEFINED; 32 private int mCallSessionEvent = MockVideoProvider.SESSION_EVENT_UNDEFINED; 33 private int mPeerWidth = MockVideoProvider.PEER_WIDTH_UNDEFINED; 34 private int mResponseStatus; 35 private VideoProfile mRequestedProfile = null; 36 private VideoProfile mResponseProfile = null; 37 private VideoProfile mRequestProfile = null; 38 39 public MockVideoCallCallback(Call call) { 40 mCall = call; 41 } 42 43 /** 44 * Store incoming session modify request so tests can inspect it. 45 * 46 * @param videoProfile The requested video profile. 47 */ 48 @Override 49 public void onSessionModifyRequestReceived(VideoProfile videoProfile) { 50 mRequestProfile = videoProfile; 51 } 52 53 /** 54 * Store incoming session modify response so tests can inspect it. 55 * 56 * @param status Status of the session modify request. 57 * @param requestedProfile The original request which was sent to the peer device. 58 * @param responseProfile The actual profile changes made by the peer device. 59 */ 60 @Override 61 public void onSessionModifyResponseReceived(int status, VideoProfile requestedProfile, 62 VideoProfile responseProfile) { 63 mResponseStatus = status; 64 mRequestedProfile = requestedProfile; 65 mResponseProfile = responseProfile; 66 } 67 68 /** 69 * Store incoming session event so tests can inspect it. 70 * 71 * @param event The event. 72 */ 73 @Override 74 public void onCallSessionEvent(int event) { 75 mCallSessionEvent = event; 76 } 77 78 /** 79 * Store incoming peer dimensions so tests can inspect them. 80 * 81 * @param width The updated peer video width. 82 * @param height The updated peer video height. 83 */ 84 @Override 85 public void onPeerDimensionsChanged(int width, int height) { 86 mPeerWidth = width; 87 } 88 89 /** 90 * Store incoming video quality so tests can inspect them. 91 * 92 * @param videoQuality The updated peer video quality. Valid values: 93 * {@link VideoProfile#QUALITY_HIGH}, 94 * {@link VideoProfile#QUALITY_MEDIUM}, 95 * {@link VideoProfile#QUALITY_LOW}, 96 */ 97 @Override 98 public void onVideoQualityChanged(int videoQuality) { 99 mVideoQuality = videoQuality; 100 } 101 102 /** 103 * Store incoming call data usage so tests can inspect it. 104 * 105 * @param dataUsage The updated data usage (in bytes). 106 */ 107 @Override 108 public void onCallDataUsageChanged(long dataUsage) { 109 mDataUsage = dataUsage; 110 } 111 112 /** 113 * Store incoming camera capabilities so tests can inspect them. 114 * 115 * @param cameraCapabilities The changed camera capabilities. 116 */ 117 @Override 118 public void onCameraCapabilitiesChanged(CameraCapabilities cameraCapabilities) { 119 mCameraCapabilities = cameraCapabilities; 120 } 121 122 /** 123 * Returns the last received {@link CameraCapabilities}. 124 * 125 * @return The {@link CameraCapabilities}. 126 */ 127 public CameraCapabilities getCameraCapabilities() { 128 return mCameraCapabilities; 129 } 130 131 /** 132 * Returns the last received data usage. 133 * 134 * @return The data usage. 135 */ 136 public long getDataUsage() { 137 return mDataUsage; 138 } 139 140 /** 141 * Returns the last received video quality. 142 * 143 * @return The video quality. 144 */ 145 public int getVideoQuality() 146 { 147 return mVideoQuality; 148 } 149 150 /** 151 * Returns the last received call session event. 152 * 153 * @return The call session event. 154 */ 155 public int getCallSessionEvent() 156 { 157 return mCallSessionEvent; 158 } 159 160 /** 161 * Returns the last received peer width. 162 * 163 * @return The call session event. 164 */ 165 public int getPeerWidth() 166 { 167 return mPeerWidth; 168 } 169 170 /** 171 * Returns the last {@code requestedProfile} received via onSessionModifyResponseReceived. 172 * 173 * @return The video profile. 174 */ 175 public VideoProfile getRequestedProfile() { 176 return mRequestedProfile; 177 } 178 179 /** 180 * Returns the last {@code responseProfile} received via onSessionModifyResponseReceived. 181 * 182 * @return The video profile. 183 */ 184 public VideoProfile getResponseProfile() { 185 return mResponseProfile; 186 } 187 188 /** 189 * Returns the last {@code status} received via onSessionModifyResponseReceived.. 190 * 191 * @return The response status. 192 */ 193 public int getResponseStatus() { 194 return mResponseStatus; 195 } 196 197 /** 198 * Returns the last requested video profile. 199 * 200 * @return The video profile. 201 */ 202 public VideoProfile getRequestProfile() { 203 return mRequestProfile; 204 } 205 } 206