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

Commit 71c5f5b3 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

VolumeControlService: Fix for possible crash

Could happen when profile is stopped while connecting.

Crash Messages sorted from most recent:
Attempt to invoke virtual method 'int com.android.bluetooth.btservice.AdapterService.getBondState(android.bluetooth.BluetoothDevice)' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.android.bluetooth.btservice.AdapterService.getBondState(android.bluetooth.BluetoothDevice)' on a null object reference
	at com.android.bluetooth.vc.VolumeControlService.okToConnect(VolumeControlService.java:293)
	at com.android.bluetooth.vc.VolumeControlStateMachine$Disconnected.processMessage(VolumeControlStateMachine.java:140

Bug: 206116821
Test: atest VolumeControlServiceTest
Change-Id: I0b8580e1f8e8e0b8e507cd1147b227880b4ee1d5
parent 65cf92cf
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -412,6 +412,11 @@ public class VolumeControlService extends ProfileService {
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    public boolean okToConnect(BluetoothDevice device) {
        /* Make sure device is valid */
        if (device == null) {
            Log.e(TAG, "okToConnect: Invalid device");
            return false;
        }
        // Check if this is an incoming connection in Quiet mode.
        if (mAdapterService.isQuietModeEnabled()) {
            Log.e(TAG, "okToConnect: cannot connect to " + device + " : quiet mode enabled");