diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2011-09-21 09:36:56 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-09-21 09:36:56 -0700 |
commit | eb060254a0b7aa42ab05ed6539156c3084ec1908 (patch) | |
tree | 1761514f154b567612d108c6a902bb819cf70847 /media | |
parent | 13dfa095c2a62b0bece80c12300fcab3f20a2cbe (diff) | |
parent | 9c43016b52afa855156aac2dc81a2bbe1e4ab436 (diff) | |
download | frameworks_base-eb060254a0b7aa42ab05ed6539156c3084ec1908.zip frameworks_base-eb060254a0b7aa42ab05ed6539156c3084ec1908.tar.gz frameworks_base-eb060254a0b7aa42ab05ed6539156c3084ec1908.tar.bz2 |
am 9c43016b: Merge "Bug 5045498 Keep track of RemoteControlClient play state change time" into ics-factoryrom
* commit '9c43016b52afa855156aac2dc81a2bbe1e4ab436':
Bug 5045498 Keep track of RemoteControlClient play state change time
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/IRemoteControlDisplay.aidl | 2 | ||||
-rw-r--r-- | media/java/android/media/RemoteControlClient.java | 23 |
2 files changed, 18 insertions, 7 deletions
diff --git a/media/java/android/media/IRemoteControlDisplay.aidl b/media/java/android/media/IRemoteControlDisplay.aidl index e15b07c..204de3c 100644 --- a/media/java/android/media/IRemoteControlDisplay.aidl +++ b/media/java/android/media/IRemoteControlDisplay.aidl @@ -40,7 +40,7 @@ oneway interface IRemoteControlDisplay void setCurrentClientId(int clientGeneration, in PendingIntent clientMediaIntent, boolean clearing); - void setPlaybackState(int generationId, int state); + void setPlaybackState(int generationId, int state, long stateChangeTimeMs); void setTransportControlFlags(int generationId, int transportControlFlags); diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java index 5dea87f..198ae4c 100644 --- a/media/java/android/media/RemoteControlClient.java +++ b/media/java/android/media/RemoteControlClient.java @@ -29,6 +29,7 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.RemoteException; +import android.os.SystemClock; import android.util.Log; import java.lang.IllegalArgumentException; @@ -494,11 +495,15 @@ public class RemoteControlClient */ public void setPlaybackState(int state) { synchronized(mCacheLock) { - // store locally - mPlaybackState = state; - - // send to remote control display if conditions are met - sendPlaybackState_syncCacheLock(); + if (mPlaybackState != state) { + // store locally + mPlaybackState = state; + // keep track of when the state change occurred + mPlaybackStateChangeTimeMs = SystemClock.elapsedRealtime(); + + // send to remote control display if conditions are met + sendPlaybackState_syncCacheLock(); + } } } @@ -534,6 +539,11 @@ public class RemoteControlClient */ private int mPlaybackState = PLAYSTATE_NONE; /** + * Time of last play state change + * Access synchronized on mCacheLock + */ + private long mPlaybackStateChangeTimeMs = 0; + /** * Cache for the artwork bitmap. * Access synchronized on mCacheLock * Artwork and metadata are not kept in one Bundle because the bitmap sometimes needs to be @@ -716,7 +726,8 @@ public class RemoteControlClient private void sendPlaybackState_syncCacheLock() { if ((mCurrentClientGenId == mInternalClientGenId) && (mRcDisplay != null)) { try { - mRcDisplay.setPlaybackState(mInternalClientGenId, mPlaybackState); + mRcDisplay.setPlaybackState(mInternalClientGenId, mPlaybackState, + mPlaybackStateChangeTimeMs); } catch (RemoteException e) { Log.e(TAG, "Error in setPlaybackState(), dead display "+e); detachFromDisplay_syncCacheLock(); |