diff options
author | RoboErik <epastern@google.com> | 2014-05-27 16:49:09 -0700 |
---|---|---|
committer | RoboErik <epastern@google.com> | 2014-05-29 11:28:48 -0700 |
commit | 79fa4630bbca7c6c251eea99fe8997e4b45becee (patch) | |
tree | c65f1dafd3657cb016eb7fc0ebf78a46eb3a1393 /services | |
parent | eb61eb786af1db1f1cf6c988d78d1ddc3acb4a16 (diff) | |
download | frameworks_base-79fa4630bbca7c6c251eea99fe8997e4b45becee.zip frameworks_base-79fa4630bbca7c6c251eea99fe8997e4b45becee.tar.gz frameworks_base-79fa4630bbca7c6c251eea99fe8997e4b45becee.tar.bz2 |
API changes to sessions
Changes requested by API Council review. A second CL will refactor
TransportController and TransportPerformer based on feedback.
Change-Id: Ie26a7d01d7021232a66c2edf1eb58120437fdfde
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/media/MediaSessionRecord.java | 36 | ||||
-rw-r--r-- | services/core/java/com/android/server/media/MediaSessionStack.java | 14 |
2 files changed, 26 insertions, 24 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java index 030e3ed..c909a54 100644 --- a/services/core/java/com/android/server/media/MediaSessionRecord.java +++ b/services/core/java/com/android/server/media/MediaSessionRecord.java @@ -66,13 +66,13 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { * These are the playback states that count as currently active. */ private static final int[] ACTIVE_STATES = { - PlaybackState.PLAYSTATE_FAST_FORWARDING, - PlaybackState.PLAYSTATE_REWINDING, - PlaybackState.PLAYSTATE_SKIPPING_BACKWARDS, - PlaybackState.PLAYSTATE_SKIPPING_FORWARDS, - PlaybackState.PLAYSTATE_BUFFERING, - PlaybackState.PLAYSTATE_CONNECTING, - PlaybackState.PLAYSTATE_PLAYING }; + PlaybackState.STATE_FAST_FORWARDING, + PlaybackState.STATE_REWINDING, + PlaybackState.STATE_SKIPPING_TO_PREVIOUS, + PlaybackState.STATE_SKIPPING_TO_NEXT, + PlaybackState.STATE_BUFFERING, + PlaybackState.STATE_CONNECTING, + PlaybackState.STATE_PLAYING }; /** * The length of time a session will still be considered active after @@ -301,7 +301,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { if (isActiveState(state)) { return true; } - if (state == mPlaybackState.PLAYSTATE_PAUSED) { + if (state == mPlaybackState.STATE_PAUSED) { long inactiveTime = SystemClock.uptimeMillis() - mLastActiveTime; if (inactiveTime < ACTIVE_BUFFER) { return true; @@ -509,12 +509,12 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { } PlaybackState result = null; if (state != null) { - if (state.getState() == PlaybackState.PLAYSTATE_PLAYING - || state.getState() == PlaybackState.PLAYSTATE_FAST_FORWARDING - || state.getState() == PlaybackState.PLAYSTATE_REWINDING) { + if (state.getState() == PlaybackState.STATE_PLAYING + || state.getState() == PlaybackState.STATE_FAST_FORWARDING + || state.getState() == PlaybackState.STATE_REWINDING) { long updateTime = state.getLastPositionUpdateTime(); if (updateTime > 0) { - long position = (long) (state.getRate() + long position = (long) (state.getPlaybackRate() * (SystemClock.elapsedRealtime() - updateTime)) + state.getPosition(); if (duration >= 0 && position > duration) { position = duration; @@ -522,7 +522,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { position = 0; } result = new PlaybackState(state); - result.setState(state.getState(), position, state.getRate()); + result.setState(state.getState(), position, state.getPlaybackRate()); } } } @@ -588,7 +588,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { public void setPlaybackState(PlaybackState state) { int oldState = mPlaybackState == null ? 0 : mPlaybackState.getState(); int newState = state == null ? 0 : state.getState(); - if (isActiveState(oldState) && newState == PlaybackState.PLAYSTATE_PAUSED) { + if (isActiveState(oldState) && newState == PlaybackState.STATE_PAUSED) { mLastActiveTime = SystemClock.elapsedRealtime(); } mPlaybackState = state; @@ -649,14 +649,16 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { mCb = cb; } - public void sendMediaButton(KeyEvent keyEvent, int sequenceId, ResultReceiver cb) { + public boolean sendMediaButton(KeyEvent keyEvent, int sequenceId, ResultReceiver cb) { Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent); try { mCb.onMediaButton(mediaButtonIntent, sequenceId, cb); + return true; } catch (RemoteException e) { Slog.e(TAG, "Remote failure in sendMediaRequest.", e); } + return false; } public void sendCommand(String command, Bundle extras, ResultReceiver cb) { @@ -788,8 +790,8 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { } @Override - public void sendMediaButton(KeyEvent mediaButtonIntent) { - mSessionCb.sendMediaButton(mediaButtonIntent, 0, null); + public boolean sendMediaButton(KeyEvent mediaButtonIntent) { + return mSessionCb.sendMediaButton(mediaButtonIntent, 0, null); } @Override diff --git a/services/core/java/com/android/server/media/MediaSessionStack.java b/services/core/java/com/android/server/media/MediaSessionStack.java index 7ba9212..56236f8 100644 --- a/services/core/java/com/android/server/media/MediaSessionStack.java +++ b/services/core/java/com/android/server/media/MediaSessionStack.java @@ -33,18 +33,18 @@ public class MediaSessionStack { * bump priority regardless of the old state. */ private static final int[] ALWAYS_PRIORITY_STATES = { - PlaybackState.PLAYSTATE_FAST_FORWARDING, - PlaybackState.PLAYSTATE_REWINDING, - PlaybackState.PLAYSTATE_SKIPPING_BACKWARDS, - PlaybackState.PLAYSTATE_SKIPPING_FORWARDS }; + PlaybackState.STATE_FAST_FORWARDING, + PlaybackState.STATE_REWINDING, + PlaybackState.STATE_SKIPPING_TO_PREVIOUS, + PlaybackState.STATE_SKIPPING_TO_NEXT }; /** * These are states that usually indicate the user took an action if they * were entered from a non-priority state. */ private static final int[] TRANSITION_PRIORITY_STATES = { - PlaybackState.PLAYSTATE_BUFFERING, - PlaybackState.PLAYSTATE_CONNECTING, - PlaybackState.PLAYSTATE_PLAYING }; + PlaybackState.STATE_BUFFERING, + PlaybackState.STATE_CONNECTING, + PlaybackState.STATE_PLAYING }; private final ArrayList<MediaSessionRecord> mSessions = new ArrayList<MediaSessionRecord>(); |