Loading services/core/java/com/android/server/audio/AudioService.java +27 −3 Original line number Diff line number Diff line Loading @@ -5279,14 +5279,29 @@ public class AudioService extends IAudioService.Stub return mIndexMin; } private boolean isValidLegacyStreamType() { return (mLegacyStreamType != AudioSystem.STREAM_DEFAULT) && (mLegacyStreamType < mStreamStates.length); } public void applyAllVolumes() { synchronized (VolumeGroupState.class) { int deviceForStream = AudioSystem.DEVICE_NONE; int volumeIndexForStream = 0; if (isValidLegacyStreamType()) { // Prevent to apply settings twice when group is associated to public stream deviceForStream = getDeviceForStream(mLegacyStreamType); volumeIndexForStream = getStreamVolume(mLegacyStreamType); } // apply device specific volumes first int index; for (int i = 0; i < mIndexMap.size(); i++) { final int device = mIndexMap.keyAt(i); if (device != AudioSystem.DEVICE_OUT_DEFAULT) { index = mIndexMap.valueAt(i); if (device == deviceForStream && volumeIndexForStream == index) { continue; } if (DEBUG_VOL) { Log.v(TAG, "applyAllVolumes: restore index " + index + " for group " + mAudioVolumeGroup.name() + " and device " Loading @@ -5302,6 +5317,13 @@ public class AudioService extends IAudioService.Stub Log.v(TAG, "applyAllVolumes: restore default device index " + index + " for group " + mAudioVolumeGroup.name()); } if (isValidLegacyStreamType()) { int defaultStreamIndex = (mStreamStates[mLegacyStreamType] .getIndex(AudioSystem.DEVICE_OUT_DEFAULT) + 5) / 10; if (defaultStreamIndex == index) { return; } } setVolumeIndexInt(index, AudioSystem.DEVICE_OUT_DEFAULT, 0 /*flags*/); } } Loading @@ -5312,8 +5334,9 @@ public class AudioService extends IAudioService.Stub } if (DEBUG_VOL) { Log.v(TAG, "persistVolumeGroup: storing index " + getIndex(device) + " for group " + mAudioVolumeGroup.name() + " and device " + AudioSystem.getOutputDeviceName(device)); + mAudioVolumeGroup.name() + ", device " + AudioSystem.getOutputDeviceName(device) + " and User=" + ActivityManager.getCurrentUser()); } boolean success = Settings.System.putIntForUser(mContentResolver, getSettingNameForDevice(device), Loading Loading @@ -5348,7 +5371,8 @@ public class AudioService extends IAudioService.Stub } if (DEBUG_VOL) { Log.v(TAG, "readSettings: found stored index " + getValidIndex(index) + " for group " + mAudioVolumeGroup.name() + ", device: " + name); + " for group " + mAudioVolumeGroup.name() + ", device: " + name + ", User=" + ActivityManager.getCurrentUser()); } mIndexMap.put(device, getValidIndex(index)); } Loading Loading
services/core/java/com/android/server/audio/AudioService.java +27 −3 Original line number Diff line number Diff line Loading @@ -5279,14 +5279,29 @@ public class AudioService extends IAudioService.Stub return mIndexMin; } private boolean isValidLegacyStreamType() { return (mLegacyStreamType != AudioSystem.STREAM_DEFAULT) && (mLegacyStreamType < mStreamStates.length); } public void applyAllVolumes() { synchronized (VolumeGroupState.class) { int deviceForStream = AudioSystem.DEVICE_NONE; int volumeIndexForStream = 0; if (isValidLegacyStreamType()) { // Prevent to apply settings twice when group is associated to public stream deviceForStream = getDeviceForStream(mLegacyStreamType); volumeIndexForStream = getStreamVolume(mLegacyStreamType); } // apply device specific volumes first int index; for (int i = 0; i < mIndexMap.size(); i++) { final int device = mIndexMap.keyAt(i); if (device != AudioSystem.DEVICE_OUT_DEFAULT) { index = mIndexMap.valueAt(i); if (device == deviceForStream && volumeIndexForStream == index) { continue; } if (DEBUG_VOL) { Log.v(TAG, "applyAllVolumes: restore index " + index + " for group " + mAudioVolumeGroup.name() + " and device " Loading @@ -5302,6 +5317,13 @@ public class AudioService extends IAudioService.Stub Log.v(TAG, "applyAllVolumes: restore default device index " + index + " for group " + mAudioVolumeGroup.name()); } if (isValidLegacyStreamType()) { int defaultStreamIndex = (mStreamStates[mLegacyStreamType] .getIndex(AudioSystem.DEVICE_OUT_DEFAULT) + 5) / 10; if (defaultStreamIndex == index) { return; } } setVolumeIndexInt(index, AudioSystem.DEVICE_OUT_DEFAULT, 0 /*flags*/); } } Loading @@ -5312,8 +5334,9 @@ public class AudioService extends IAudioService.Stub } if (DEBUG_VOL) { Log.v(TAG, "persistVolumeGroup: storing index " + getIndex(device) + " for group " + mAudioVolumeGroup.name() + " and device " + AudioSystem.getOutputDeviceName(device)); + mAudioVolumeGroup.name() + ", device " + AudioSystem.getOutputDeviceName(device) + " and User=" + ActivityManager.getCurrentUser()); } boolean success = Settings.System.putIntForUser(mContentResolver, getSettingNameForDevice(device), Loading Loading @@ -5348,7 +5371,8 @@ public class AudioService extends IAudioService.Stub } if (DEBUG_VOL) { Log.v(TAG, "readSettings: found stored index " + getValidIndex(index) + " for group " + mAudioVolumeGroup.name() + ", device: " + name); + " for group " + mAudioVolumeGroup.name() + ", device: " + name + ", User=" + ActivityManager.getCurrentUser()); } mIndexMap.put(device, getValidIndex(index)); } Loading