Loading services/core/java/com/android/server/audio/AudioService.java +50 −10 Original line number Diff line number Diff line Loading @@ -1608,7 +1608,14 @@ public class AudioService extends IAudioService.Stub if (dev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { enabled = mAvrcpAbsVolSupported; } mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", enabled, stream); final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", enabled, stream); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, dev, enabled, stream).eventToString(), ALOGE, TAG); } }); } } Loading Loading @@ -2069,7 +2076,13 @@ public class AudioService extends IAudioService.Stub if (dev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { enabled = mAvrcpAbsVolSupported; } mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", enabled, stream); final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", enabled, stream); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, dev, enabled, stream).eventToString(), ALOGE, TAG); } }); } Loading Loading @@ -4917,15 +4930,27 @@ public class AudioService extends IAudioService.Stub private void onUpdateContextualVolumes() { final int streamType = getBluetoothContextualVolumeStream(); Log.i(TAG, "onUpdateContextualVolumes: absolute volume driving streams " + streamType + " avrcp supported: " + mAvrcpAbsVolSupported); synchronized (mCachedAbsVolDrivingStreamsLock) { mCachedAbsVolDrivingStreams.replaceAll((absDev, stream) -> { boolean enabled = true; if (absDev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { enabled = mAvrcpAbsVolSupported; if (!enabled) { Log.w(TAG, "Updating avrcp not supported in onUpdateContextualVolumes"); } } if (stream != streamType) { final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(absDev, /*address=*/"", enabled, streamType); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, absDev, enabled, streamType).eventToString(), ALOGE, TAG); } if (stream != streamType || !enabled) { mAudioSystem.setDeviceAbsoluteVolumeEnabled(absDev, /*address=*/"", enabled, streamType); } return streamType; }); Loading Loading @@ -10563,14 +10588,23 @@ public class AudioService extends IAudioService.Stub } /*package*/ void setAvrcpAbsoluteVolumeSupported(boolean support) { Log.i(TAG, "setAvrcpAbsoluteVolumeSupported support " + support); synchronized (mCachedAbsVolDrivingStreamsLock) { mAvrcpAbsVolSupported = support; if (absVolumeIndexFix()) { int a2dpDev = AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP; mCachedAbsVolDrivingStreams.compute(a2dpDev, (dev, stream) -> { if (!mAvrcpAbsVolSupported) { mAudioSystem.setDeviceAbsoluteVolumeEnabled(a2dpDev, /*address=*/ "", /*enabled*/false, AudioSystem.STREAM_DEFAULT); final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled( a2dpDev, /*address=*/"", /*enabled*/false, AudioSystem.STREAM_DEFAULT); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, a2dpDev, /*enabled=*/false, AudioSystem.STREAM_DEFAULT).eventToString(), ALOGE, TAG); } return null; } // For A2DP and AVRCP we need to set the driving stream based on the Loading @@ -10578,8 +10612,14 @@ public class AudioService extends IAudioService.Stub // and setStreamVolume that the driving abs volume stream is consistent. int streamToDriveAbs = getBluetoothContextualVolumeStream(); if (stream == null || stream != streamToDriveAbs) { mAudioSystem.setDeviceAbsoluteVolumeEnabled(a2dpDev, /*address=*/ "", /*enabled*/true, streamToDriveAbs); final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(a2dpDev, /*address=*/"", /*enabled*/true, streamToDriveAbs); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, a2dpDev, /*enabled=*/true, streamToDriveAbs).eventToString(), ALOGE, TAG); } } return streamToDriveAbs; }); Loading Loading @@ -12679,7 +12719,7 @@ public class AudioService extends IAudioService.Stub pw.println("\nLoudness alignment:"); mLoudnessCodecHelper.dump(pw); pw.println("\nAbsolute voume devices:"); pw.println("\nAbsolute volume devices with their volume driving streams:"); synchronized (mCachedAbsVolDrivingStreamsLock) { mCachedAbsVolDrivingStreams.forEach((dev, stream) -> pw.println( "Device type: 0x" + Integer.toHexString(dev) + ", driving stream " + stream)); services/core/java/com/android/server/audio/AudioServiceEvents.java +24 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,7 @@ public class AudioServiceEvents { static final int VOL_SET_LE_AUDIO_VOL = 10; static final int VOL_ADJUST_GROUP_VOL = 11; static final int VOL_MASTER_MUTE = 12; static final int VOL_ABS_DEVICE_ENABLED_ERROR = 13; final int mOp; final int mStream; Loading Loading @@ -365,6 +366,19 @@ public class AudioServiceEvents { logMetricEvent(); } /** used for VOL_ABS_DEVICE_ENABLED_ERROR */ VolumeEvent(int op, int result, int device, boolean enabled, int streamType) { mOp = op; mStream = streamType; mVal1 = device; mVal2 = enabled ? 1 : 0; mVal3 = result; // unused mCaller = null; mGroupName = null; logMetricEvent(); } /** * Audio Analytics unique Id. Loading Loading @@ -481,6 +495,9 @@ public class AudioServiceEvents { case VOL_MASTER_MUTE: // No value in logging metrics for this internal event return; case VOL_ABS_DEVICE_ENABLED_ERROR: // No value in logging metrics for this internal event return; default: return; } Loading Loading @@ -569,6 +586,13 @@ public class AudioServiceEvents { return new StringBuilder("Master mute:") .append(mVal1 == 1 ? " muted)" : " unmuted)") .toString(); case VOL_ABS_DEVICE_ENABLED_ERROR: return new StringBuilder("setDeviceAbsoluteVolumeEnabled failed with ") .append(mVal3) .append(" for dev: 0x").append(Integer.toHexString(mVal1)) .append(" enabled: ").append(mVal2) .append(" streamType: ").append(mStream) .toString(); default: return new StringBuilder("FIXME invalid op:").append(mOp).toString(); } } Loading Loading
services/core/java/com/android/server/audio/AudioService.java +50 −10 Original line number Diff line number Diff line Loading @@ -1608,7 +1608,14 @@ public class AudioService extends IAudioService.Stub if (dev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { enabled = mAvrcpAbsVolSupported; } mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", enabled, stream); final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", enabled, stream); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, dev, enabled, stream).eventToString(), ALOGE, TAG); } }); } } Loading Loading @@ -2069,7 +2076,13 @@ public class AudioService extends IAudioService.Stub if (dev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { enabled = mAvrcpAbsVolSupported; } mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", enabled, stream); final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", enabled, stream); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, dev, enabled, stream).eventToString(), ALOGE, TAG); } }); } Loading Loading @@ -4917,15 +4930,27 @@ public class AudioService extends IAudioService.Stub private void onUpdateContextualVolumes() { final int streamType = getBluetoothContextualVolumeStream(); Log.i(TAG, "onUpdateContextualVolumes: absolute volume driving streams " + streamType + " avrcp supported: " + mAvrcpAbsVolSupported); synchronized (mCachedAbsVolDrivingStreamsLock) { mCachedAbsVolDrivingStreams.replaceAll((absDev, stream) -> { boolean enabled = true; if (absDev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { enabled = mAvrcpAbsVolSupported; if (!enabled) { Log.w(TAG, "Updating avrcp not supported in onUpdateContextualVolumes"); } } if (stream != streamType) { final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(absDev, /*address=*/"", enabled, streamType); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, absDev, enabled, streamType).eventToString(), ALOGE, TAG); } if (stream != streamType || !enabled) { mAudioSystem.setDeviceAbsoluteVolumeEnabled(absDev, /*address=*/"", enabled, streamType); } return streamType; }); Loading Loading @@ -10563,14 +10588,23 @@ public class AudioService extends IAudioService.Stub } /*package*/ void setAvrcpAbsoluteVolumeSupported(boolean support) { Log.i(TAG, "setAvrcpAbsoluteVolumeSupported support " + support); synchronized (mCachedAbsVolDrivingStreamsLock) { mAvrcpAbsVolSupported = support; if (absVolumeIndexFix()) { int a2dpDev = AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP; mCachedAbsVolDrivingStreams.compute(a2dpDev, (dev, stream) -> { if (!mAvrcpAbsVolSupported) { mAudioSystem.setDeviceAbsoluteVolumeEnabled(a2dpDev, /*address=*/ "", /*enabled*/false, AudioSystem.STREAM_DEFAULT); final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled( a2dpDev, /*address=*/"", /*enabled*/false, AudioSystem.STREAM_DEFAULT); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, a2dpDev, /*enabled=*/false, AudioSystem.STREAM_DEFAULT).eventToString(), ALOGE, TAG); } return null; } // For A2DP and AVRCP we need to set the driving stream based on the Loading @@ -10578,8 +10612,14 @@ public class AudioService extends IAudioService.Stub // and setStreamVolume that the driving abs volume stream is consistent. int streamToDriveAbs = getBluetoothContextualVolumeStream(); if (stream == null || stream != streamToDriveAbs) { mAudioSystem.setDeviceAbsoluteVolumeEnabled(a2dpDev, /*address=*/ "", /*enabled*/true, streamToDriveAbs); final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(a2dpDev, /*address=*/"", /*enabled*/true, streamToDriveAbs); if (result != AudioSystem.AUDIO_STATUS_OK) { sVolumeLogger.enqueueAndSlog( new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, result, a2dpDev, /*enabled=*/true, streamToDriveAbs).eventToString(), ALOGE, TAG); } } return streamToDriveAbs; }); Loading Loading @@ -12679,7 +12719,7 @@ public class AudioService extends IAudioService.Stub pw.println("\nLoudness alignment:"); mLoudnessCodecHelper.dump(pw); pw.println("\nAbsolute voume devices:"); pw.println("\nAbsolute volume devices with their volume driving streams:"); synchronized (mCachedAbsVolDrivingStreamsLock) { mCachedAbsVolDrivingStreams.forEach((dev, stream) -> pw.println( "Device type: 0x" + Integer.toHexString(dev) + ", driving stream " + stream));
services/core/java/com/android/server/audio/AudioServiceEvents.java +24 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,7 @@ public class AudioServiceEvents { static final int VOL_SET_LE_AUDIO_VOL = 10; static final int VOL_ADJUST_GROUP_VOL = 11; static final int VOL_MASTER_MUTE = 12; static final int VOL_ABS_DEVICE_ENABLED_ERROR = 13; final int mOp; final int mStream; Loading Loading @@ -365,6 +366,19 @@ public class AudioServiceEvents { logMetricEvent(); } /** used for VOL_ABS_DEVICE_ENABLED_ERROR */ VolumeEvent(int op, int result, int device, boolean enabled, int streamType) { mOp = op; mStream = streamType; mVal1 = device; mVal2 = enabled ? 1 : 0; mVal3 = result; // unused mCaller = null; mGroupName = null; logMetricEvent(); } /** * Audio Analytics unique Id. Loading Loading @@ -481,6 +495,9 @@ public class AudioServiceEvents { case VOL_MASTER_MUTE: // No value in logging metrics for this internal event return; case VOL_ABS_DEVICE_ENABLED_ERROR: // No value in logging metrics for this internal event return; default: return; } Loading Loading @@ -569,6 +586,13 @@ public class AudioServiceEvents { return new StringBuilder("Master mute:") .append(mVal1 == 1 ? " muted)" : " unmuted)") .toString(); case VOL_ABS_DEVICE_ENABLED_ERROR: return new StringBuilder("setDeviceAbsoluteVolumeEnabled failed with ") .append(mVal3) .append(" for dev: 0x").append(Integer.toHexString(mVal1)) .append(" enabled: ").append(mVal2) .append(" streamType: ").append(mStream) .toString(); default: return new StringBuilder("FIXME invalid op:").append(mOp).toString(); } } Loading