Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8eeccc2a authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

mcp: Fix possible nullpointer dereference

Could happen when Gatt service is not created.
Can happen in unitests

Bug: 150670922
Tag: #feature
Test: atest BluetoothInstrumentationTests
Sponsor: jpawlowski@
Change-Id: I205369a2153df2de8eef40af3e5119896060f9f6
parent 968184db
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -187,8 +187,10 @@ public class MediaControlProfile implements MediaControlServiceCallbacks {
        // If any of these were previously requested, just clean-up the requests
        removePendingStateRequests(state_map.keySet());

        if (mGMcsService != null) {
            mGMcsService.updatePlayerState(state_map);
        }
    }

    private void removePendingStateRequests(Set<PlayerStateField> fields) {
        if (mPendingStateRequest == null) return;
@@ -288,9 +290,11 @@ public class MediaControlProfile implements MediaControlServiceCallbacks {
            Map<PlayerStateField, Object> state_map = new HashMap<>();
            state_map.put(PlayerStateField.TRACK_POSITION, getLatestTrackPosition());

            if (mGMcsService != null) {
              mGMcsService.updatePlayerState(state_map);
            }
        }
    }

    @Override
    public void onCurrentTrackMetadataRequest() {
@@ -578,8 +582,10 @@ public class MediaControlProfile implements MediaControlServiceCallbacks {

        if (!handled_request_map.isEmpty()) {
            removePendingStateRequests(handled_request_map.keySet());
            if (mGMcsService != null) {
              mGMcsService.updatePlayerState(handled_request_map);
            }
        }

        if (DBG) {
            if (mPendingStateRequest != null && !mPendingStateRequest.isEmpty()) {