Loading services/core/java/com/android/server/audio/AudioService.java +14 −4 Original line number Diff line number Diff line Loading @@ -8571,6 +8571,12 @@ public class AudioService extends IAudioService.Stub return true; } private boolean shouldPreserveVolume(boolean userSwitch, VolumeGroupState vgs) { // as for STREAM_MUSIC, preserve volume from one user to the next except // Android Automotive platform return (userSwitch && vgs.isMusic()) && !isPlatformAutomotive(); } private void readVolumeGroupsSettings(boolean userSwitch) { synchronized (mSettingsLock) { synchronized (VolumeStreamState.class) { Loading @@ -8579,8 +8585,7 @@ public class AudioService extends IAudioService.Stub } for (int i = 0; i < sVolumeGroupStates.size(); i++) { VolumeGroupState vgs = sVolumeGroupStates.valueAt(i); // as for STREAM_MUSIC, preserve volume from one user to the next. if (!(userSwitch && vgs.isMusic())) { if (!shouldPreserveVolume(userSwitch, vgs)) { vgs.clearIndexCache(); vgs.readSettings(); } Loading Loading @@ -9019,6 +9024,11 @@ public class AudioService extends IAudioService.Stub mIndexMap.clear(); } private @UserIdInt int getVolumePersistenceUserId() { return isMusic() && !isPlatformAutomotive() ? UserHandle.USER_SYSTEM : UserHandle.USER_CURRENT; } private void persistVolumeGroup(int device) { // No need to persist the index if the volume group is backed up // by a public stream type as this is redundant Loading @@ -9036,7 +9046,7 @@ public class AudioService extends IAudioService.Stub boolean success = mSettings.putSystemIntForUser(mContentResolver, getSettingNameForDevice(device), getIndex(device), isMusic() ? UserHandle.USER_SYSTEM : UserHandle.USER_CURRENT); getVolumePersistenceUserId()); if (!success) { Log.e(TAG, "persistVolumeGroup failed for group " + mAudioVolumeGroup.name()); } Loading @@ -9059,7 +9069,7 @@ public class AudioService extends IAudioService.Stub String name = getSettingNameForDevice(device); index = mSettings.getSystemIntForUser( mContentResolver, name, defaultIndex, isMusic() ? UserHandle.USER_SYSTEM : UserHandle.USER_CURRENT); getVolumePersistenceUserId()); if (index == -1) { continue; } Loading Loading
services/core/java/com/android/server/audio/AudioService.java +14 −4 Original line number Diff line number Diff line Loading @@ -8571,6 +8571,12 @@ public class AudioService extends IAudioService.Stub return true; } private boolean shouldPreserveVolume(boolean userSwitch, VolumeGroupState vgs) { // as for STREAM_MUSIC, preserve volume from one user to the next except // Android Automotive platform return (userSwitch && vgs.isMusic()) && !isPlatformAutomotive(); } private void readVolumeGroupsSettings(boolean userSwitch) { synchronized (mSettingsLock) { synchronized (VolumeStreamState.class) { Loading @@ -8579,8 +8585,7 @@ public class AudioService extends IAudioService.Stub } for (int i = 0; i < sVolumeGroupStates.size(); i++) { VolumeGroupState vgs = sVolumeGroupStates.valueAt(i); // as for STREAM_MUSIC, preserve volume from one user to the next. if (!(userSwitch && vgs.isMusic())) { if (!shouldPreserveVolume(userSwitch, vgs)) { vgs.clearIndexCache(); vgs.readSettings(); } Loading Loading @@ -9019,6 +9024,11 @@ public class AudioService extends IAudioService.Stub mIndexMap.clear(); } private @UserIdInt int getVolumePersistenceUserId() { return isMusic() && !isPlatformAutomotive() ? UserHandle.USER_SYSTEM : UserHandle.USER_CURRENT; } private void persistVolumeGroup(int device) { // No need to persist the index if the volume group is backed up // by a public stream type as this is redundant Loading @@ -9036,7 +9046,7 @@ public class AudioService extends IAudioService.Stub boolean success = mSettings.putSystemIntForUser(mContentResolver, getSettingNameForDevice(device), getIndex(device), isMusic() ? UserHandle.USER_SYSTEM : UserHandle.USER_CURRENT); getVolumePersistenceUserId()); if (!success) { Log.e(TAG, "persistVolumeGroup failed for group " + mAudioVolumeGroup.name()); } Loading @@ -9059,7 +9069,7 @@ public class AudioService extends IAudioService.Stub String name = getSettingNameForDevice(device); index = mSettings.getSystemIntForUser( mContentResolver, name, defaultIndex, isMusic() ? UserHandle.USER_SYSTEM : UserHandle.USER_CURRENT); getVolumePersistenceUserId()); if (index == -1) { continue; } Loading