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

Skip to content
Commit e90e3d92 authored by Jakub Tyszkowski's avatar Jakub Tyszkowski Committed by Jakub Pawlowski
Browse files

mcp: Fix possible null pointer exception

There is a tiny time gap between the MediaControlProfile construction
and the asynchronous init() method call, in which the ListCallback
methods can be called. In such case and exception is thrown.
This change moves the callback registration from the constructor
to the init() routine, right after the member variable initialisation,
to guarantee it being not-null on the first callback call.

Fixes the following exception:
  java.lang.NullPointerException: Attempt to read from field
  'com.android.bluetooth.audio_util.Metadata
  com.android.bluetooth.audio_util.MediaData.metadata' on a
  null object reference at
  com.android.bluetooth.mcp.MediaControlProfile$ListCallback.run(MediaControlProfile.java:82)

Test: atest MediaControlProfileTest
Sponsor: jpawlowski@
Bug: 150670922
Bug: 199499736
Change-Id: Ie8946701b49d6540bbba3d8edad6eb24269263cc
parent fa699f0b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment