From 780caff380fad5da59c72f8706932a8ae72520f3 Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Fri, 12 Jul 2013 09:51:53 +0200 Subject: Fix occasionally flickering music control widget. The problem was seemingly related to the player abandoning audio focus while the playback state was still set to 'playing'. In that case, the transport control was removed from the keyguard host because it had no listener anymore, but later was re-added due to isMusicPlaying() still returning true. Re-adding it lead to it re-registering with audio service, which cleared the display due to nothing being connected, which lead to the detachment listener being called again, which in turned closed the loop. While this may be a sign of a buggy player app (it should stop its playback prior to abandoning audio focus), this situation still should be handled gracefully. Fix the problem by simply reporting no music being played while no remote control client is connected. Change-Id: Id6834d38bc6faa3b6455ac66b413443f85606785 --- .../policy/impl/keyguard/KeyguardTransportControlView.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java index 20be303..b880d5f 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardTransportControlView.java @@ -382,8 +382,11 @@ public class KeyguardTransportControlView extends FrameLayout implements OnClick } public boolean isMusicPlaying() { - return mCurrentPlayState == RemoteControlClient.PLAYSTATE_PLAYING - || mCurrentPlayState == RemoteControlClient.PLAYSTATE_BUFFERING; + if (!mMusicClientPresent) { + return false; + } + return mCurrentPlayState == RemoteControlClient.PLAYSTATE_PLAYING + || mCurrentPlayState == RemoteControlClient.PLAYSTATE_BUFFERING; } private static void setVisibilityBasedOnFlag(View view, int flags, int flag) { -- cgit v1.1