diff options
| author | 2023-02-08 21:03:04 +0000 | |
|---|---|---|
| committer | 2023-02-08 21:03:04 +0000 | |
| commit | a522f0b792285dc8dab38cabfc6315e25adfc59b (patch) | |
| tree | ce239d1e76a0daf8b4856842ff9d8354c6e3dc98 | |
| parent | eff698308fdb514e7287d0d0f8cd618c560db7bb (diff) | |
| parent | 566b5183be92043bdffa2673ae41a0f8763bb9a4 (diff) | |
Merge "DO NOT MERGE AudioService: setDeviceVolume no-op when for current device" into tm-qpr-dev
| -rw-r--r-- | services/core/java/com/android/server/audio/AudioService.java | 9 | ||||
| -rw-r--r-- | services/core/java/com/android/server/audio/AudioServiceEvents.java | 16 |
2 files changed, 19 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index b8e3a3ac1d1a..9f1512825c3a 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -3831,8 +3831,15 @@ public class AudioService extends IAudioService.Stub // VOLUME_CHANGED_ACTION intent to see if the current device is the one being modified final int currDev = getDeviceForStream(vi.getStreamType()); + final boolean skipping = (currDev == ada.getInternalType()); + AudioService.sVolumeLogger.log(new DeviceVolumeEvent(vi.getStreamType(), index, ada, - currDev, callingPackage)); + currDev, callingPackage, skipping)); + + if (skipping) { + // setDeviceVolume was called on a device currently being used + return; + } // TODO handle unmuting of current audio device // if a stream is not muted but the VolumeInfo is for muting, set the volume index diff --git a/services/core/java/com/android/server/audio/AudioServiceEvents.java b/services/core/java/com/android/server/audio/AudioServiceEvents.java index 6cbe03ed87d3..36908dc73c24 100644 --- a/services/core/java/com/android/server/audio/AudioServiceEvents.java +++ b/services/core/java/com/android/server/audio/AudioServiceEvents.java @@ -174,15 +174,17 @@ public class AudioServiceEvents { final String mDeviceAddress; final String mCaller; final int mDeviceForStream; + final boolean mSkipped; DeviceVolumeEvent(int streamType, int index, @NonNull AudioDeviceAttributes device, - int deviceForStream, String callingPackage) { + int deviceForStream, String callingPackage, boolean skipped) { mStream = streamType; mVolIndex = index; mDeviceNativeType = "0x" + Integer.toHexString(device.getInternalType()); mDeviceAddress = device.getAddress(); mDeviceForStream = deviceForStream; mCaller = callingPackage; + mSkipped = skipped; // log metrics new MediaMetrics.Item(MediaMetrics.Name.AUDIO_VOLUME_EVENT) .set(MediaMetrics.Property.EVENT, "setDeviceVolume") @@ -197,14 +199,18 @@ public class AudioServiceEvents { @Override public String eventToString() { - return new StringBuilder("setDeviceVolume(stream:") + final StringBuilder sb = new StringBuilder("setDeviceVolume(stream:") .append(AudioSystem.streamToString(mStream)) .append(" index:").append(mVolIndex) .append(" device:").append(mDeviceNativeType) .append(" addr:").append(mDeviceAddress) - .append(") from ").append(mCaller) - .append(" currDevForStream:Ox").append(Integer.toHexString(mDeviceForStream)) - .toString(); + .append(") from ").append(mCaller); + if (mSkipped) { + sb.append(" skipped [device in use]"); + } else { + sb.append(" currDevForStream:Ox").append(Integer.toHexString(mDeviceForStream)); + } + return sb.toString(); } } |