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

Commit 9448dc1c authored by Steve Kondik's avatar Steve Kondik
Browse files

bt: Fix NPE in BroadcastReceiver

java.lang.RuntimeException: Error receiving broadcast Intent {
act=android.bluetooth.device.action.CONNECTION_ACCESS_REPLY (has extras)
} in android.bluetooth.BluetoothDeviceProfileState$1@407e8ed0
	at
android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:722)
	at android.os.Handler.handleCallback(Handler.java:587)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:130)
	at com.android.server.ServerThread.run(SystemServer.java:630)
Caused by: java.lang.NullPointerException
	at
android.bluetooth.BluetoothDeviceProfileState$1.onReceive(BluetoothDeviceProfileState.java:119)
	at
android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:709)
	... 4 more

Change-Id: I3590f41040383a2fb0f54f305ac2e7fe526c2070
parent 862a19b7
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -116,7 +116,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
        public void onReceive(Context context, Intent intent) {
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            String action = intent.getAction();
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            if (!device.equals(mDevice)) return;
            if (device == null || !device.equals(mDevice)) return;


            if (action.equals(BluetoothHeadset.ACTION_STATE_CHANGED)) {
            if (action.equals(BluetoothHeadset.ACTION_STATE_CHANGED)) {
                int newState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, 0);
                int newState = intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, 0);