Make PlaybackState immutable with a builder
bug:15862252 Change-Id: I51f2e466bd2c41bbe80d20aa9785126a7ac6ab3f
This commit is contained in:
@@ -682,9 +682,13 @@ public class RemoteControlClient
|
||||
// USE_SESSIONS
|
||||
if (mSession != null) {
|
||||
int pbState = PlaybackState.getStateFromRccState(state);
|
||||
mSessionPlaybackState.setState(pbState, hasPosition ?
|
||||
mPlaybackPositionMs : PlaybackState.PLAYBACK_POSITION_UNKNOWN,
|
||||
playbackSpeed);
|
||||
long position = hasPosition ? mPlaybackPositionMs
|
||||
: PlaybackState.PLAYBACK_POSITION_UNKNOWN;
|
||||
|
||||
PlaybackState.Builder bob = new PlaybackState.Builder(mSessionPlaybackState);
|
||||
bob.setState(pbState, position, playbackSpeed, SystemClock.elapsedRealtime());
|
||||
bob.setErrorMessage(null);
|
||||
mSessionPlaybackState = bob.build();
|
||||
mSession.setPlaybackState(mSessionPlaybackState);
|
||||
}
|
||||
}
|
||||
@@ -745,8 +749,9 @@ public class RemoteControlClient
|
||||
|
||||
// USE_SESSIONS
|
||||
if (mSession != null) {
|
||||
mSessionPlaybackState.setActions(PlaybackState
|
||||
.getActionsFromRccControlFlags(transportControlFlags));
|
||||
PlaybackState.Builder bob = new PlaybackState.Builder(mSessionPlaybackState);
|
||||
bob.setActions(PlaybackState.getActionsFromRccControlFlags(transportControlFlags));
|
||||
mSessionPlaybackState = bob.build();
|
||||
mSession.setPlaybackState(mSessionPlaybackState);
|
||||
}
|
||||
}
|
||||
@@ -946,7 +951,7 @@ public class RemoteControlClient
|
||||
/**
|
||||
* Cache for the current playback state using Session APIs.
|
||||
*/
|
||||
private final PlaybackState mSessionPlaybackState = new PlaybackState();
|
||||
private PlaybackState mSessionPlaybackState = null;
|
||||
|
||||
/**
|
||||
* Cache for metadata using Session APIs. This is re-initialized in apply().
|
||||
|
||||
Reference in New Issue
Block a user