1 /* 2 * Copyright (C) 2023 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.hdmi; 18 19 import android.annotation.NonNull; 20 import android.media.AudioAttributes; 21 import android.media.AudioDeviceAttributes; 22 import android.media.AudioDeviceVolumeManager; 23 import android.media.AudioManager; 24 25 import java.util.List; 26 27 /** 28 * Interface with the methods from {@link AudioDeviceVolumeManager} used by the HDMI control 29 * framework. Allows the class to be faked for tests. 30 * 31 * See implementations {@link DefaultAudioManagerWrapper} and 32 * {@link FakeAudioFramework.FakeAudioManagerWrapper}. 33 */ 34 public interface AudioManagerWrapper { 35 36 /** 37 * Wraps {@link AudioManager#adjustStreamVolume(int, int, int)} 38 */ adjustStreamVolume(int streamType, int direction, @AudioManager.PublicVolumeFlags int flags)39 void adjustStreamVolume(int streamType, int direction, 40 @AudioManager.PublicVolumeFlags int flags); 41 42 /** 43 * Wraps {@link AudioManager#setStreamVolume(int, int, int)} 44 */ setStreamVolume(int streamType, int index, @AudioManager.PublicVolumeFlags int flags)45 void setStreamVolume(int streamType, int index, @AudioManager.PublicVolumeFlags int flags); 46 47 /** 48 * Wraps {@link AudioManager#getStreamVolume(int)} 49 */ getStreamVolume(int streamType)50 int getStreamVolume(int streamType); 51 52 /** 53 * Wraps {@link AudioManager#getStreamMinVolume(int)} 54 */ getStreamMinVolume(int streamType)55 int getStreamMinVolume(int streamType); 56 57 /** 58 * Wraps {@link AudioManager#getStreamMaxVolume(int)} 59 */ getStreamMaxVolume(int streamType)60 int getStreamMaxVolume(int streamType); 61 62 /** 63 * Wraps {@link AudioManager#isStreamMute(int)} 64 */ isStreamMute(int streamType)65 boolean isStreamMute(int streamType); 66 67 /** 68 * Wraps {@link AudioManager#setStreamMute(int, boolean)} 69 */ setStreamMute(int streamType, boolean state)70 void setStreamMute(int streamType, boolean state); 71 72 /** 73 * Wraps {@link AudioManager#setHdmiSystemAudioSupported(boolean)} 74 */ setHdmiSystemAudioSupported(boolean on)75 int setHdmiSystemAudioSupported(boolean on); 76 77 /** 78 * Wraps {@link AudioManager#setWiredDeviceConnectionState(AudioDeviceAttributes, int)} 79 */ setWiredDeviceConnectionState(AudioDeviceAttributes attributes, int state)80 void setWiredDeviceConnectionState(AudioDeviceAttributes attributes, int state); 81 82 /** 83 * Wraps {@link AudioManager#setWiredDeviceConnectionState(int, int, String, String)} 84 */ setWiredDeviceConnectionState(int device, int state, String address, String name)85 void setWiredDeviceConnectionState(int device, int state, String address, String name); 86 87 /** 88 * Wraps {@link AudioManager#getDeviceVolumeBehavior(AudioDeviceAttributes)} 89 */ 90 @AudioManager.DeviceVolumeBehavior getDeviceVolumeBehavior(@onNull AudioDeviceAttributes device)91 int getDeviceVolumeBehavior(@NonNull AudioDeviceAttributes device); 92 93 /** 94 * Wraps {@link AudioManager#setDeviceVolumeBehavior(AudioDeviceAttributes, int)} 95 */ setDeviceVolumeBehavior(@onNull AudioDeviceAttributes device, @AudioManager.DeviceVolumeBehavior int deviceVolumeBehavior)96 void setDeviceVolumeBehavior(@NonNull AudioDeviceAttributes device, 97 @AudioManager.DeviceVolumeBehavior int deviceVolumeBehavior); 98 99 /** 100 * Wraps {@link AudioManager#getDevicesForAttributes(AudioAttributes)} 101 */ 102 @NonNull getDevicesForAttributes( @onNull AudioAttributes attributes)103 List<AudioDeviceAttributes> getDevicesForAttributes( 104 @NonNull AudioAttributes attributes); 105 } 106