Loading services/core/java/com/android/server/audio/AudioDeviceBroker.java +2 −1 Original line number Diff line number Diff line Loading @@ -1323,7 +1323,8 @@ import java.util.concurrent.atomic.AtomicBoolean; break; case MSG_II_SET_HEARING_AID_VOLUME: synchronized (mDeviceStateLock) { mBtHelper.setHearingAidVolume(msg.arg1, msg.arg2); mBtHelper.setHearingAidVolume(msg.arg1, msg.arg2, mDeviceInventory.isHearingAidConnected()); } break; case MSG_II_SET_LE_AUDIO_OUT_VOLUME: { Loading services/core/java/com/android/server/audio/AudioDeviceInventory.java +16 −0 Original line number Diff line number Diff line Loading @@ -1160,6 +1160,22 @@ public class AudioDeviceInventory { .record(); } /** * Returns whether a device of type DEVICE_OUT_HEARING_AID is connected. * Visibility by APM plays no role * @return true if a DEVICE_OUT_HEARING_AID is connected, false otherwise. */ boolean isHearingAidConnected() { synchronized (mDevicesLock) { for (DeviceInfo di : mConnectedDevices.values()) { if (di.mDeviceType == AudioSystem.DEVICE_OUT_HEARING_AID) { return true; } } return false; } } @GuardedBy("mDevicesLock") private void makeLeAudioDeviceAvailable(String address, String name, int streamType, int volumeIndex, int device, String eventSource) { Loading services/core/java/com/android/server/audio/BtHelper.java +7 −3 Original line number Diff line number Diff line Loading @@ -422,7 +422,8 @@ public class BtHelper { mLeAudio.setVolume(volume); } /*package*/ synchronized void setHearingAidVolume(int index, int streamType) { /*package*/ synchronized void setHearingAidVolume(int index, int streamType, boolean isHeadAidConnected) { if (mHearingAid == null) { if (AudioService.DEBUG_VOL) { Log.i(TAG, "setHearingAidVolume: null mHearingAid"); Loading @@ -439,8 +440,11 @@ public class BtHelper { Log.i(TAG, "setHearingAidVolume: calling mHearingAid.setVolume idx=" + index + " gain=" + gainDB); } // do not log when hearing aid is not connected to avoid confusion when reading dumpsys if (isHeadAidConnected) { AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent( AudioServiceEvents.VolumeEvent.VOL_SET_HEARING_AID_VOL, index, gainDB)); } mHearingAid.setVolume(gainDB); } Loading Loading
services/core/java/com/android/server/audio/AudioDeviceBroker.java +2 −1 Original line number Diff line number Diff line Loading @@ -1323,7 +1323,8 @@ import java.util.concurrent.atomic.AtomicBoolean; break; case MSG_II_SET_HEARING_AID_VOLUME: synchronized (mDeviceStateLock) { mBtHelper.setHearingAidVolume(msg.arg1, msg.arg2); mBtHelper.setHearingAidVolume(msg.arg1, msg.arg2, mDeviceInventory.isHearingAidConnected()); } break; case MSG_II_SET_LE_AUDIO_OUT_VOLUME: { Loading
services/core/java/com/android/server/audio/AudioDeviceInventory.java +16 −0 Original line number Diff line number Diff line Loading @@ -1160,6 +1160,22 @@ public class AudioDeviceInventory { .record(); } /** * Returns whether a device of type DEVICE_OUT_HEARING_AID is connected. * Visibility by APM plays no role * @return true if a DEVICE_OUT_HEARING_AID is connected, false otherwise. */ boolean isHearingAidConnected() { synchronized (mDevicesLock) { for (DeviceInfo di : mConnectedDevices.values()) { if (di.mDeviceType == AudioSystem.DEVICE_OUT_HEARING_AID) { return true; } } return false; } } @GuardedBy("mDevicesLock") private void makeLeAudioDeviceAvailable(String address, String name, int streamType, int volumeIndex, int device, String eventSource) { Loading
services/core/java/com/android/server/audio/BtHelper.java +7 −3 Original line number Diff line number Diff line Loading @@ -422,7 +422,8 @@ public class BtHelper { mLeAudio.setVolume(volume); } /*package*/ synchronized void setHearingAidVolume(int index, int streamType) { /*package*/ synchronized void setHearingAidVolume(int index, int streamType, boolean isHeadAidConnected) { if (mHearingAid == null) { if (AudioService.DEBUG_VOL) { Log.i(TAG, "setHearingAidVolume: null mHearingAid"); Loading @@ -439,8 +440,11 @@ public class BtHelper { Log.i(TAG, "setHearingAidVolume: calling mHearingAid.setVolume idx=" + index + " gain=" + gainDB); } // do not log when hearing aid is not connected to avoid confusion when reading dumpsys if (isHeadAidConnected) { AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent( AudioServiceEvents.VolumeEvent.VOL_SET_HEARING_AID_VOL, index, gainDB)); } mHearingAid.setVolume(gainDB); } Loading