AVRCP: added null check before calling getPlaybackState().getState()
Added check if getPlayback state is null in updateCurrentMediaState
function
CRs-Fixed: 2623767
Change-Id: I4d223a84ead1e0d2dafe0a4bf2c4eeb33637ebbe
diff --git a/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java b/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
index 7c556bb..e66b164 100644
--- a/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
+++ b/packages_apps_bluetooth_ext/src/avrcp/Avrcp_ext.java
@@ -2243,16 +2243,14 @@
Log.v(TAG,"updateCurrentMediaState: isPlaying = " + isPlaying);
// Use A2DP state if we don't have a MediaControlller
PlaybackState.Builder builder = new PlaybackState.Builder();
- if (mMediaController == null || mMediaController.getPlaybackState() == null) {
- Log.v(TAG,"updateCurrentMediaState: mMediaController or getPlaybackState() null");
- if (isPlaying) {
- builder.setState(PlaybackState.STATE_PLAYING,
- PlaybackState.PLAYBACK_POSITION_UNKNOWN, 1.0f);
- } else {
- builder.setState(PlaybackState.STATE_PAUSED,
- PlaybackState.PLAYBACK_POSITION_UNKNOWN, 0.0f);
- }
+ if (isPlaying) {
+ builder.setState(PlaybackState.STATE_PLAYING,
+ PlaybackState.PLAYBACK_POSITION_UNKNOWN, 1.0f);
} else {
+ builder.setState(PlaybackState.STATE_PAUSED,
+ PlaybackState.PLAYBACK_POSITION_UNKNOWN, 0.0f);
+ }
+ if (mMediaController != null && mMediaController.getPlaybackState() != null) {
int mMediaPlayState = mMediaController.getPlaybackState().getState();
if (isPlaying) {
builder.setState(PlaybackState.STATE_PLAYING,