diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2012-10-29 12:42:55 -0700 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2012-10-29 12:42:55 -0700 |
commit | f4a8eb22112c534f436357b50f231778c5c15c25 (patch) | |
tree | db3319b4382be2d6d020ea616947634c4a43d33f /media | |
parent | 4bfa1e99e2ce5aa96465872a159377102a5bb4cb (diff) | |
download | frameworks_base-f4a8eb22112c534f436357b50f231778c5c15c25.zip frameworks_base-f4a8eb22112c534f436357b50f231778c5c15c25.tar.gz frameworks_base-f4a8eb22112c534f436357b50f231778c5c15c25.tar.bz2 |
No playback and music widget from other user on user switch
On user switch:
- make the current audio focus owner loose audio focus
- clear the remote control display
Bug 7205290
Bug 7307156
Change-Id: I6ebcb94d1d2bae8c57ab98dd7e795b239a981d28
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioService.java | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index a5c60d4..acd3eab 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -3913,7 +3913,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } else if (action.equalsIgnoreCase(Intent.ACTION_CONFIGURATION_CHANGED)) { handleConfigurationChanged(context); } else if (action.equals(Intent.ACTION_USER_SWITCHED)) { - // attempt to stop music playabck for background user + // attempt to stop music playback for background user sendMsg(mAudioHandler, MSG_BROADCAST_AUDIO_BECOMING_NOISY, SENDMSG_REPLACE, @@ -3921,6 +3921,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { 0, null, 0); + // the current audio focus owner is no longer valid + discardAudioFocusOwner(); + // load volume settings for new user readAudioSettings(true /*userSwitch*/); // preserve STREAM_MUSIC volume from one user to the next. @@ -3965,6 +3968,32 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } }; + /** + * Discard the current audio focus owner. + * Notify top of audio focus stack that it lost focus (regardless of possibility to reassign + * focus), remove it from the stack, and clear the remote control display. + */ + private void discardAudioFocusOwner() { + synchronized(mAudioFocusLock) { + if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null)) { + // notify the current focus owner it lost focus after removing it from stack + FocusStackEntry focusOwner = mFocusStack.pop(); + try { + focusOwner.mFocusDispatcher.dispatchAudioFocusChange( + AudioManager.AUDIOFOCUS_LOSS, focusOwner.mClientId); + } catch (RemoteException e) { + Log.e(TAG, "Failure to signal loss of audio focus due to "+ e); + e.printStackTrace(); + } + focusOwner.unlinkToDeath(); + // clear RCD + synchronized(mRCStack) { + clearRemoteControlDisplay_syncAfRcs(); + } + } + } + } + private void notifyTopOfAudioFocusStack() { // notify the top of the stack it gained focus if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null)) { @@ -4036,7 +4065,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { Iterator<FocusStackEntry> stackIterator = mFocusStack.iterator(); while(stackIterator.hasNext()) { FocusStackEntry fse = stackIterator.next(); - pw.println(" source:" + fse.mSourceRef + " -- client: " + fse.mClientId + pw.println(" source:" + fse.mSourceRef + + " -- pack: " + fse.mPackageName + + " -- client: " + fse.mClientId + " -- duration: " + fse.mFocusChangeType + " -- uid: " + fse.mCallingUid + " -- stream: " + fse.mStreamType); @@ -4718,6 +4749,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { while(stackIterator.hasNext()) { RemoteControlStackEntry rcse = stackIterator.next(); pw.println(" pi: " + rcse.mMediaIntent + + " -- pack: " + rcse.mCallingPackageName + " -- ercvr: " + rcse.mReceiverComponent + " -- client: " + rcse.mRcClient + " -- uid: " + rcse.mCallingUid + |