Fix null pointer exception on AvrcpTargetService
This fixes null pointer exception by simply adding null pointer checker.
Problem occurs when sendMediaUpdate() is called just after Avrcp
Service is stop()ed.
Error Message: java.lang.NullPointerException: Attempt to invoke virtual method ’void com.android.bluetooth.avrcp.AvrcpNativeInterface.sendMediaUpdate(boolean, boolean, boolean)’ on a null object reference
Test: Once issue
Change-Id: Id42e48faa28ce6c1ec6d4148705d3342261aa6ca
Signed-off-by: slki.shin <slki.shin@samsung.com>
diff --git a/src/com/android/bluetooth/avrcp/AvrcpTargetService.java b/src/com/android/bluetooth/avrcp/AvrcpTargetService.java
index bdc930b..f11622f 100644
--- a/src/com/android/bluetooth/avrcp/AvrcpTargetService.java
+++ b/src/com/android/bluetooth/avrcp/AvrcpTargetService.java
@@ -70,6 +70,8 @@
MediaPlayerList.FolderUpdateCallback {
@Override
public void run(MediaData data) {
+ if (mNativeInterface == null) return;
+
boolean metadata = !Objects.equals(mCurrentData.metadata, data.metadata);
boolean state = !MediaPlayerWrapper.playstateEquals(mCurrentData.state, data.state);
boolean queue = !Objects.equals(mCurrentData.queue, data.queue);
@@ -86,6 +88,8 @@
@Override
public void run(boolean availablePlayers, boolean addressedPlayers,
boolean uids) {
+ if (mNativeInterface == null) return;
+
mNativeInterface.sendFolderUpdate(availablePlayers, addressedPlayers, uids);
}
}