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
Loading
Please register or sign in to comment