Fix volume change nullpointer exception in AvrcpTargetService when configured as A2DP sink

When configured as an A2DP sink (i.e. A2dpService disabled, A2dpSinkService enabled),
media plays without issue, but sending a volume change command to device results in
a crash and BT disconnect, root-caused to a nullpointer exception in
AvrcpTargetService.java

Error message from bugreport:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothDevice com.android.bluetooth.a2dp.A2dpService.getActiveDevice()' on a null object reference

Bug: 148421135
Test: In overlay/packages/apps/Bluetooth/res/values/config.xml:
 - Set profile_supported_a2dp to false
 - Set profile_supported_a2dp_sink to true
 - Set profile_supported_avrcp_target to true

Build/flash device, then connect to device, play media and change volume level.

Verified that after fix, BT service does not crash, volume changes work as expected.

Change-Id: I2f2b57d23b81b1d8a2e72dc0b7e087b2d5bd477a
1 file changed