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