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

Skip to content
Commit 1078155c authored by Sal Savage's avatar Sal Savage
Browse files

Better protect staticly accessed resources to prevent exceptions

A2DP and AVRCP talk to each other a static function so AVRCP can know if
A2DP has proper audio focus before a play request is sent. This function
is only valid once A2DP has been started, yielding to an object thats
created on start(). The function makes no checks for the static service
reference OR the stream handler before use. This can lead to NPEs in
rare cases.

This change turn grabbing focus from an unsafe state function to a
member function, aligning it with other functions AVRCP uses. It also
makes it mockable in tests better. Functions now check for null values
before using them and have sensible defaults in the case something is
wrong. Start and stop are now synchronized so we can make assumptions
about the state of the stream handler.

Additionally, AVRCP controller has been changed to match the new method
of consuming getFocusState() and the surrounding logic has been updated.
Tests have been added and cleaned up to cover the entire block of code.

Bug: 152632246
Test: Build, flash, test with A2DP source devices, atest
Change-Id: Ic58dcc2bf1985c173465e245787d5567250a5577
Merged-In: Ic58dcc2bf1985c173465e245787d5567250a5577
parent f87ec185
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