am 4b495477: am 9f1bca5f: am 0ed179d1: am 4a154af9: Merge "Send volume keys to the default stream if not actually playing" into lmp-dev
* commit '4b495477d957cef0b0e199674d63b6147a3c4e58': Send volume keys to the default stream if not actually playing
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.Intent;
|
|||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.AudioManagerInternal;
|
import android.media.AudioManagerInternal;
|
||||||
|
import android.media.AudioSystem;
|
||||||
import android.media.MediaDescription;
|
import android.media.MediaDescription;
|
||||||
import android.media.MediaMetadata;
|
import android.media.MediaMetadata;
|
||||||
import android.media.Rating;
|
import android.media.Rating;
|
||||||
@@ -237,6 +238,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
|
|||||||
*/
|
*/
|
||||||
public void adjustVolume(int direction, int flags, String packageName, int uid,
|
public void adjustVolume(int direction, int flags, String packageName, int uid,
|
||||||
boolean useSuggested) {
|
boolean useSuggested) {
|
||||||
|
int previousFlagPlaySound = flags & AudioManager.FLAG_PLAY_SOUND;
|
||||||
if (isPlaybackActive(false) || hasFlag(MediaSession.FLAG_EXCLUSIVE_GLOBAL_PRIORITY)) {
|
if (isPlaybackActive(false) || hasFlag(MediaSession.FLAG_EXCLUSIVE_GLOBAL_PRIORITY)) {
|
||||||
flags &= ~AudioManager.FLAG_PLAY_SOUND;
|
flags &= ~AudioManager.FLAG_PLAY_SOUND;
|
||||||
}
|
}
|
||||||
@@ -248,8 +250,15 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
|
|||||||
if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) {
|
if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) {
|
||||||
int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs);
|
int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs);
|
||||||
if (useSuggested) {
|
if (useSuggested) {
|
||||||
mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction, flags,
|
if (AudioSystem.isStreamActive(stream, 0)) {
|
||||||
packageName, uid);
|
mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction,
|
||||||
|
flags, packageName, uid);
|
||||||
|
} else {
|
||||||
|
flags |= previousFlagPlaySound;
|
||||||
|
mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(
|
||||||
|
AudioManager.USE_DEFAULT_STREAM_TYPE, direction, flags, packageName,
|
||||||
|
uid);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags,
|
mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags,
|
||||||
packageName, uid);
|
packageName, uid);
|
||||||
|
|||||||
Reference in New Issue
Block a user