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

Commit 4ca9d2a8 authored by William Escande's avatar William Escande
Browse files

Prevent to setActiveDevice when not ON

Calling setActiveDevice while in BLE_ON state can generate
nullpointerException

Bug: 328840703
Fix: 328840703
Test: m Bluetooth
Flag: Exempt, simple state check
Change-Id: Icaf1daadd98e20acedcfd57235c1987eb81ecf05
parent fbb32512
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -5091,6 +5091,10 @@ public class AdapterService extends Service {
                android.Manifest.permission.MODIFY_PHONE_STATE,
            })
    public boolean setActiveDevice(BluetoothDevice device, @ActiveDeviceUse int profiles) {
        if (getState() != BluetoothAdapter.STATE_ON) {
            Log.e(TAG, "setActiveDevice: Bluetooth is not enabled");
            return false;
        }
        boolean setA2dp = false;
        boolean setHeadset = false;