diff options
author | RoboErik <epastern@google.com> | 2015-01-07 11:10:23 -0800 |
---|---|---|
committer | Erik Pasternak <roboerik@android.com> | 2015-01-07 20:13:31 +0000 |
commit | 2610d71251e3e376e2514f20986c81e5d55f1b55 (patch) | |
tree | aa9b6b6881bebd7a9aa37108fb770f00006fffee | |
parent | f61bc8a2624bc70c903238229a62abc3351ed620 (diff) | |
download | frameworks_base-2610d71251e3e376e2514f20986c81e5d55f1b55.zip frameworks_base-2610d71251e3e376e2514f20986c81e5d55f1b55.tar.gz frameworks_base-2610d71251e3e376e2514f20986c81e5d55f1b55.tar.bz2 |
Don't unmute when trying to show volume UI. DO NOT MERGE
When a MediaSession is active the adjust volume event to show UI was
causing the stream to be unmuted. Since this happens after every mute
event you were unable to mute while a session was active. This change
doesn't unmute for events that just show the UI.
bug:18844550
Change-Id: Ic8b0f1ab1354646724ead4572a973c302c275eab
-rw-r--r-- | services/core/java/com/android/server/media/MediaSessionRecord.java | 11 | ||||
-rw-r--r-- | services/core/java/com/android/server/media/MediaSessionService.java | 10 |
2 files changed, 11 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java index 1fba7bb..03a5920 100644 --- a/services/core/java/com/android/server/media/MediaSessionRecord.java +++ b/services/core/java/com/android/server/media/MediaSessionRecord.java @@ -93,7 +93,6 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { private final MediaSessionService mService; private final boolean mUseMasterVolume; - private final IBinder mICallback = new Binder(); private final Object mLock = new Object(); private final ArrayList<ISessionControllerCallback> mControllerCallbacks = new ArrayList<ISessionControllerCallback>(); @@ -260,13 +259,13 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { boolean isMasterMute = mAudioManager.isMasterMute(); if (isMute) { mAudioManagerInternal.setMasterMuteForUid(!isMasterMute, - flags, packageName, mICallback, uid); + flags, packageName, mService.mICallback, uid); } else { mAudioManagerInternal.adjustMasterVolumeForUid(direction, flags, packageName, uid); if (isMasterMute) { mAudioManagerInternal.setMasterMuteForUid(false, - flags, packageName, mICallback, uid); + flags, packageName, mService.mICallback, uid); } } return; @@ -280,7 +279,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { } else { mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction, flags, packageName, uid); - if (isStreamMute) { + if (isStreamMute && direction != 0) { mAudioManager.setStreamMute(stream, false); } } @@ -295,7 +294,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { mAudioManagerInternal.adjustSuggestedStreamVolumeForUid( AudioManager.USE_DEFAULT_STREAM_TYPE, direction, flags, packageName, uid); - if (isStreamMute) { + if (isStreamMute && direction != 0) { mAudioManager.setStreamMute(AudioManager.USE_DEFAULT_STREAM_TYPE, false); } @@ -307,7 +306,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { } else { mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags, packageName, uid); - if (isStreamMute) { + if (isStreamMute && direction != 0) { mAudioManager.setStreamMute(stream, false); } } diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java index 105ec77..22acfea 100644 --- a/services/core/java/com/android/server/media/MediaSessionService.java +++ b/services/core/java/com/android/server/media/MediaSessionService.java @@ -77,6 +77,8 @@ public class MediaSessionService extends SystemService implements Monitor { private static final int WAKELOCK_TIMEOUT = 5000; + /* package */final IBinder mICallback = new Binder(); + private final SessionManagerImpl mSessionManagerImpl; private final MediaSessionStack mPriorityStack; @@ -91,6 +93,7 @@ public class MediaSessionService extends SystemService implements Monitor { private KeyguardManager mKeyguardManager; private IAudioService mAudioService; + private AudioManager mAudioManager; private ContentResolver mContentResolver; private SettingsObserver mSettingsObserver; @@ -118,6 +121,7 @@ public class MediaSessionService extends SystemService implements Monitor { mKeyguardManager = (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE); mAudioService = getAudioService(); + mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); mContentResolver = getContext().getContentResolver(); mSettingsObserver = new SettingsObserver(); mSettingsObserver.observe(); @@ -589,8 +593,6 @@ public class MediaSessionService extends SystemService implements Monitor { "android.media.AudioService.WAKELOCK_ACQUIRED"; private static final int WAKELOCK_RELEASE_ON_FINISHED = 1980; // magic number - private final IBinder mICallback = new Binder(); - private boolean mVoiceButtonDown = false; private boolean mVoiceButtonHandled = false; @@ -845,14 +847,14 @@ public class MediaSessionService extends SystemService implements Monitor { } else { boolean isStreamMute = mAudioService.isStreamMute(suggestedStream); if (direction == MediaSessionManager.DIRECTION_MUTE) { - mAudioService.setStreamMute(suggestedStream, !isStreamMute, mICallback); + mAudioManager.setStreamMute(suggestedStream, !isStreamMute); } else { mAudioService.adjustSuggestedStreamVolume(direction, suggestedStream, flags, packageName); // Do not call setStreamMute when direction = 0 which is used just to // show the UI. if (isStreamMute && direction != 0) { - mAudioService.setStreamMute(suggestedStream, false, mICallback); + mAudioManager.setStreamMute(suggestedStream, false); } } } |