summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2011-09-19 14:53:14 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2011-09-20 11:59:51 -0700
commit68622396b62f9084781add1e12f4d513b633ab54 (patch)
tree453653c1bf8e7de308091370e08edef4aafe4cac /core
parentbbb11b80106c8687f2833c3d4b538029fc0805e6 (diff)
downloadframeworks_base-68622396b62f9084781add1e12f4d513b633ab54.zip
frameworks_base-68622396b62f9084781add1e12f4d513b633ab54.tar.gz
frameworks_base-68622396b62f9084781add1e12f4d513b633ab54.tar.bz2
Bug 5045498 Keep track of RemoteControlClient play state change time
Store the time at which a RemoteControlClient changes it playback state, and send that time to the IRemoteControlDisplay. This change will enable displays to implement strategies such as timeouts (e.g. to not display transport controls for clients which have been paused or stopped for a certain amount of time). Change-Id: I902882500565743d455d56f6000efaf612cbe0a9
Diffstat (limited to 'core')
-rw-r--r--core/java/com/android/internal/widget/TransportControlView.java33
1 files changed, 32 insertions, 1 deletions
diff --git a/core/java/com/android/internal/widget/TransportControlView.java b/core/java/com/android/internal/widget/TransportControlView.java
index 1c7ad61..1042a59 100644
--- a/core/java/com/android/internal/widget/TransportControlView.java
+++ b/core/java/com/android/internal/widget/TransportControlView.java
@@ -35,6 +35,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
+import android.os.SystemClock;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
@@ -59,6 +60,7 @@ public class TransportControlView extends FrameLayout implements OnClickListener
private static final int MSG_SET_ARTWORK = 103;
private static final int MSG_SET_GENERATION_ID = 104;
private static final int MAXDIM = 512;
+ private static final int DISPLAY_TIMEOUT_MS = 5000; // 5s
protected static final boolean DEBUG = true;
protected static final String TAG = "TransportControlView";
@@ -142,7 +144,7 @@ public class TransportControlView extends FrameLayout implements OnClickListener
mLocalHandler = new WeakReference<Handler>(handler);
}
- public void setPlaybackState(int generationId, int state) {
+ public void setPlaybackState(int generationId, int state, long stateChangeTimeMs) {
Handler handler = mLocalHandler.get();
if (handler != null) {
handler.obtainMessage(MSG_UPDATE_STATE, generationId, state).sendToTarget();
@@ -401,4 +403,33 @@ public class TransportControlView extends FrameLayout implements OnClickListener
return false;
}
+ private boolean wasPlayingRecently(int state, long stateChangeTimeMs) {
+ switch (state) {
+ case RemoteControlClient.PLAYSTATE_PLAYING:
+ case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
+ case RemoteControlClient.PLAYSTATE_REWINDING:
+ case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
+ case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
+ case RemoteControlClient.PLAYSTATE_BUFFERING:
+ // actively playing or about to play
+ return true;
+ case RemoteControlClient.PLAYSTATE_NONE:
+ return false;
+ case RemoteControlClient.PLAYSTATE_STOPPED:
+ case RemoteControlClient.PLAYSTATE_PAUSED:
+ case RemoteControlClient.PLAYSTATE_ERROR:
+ // we have stopped playing, check how long ago
+ if (DEBUG) {
+ if ((SystemClock.elapsedRealtime() - stateChangeTimeMs) < DISPLAY_TIMEOUT_MS) {
+ Log.v(TAG, "wasPlayingRecently: time < TIMEOUT was playing recently");
+ } else {
+ Log.v(TAG, "wasPlayingRecently: time > TIMEOUT");
+ }
+ }
+ return ((SystemClock.elapsedRealtime() - stateChangeTimeMs) < DISPLAY_TIMEOUT_MS);
+ default:
+ Log.e(TAG, "Unknown playback state " + state + " in wasPlayingRecently()");
+ return false;
+ }
+ }
}