Loading services/core/java/com/android/server/media/MediaSessionRecord.java +19 −27 Original line number Original line Diff line number Diff line Loading @@ -241,19 +241,10 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { flags &= ~AudioManager.FLAG_PLAY_SOUND; flags &= ~AudioManager.FLAG_PLAY_SOUND; } } if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) { if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) { int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs); // Adjust the volume with a handler not to be blocked by other system service. // Adjust the volume with a handler not to be blocked by other system service. if (useSuggested) { int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs); if (AudioSystem.isStreamActive(stream, 0)) { postAdjustLocalVolume(stream, direction, flags, packageName, uid, useSuggested, postAdjustSuggestedStreamVolume(stream, direction, flags, packageName, uid); previousFlagPlaySound); } else { flags |= previousFlagPlaySound; postAdjustSuggestedStreamVolume(AudioManager.USE_DEFAULT_STREAM_TYPE, direction, flags, packageName, uid); } } else { postAdjustStreamVolume(stream, direction, flags, packageName, uid); } } else { } else { if (mVolumeControlType == VolumeProvider.VOLUME_CONTROL_FIXED) { if (mVolumeControlType == VolumeProvider.VOLUME_CONTROL_FIXED) { // Nothing to do, the volume cannot be changed // Nothing to do, the volume cannot be changed Loading Loading @@ -459,24 +450,25 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { return mPackageName + "/" + mTag; return mPackageName + "/" + mTag; } } private void postAdjustSuggestedStreamVolume(final int streamType, final int direction, private void postAdjustLocalVolume(final int stream, final int direction, final int flags, final int flags, final String callingPackage, final int uid) { final String packageName, final int uid, final boolean useSuggested, final int previousFlagPlaySound) { mHandler.post(new Runnable() { mHandler.post(new Runnable() { @Override @Override public void run() { public void run() { mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(streamType, direction, if (useSuggested) { flags, callingPackage, uid); if (AudioSystem.isStreamActive(stream, 0)) { mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction, flags, packageName, uid); } else { mAudioManagerInternal.adjustSuggestedStreamVolumeForUid( AudioManager.USE_DEFAULT_STREAM_TYPE, direction, flags | previousFlagPlaySound, packageName, uid); } } }); } else { mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags, packageName, uid); } } private void postAdjustStreamVolume(final int streamType, final int direction, final int flags, final String callingPackage, final int uid) { mHandler.post(new Runnable() { @Override public void run() { mAudioManagerInternal.adjustStreamVolumeForUid(streamType, direction, flags, callingPackage, uid); } } }); }); } } Loading Loading
services/core/java/com/android/server/media/MediaSessionRecord.java +19 −27 Original line number Original line Diff line number Diff line Loading @@ -241,19 +241,10 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { flags &= ~AudioManager.FLAG_PLAY_SOUND; flags &= ~AudioManager.FLAG_PLAY_SOUND; } } if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) { if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) { int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs); // Adjust the volume with a handler not to be blocked by other system service. // Adjust the volume with a handler not to be blocked by other system service. if (useSuggested) { int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs); if (AudioSystem.isStreamActive(stream, 0)) { postAdjustLocalVolume(stream, direction, flags, packageName, uid, useSuggested, postAdjustSuggestedStreamVolume(stream, direction, flags, packageName, uid); previousFlagPlaySound); } else { flags |= previousFlagPlaySound; postAdjustSuggestedStreamVolume(AudioManager.USE_DEFAULT_STREAM_TYPE, direction, flags, packageName, uid); } } else { postAdjustStreamVolume(stream, direction, flags, packageName, uid); } } else { } else { if (mVolumeControlType == VolumeProvider.VOLUME_CONTROL_FIXED) { if (mVolumeControlType == VolumeProvider.VOLUME_CONTROL_FIXED) { // Nothing to do, the volume cannot be changed // Nothing to do, the volume cannot be changed Loading Loading @@ -459,24 +450,25 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { return mPackageName + "/" + mTag; return mPackageName + "/" + mTag; } } private void postAdjustSuggestedStreamVolume(final int streamType, final int direction, private void postAdjustLocalVolume(final int stream, final int direction, final int flags, final int flags, final String callingPackage, final int uid) { final String packageName, final int uid, final boolean useSuggested, final int previousFlagPlaySound) { mHandler.post(new Runnable() { mHandler.post(new Runnable() { @Override @Override public void run() { public void run() { mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(streamType, direction, if (useSuggested) { flags, callingPackage, uid); if (AudioSystem.isStreamActive(stream, 0)) { mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction, flags, packageName, uid); } else { mAudioManagerInternal.adjustSuggestedStreamVolumeForUid( AudioManager.USE_DEFAULT_STREAM_TYPE, direction, flags | previousFlagPlaySound, packageName, uid); } } }); } else { mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags, packageName, uid); } } private void postAdjustStreamVolume(final int streamType, final int direction, final int flags, final String callingPackage, final int uid) { mHandler.post(new Runnable() { @Override public void run() { mAudioManagerInternal.adjustStreamVolumeForUid(streamType, direction, flags, callingPackage, uid); } } }); }); } } Loading