1 /* 2 * Copyright (C) 2021 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.car.testapi; 18 19 import static android.car.media.CarAudioManager.AUDIO_MIRROR_OUT_OF_OUTPUT_DEVICES; 20 import static android.service.autofill.FillRequest.INVALID_REQUEST_ID; 21 22 import android.car.CarOccupantZoneManager; 23 import android.car.media.AudioZonesMirrorStatusCallback; 24 import android.car.media.CarAudioManager; 25 import android.car.media.CarAudioPatchHandle; 26 import android.car.media.CarAudioZoneConfigInfo; 27 import android.car.media.CarVolumeGroupInfo; 28 import android.car.media.IAudioZoneConfigurationsChangeCallback; 29 import android.car.media.IAudioZonesMirrorStatusCallback; 30 import android.car.media.ICarAudio; 31 import android.car.media.ICarVolumeEventCallback; 32 import android.car.media.IMediaAudioRequestStatusCallback; 33 import android.car.media.IPrimaryZoneMediaAudioRequestCallback; 34 import android.car.media.ISwitchAudioZoneConfigCallback; 35 import android.media.AudioAttributes; 36 import android.media.AudioDeviceAttributes; 37 import android.os.IBinder; 38 39 import java.util.Collections; 40 import java.util.List; 41 import java.util.concurrent.Executor; 42 43 /** 44 * Fake service that is used by {@link FakeCar} to provide an implementation of {@link ICarAudio}. 45 * The reason we couldn't use a mock version of this service is that {@link AudioDeviceAttributes} 46 * is annotated with @hide, and Mockito fails to create a mock instance. 47 */ 48 final class FakeCarAudioService extends ICarAudio.Stub { 49 @Override isAudioFeatureEnabled(int feature)50 public boolean isAudioFeatureEnabled(int feature) { 51 return false; 52 } 53 54 @Override setGroupVolume(int zoneId, int groupId, int index, int flags)55 public void setGroupVolume(int zoneId, int groupId, int index, int flags) { 56 } 57 58 @Override getGroupMaxVolume(int zoneId, int groupId)59 public int getGroupMaxVolume(int zoneId, int groupId) { 60 return 0; 61 } 62 63 @Override getGroupMinVolume(int zoneId, int groupId)64 public int getGroupMinVolume(int zoneId, int groupId) { 65 return 0; 66 } 67 68 @Override getGroupVolume(int zoneId, int groupId)69 public int getGroupVolume(int zoneId, int groupId) { 70 return 0; 71 } 72 73 @Override setFadeTowardFront(float value)74 public void setFadeTowardFront(float value) { 75 } 76 77 @Override setBalanceTowardRight(float value)78 public void setBalanceTowardRight(float value) { 79 } 80 81 @Override getExternalSources()82 public String[] getExternalSources() { 83 return new String[] {}; 84 } 85 86 @Override createAudioPatch(String sourceAddress, int usage, int gainInMillibels)87 public CarAudioPatchHandle createAudioPatch(String sourceAddress, int usage, 88 int gainInMillibels) { 89 return null; 90 } 91 92 @Override releaseAudioPatch(CarAudioPatchHandle patch)93 public void releaseAudioPatch(CarAudioPatchHandle patch) { 94 } 95 96 @Override getVolumeGroupCount(int zoneId)97 public int getVolumeGroupCount(int zoneId) { 98 return 0; 99 } 100 101 @Override getVolumeGroupIdForUsage(int zoneId, int usage)102 public int getVolumeGroupIdForUsage(int zoneId, int usage) { 103 return 0; 104 } 105 106 @Override getUsagesForVolumeGroupId(int zoneId, int groupId)107 public int[] getUsagesForVolumeGroupId(int zoneId, int groupId) { 108 return new int[] {}; 109 } 110 111 @Override getVolumeGroupInfo(int zoneId, int groupId)112 public CarVolumeGroupInfo getVolumeGroupInfo(int zoneId, int groupId) { 113 return null; 114 } 115 116 @Override getVolumeGroupInfosForZone(int zoneId)117 public List<CarVolumeGroupInfo> getVolumeGroupInfosForZone(int zoneId) { 118 return Collections.EMPTY_LIST; 119 } 120 121 @Override getAudioAttributesForVolumeGroup(CarVolumeGroupInfo groupInfo)122 public List<AudioAttributes> getAudioAttributesForVolumeGroup(CarVolumeGroupInfo groupInfo) { 123 return Collections.EMPTY_LIST; 124 } 125 126 @Override getAudioZoneIds()127 public int[] getAudioZoneIds() { 128 return new int[] {}; 129 } 130 131 @Override getZoneIdForUid(int uid)132 public int getZoneIdForUid(int uid) { 133 return 0; 134 } 135 136 @Override setZoneIdForUid(int zoneId, int uid)137 public boolean setZoneIdForUid(int zoneId, int uid) { 138 return false; 139 } 140 141 @Override clearZoneIdForUid(int uid)142 public boolean clearZoneIdForUid(int uid) { 143 return false; 144 } 145 146 147 @Override cancelMediaAudioOnPrimaryZone(long requestId)148 public boolean cancelMediaAudioOnPrimaryZone(long requestId) { 149 return false; 150 } 151 152 @Override resetMediaAudioOnPrimaryZone(CarOccupantZoneManager.OccupantZoneInfo info)153 public boolean resetMediaAudioOnPrimaryZone(CarOccupantZoneManager.OccupantZoneInfo info) { 154 return false; 155 } 156 157 @Override isMediaAudioAllowedInPrimaryZone(CarOccupantZoneManager.OccupantZoneInfo info)158 public boolean isMediaAudioAllowedInPrimaryZone(CarOccupantZoneManager.OccupantZoneInfo info) { 159 return false; 160 } 161 162 @Override requestMediaAudioOnPrimaryZone(IMediaAudioRequestStatusCallback callback, CarOccupantZoneManager.OccupantZoneInfo info)163 public long requestMediaAudioOnPrimaryZone(IMediaAudioRequestStatusCallback callback, 164 CarOccupantZoneManager.OccupantZoneInfo info) { 165 return INVALID_REQUEST_ID; 166 } 167 168 @Override allowMediaAudioOnPrimaryZone(IBinder token, long requestId, boolean allow)169 public boolean allowMediaAudioOnPrimaryZone(IBinder token, long requestId, boolean allow) { 170 return false; 171 } 172 173 @Override registerPrimaryZoneMediaAudioRequestCallback( IPrimaryZoneMediaAudioRequestCallback backk)174 public boolean registerPrimaryZoneMediaAudioRequestCallback( 175 IPrimaryZoneMediaAudioRequestCallback backk) { 176 return false; 177 } 178 179 @Override unregisterPrimaryZoneMediaAudioRequestCallback( IPrimaryZoneMediaAudioRequestCallback callback)180 public void unregisterPrimaryZoneMediaAudioRequestCallback( 181 IPrimaryZoneMediaAudioRequestCallback callback) { 182 } 183 184 /** 185 * {@link CarAudioManager#setAudioZoneMirrorStatusCallback(Executor, 186 * AudioZonesMirrorStatusCallback)} 187 */ 188 @Override registerAudioZonesMirrorStatusCallback( IAudioZonesMirrorStatusCallback callback)189 public boolean registerAudioZonesMirrorStatusCallback( 190 IAudioZonesMirrorStatusCallback callback) { 191 return false; 192 } 193 194 /** 195 * {@link CarAudioManager#clearAudioZonesMirrorStatusCallback()} 196 */ 197 @Override unregisterAudioZonesMirrorStatusCallback(IAudioZonesMirrorStatusCallback callback)198 public void unregisterAudioZonesMirrorStatusCallback(IAudioZonesMirrorStatusCallback callback) { 199 } 200 201 /** 202 * {@link CarAudioManager#canEnableAudioMirror()} 203 */ 204 @Override canEnableAudioMirror()205 public int canEnableAudioMirror() { 206 return AUDIO_MIRROR_OUT_OF_OUTPUT_DEVICES; 207 } 208 209 /** 210 * {@link CarAudioManager#enableMirrorForAudioZones(List)} 211 */ 212 @Override enableMirrorForAudioZones(int[] audioZones)213 public long enableMirrorForAudioZones(int[] audioZones) { 214 return INVALID_REQUEST_ID; 215 } 216 217 /** 218 * {@link CarAudioManager#extendAudioMirrorRequest(long, List)} 219 */ 220 @Override extendAudioMirrorRequest(long mirrorId, int[] audioZones)221 public void extendAudioMirrorRequest(long mirrorId, int[] audioZones) { 222 } 223 224 /** 225 * {@link CarAudioManager#disableAudioMirrorForZone(int)} 226 */ 227 @Override disableAudioMirrorForZone(int zoneId)228 public void disableAudioMirrorForZone(int zoneId) { 229 } 230 231 /** 232 * {@link CarAudioManager#disableAudioMirrorRequest(int)} 233 */ 234 @Override disableAudioMirror(long requestId)235 public void disableAudioMirror(long requestId) { 236 } 237 238 /** 239 * {@link CarAudioManager#getMirrorAudioZonesForAudioZone(int)} 240 */ 241 @Override getMirrorAudioZonesForAudioZone(int zoneId)242 public int[] getMirrorAudioZonesForAudioZone(int zoneId) { 243 return new int[0]; 244 } 245 246 /** 247 * {@link CarAudioManager#getMirrorAudioZonesForMirrorRequest(long)} 248 */ 249 @Override getMirrorAudioZonesForMirrorRequest(long mirrorId )250 public int[] getMirrorAudioZonesForMirrorRequest(long mirrorId 251 ) { 252 return new int[0]; 253 } 254 255 @Override isVolumeGroupMuted(int zoneId, int groupId)256 public boolean isVolumeGroupMuted(int zoneId, int groupId) { 257 return false; 258 } 259 260 @Override setVolumeGroupMute(int zoneId, int groupId, boolean mute, int flags)261 public void setVolumeGroupMute(int zoneId, int groupId, boolean mute, int flags) { 262 } 263 264 @Override getOutputDeviceAddressForUsage(int zoneId, int usage)265 public String getOutputDeviceAddressForUsage(int zoneId, int usage) { 266 return ""; 267 } 268 269 @Override getInputDevicesForZoneId(int zoneId)270 public List<AudioDeviceAttributes> getInputDevicesForZoneId(int zoneId) { 271 return Collections.emptyList(); 272 } 273 274 @Override isPlaybackOnVolumeGroupActive(int volumeGroupId, int audioZoneId)275 public boolean isPlaybackOnVolumeGroupActive(int volumeGroupId, int audioZoneId) { 276 return false; 277 } 278 279 @Override getCurrentAudioZoneConfigInfo(int audioZoneId)280 public CarAudioZoneConfigInfo getCurrentAudioZoneConfigInfo(int audioZoneId) { 281 return null; 282 } 283 284 @Override getAudioZoneConfigInfos(int audioZoneId)285 public List<CarAudioZoneConfigInfo> getAudioZoneConfigInfos(int audioZoneId) { 286 return Collections.emptyList(); 287 } 288 289 @Override switchZoneToConfig(CarAudioZoneConfigInfo zoneConfig, ISwitchAudioZoneConfigCallback callback)290 public void switchZoneToConfig(CarAudioZoneConfigInfo zoneConfig, 291 ISwitchAudioZoneConfigCallback callback) { 292 } 293 294 @Override registerAudioZoneConfigsChangeCallback( IAudioZoneConfigurationsChangeCallback callback)295 public boolean registerAudioZoneConfigsChangeCallback( 296 IAudioZoneConfigurationsChangeCallback callback) { 297 return false; 298 } 299 300 @Override unregisterAudioZoneConfigsChangeCallback( IAudioZoneConfigurationsChangeCallback callback)301 public boolean unregisterAudioZoneConfigsChangeCallback( 302 IAudioZoneConfigurationsChangeCallback callback) { 303 return false; 304 } 305 306 @Override registerVolumeCallback(IBinder binder)307 public void registerVolumeCallback(IBinder binder) { 308 } 309 310 @Override unregisterVolumeCallback(IBinder binder)311 public void unregisterVolumeCallback(IBinder binder) { 312 } 313 314 @Override registerCarVolumeEventCallback(ICarVolumeEventCallback callback)315 public boolean registerCarVolumeEventCallback(ICarVolumeEventCallback callback) { 316 return false; 317 } 318 319 @Override unregisterCarVolumeEventCallback(ICarVolumeEventCallback callback)320 public boolean unregisterCarVolumeEventCallback(ICarVolumeEventCallback callback) { 321 return false; 322 } 323 } 324