BondStateMachine: Fix BluetoothClass being null

Bug: 298149530
Test: atest BondStateMachineTest | This happen as a race condition
      during stack shutdown and cannot be easily test. Fix is trivial
Change-Id: I41e82064a5cca1639fdf57696745ad4e53d50877
diff --git a/android/app/src/com/android/bluetooth/btservice/BondStateMachine.java b/android/app/src/com/android/bluetooth/btservice/BondStateMachine.java
index 75433b2..d565a9c 100644
--- a/android/app/src/com/android/bluetooth/btservice/BondStateMachine.java
+++ b/android/app/src/com/android/bluetooth/btservice/BondStateMachine.java
@@ -273,9 +273,10 @@
                     }
 
                     BluetoothClass btClass = dev.getBluetoothClass();
-                    int btDeviceClass = btClass.getDeviceClass();
-                    if (btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD || btDeviceClass
-                            == BluetoothClass.Device.PERIPHERAL_KEYBOARD_POINTING) {
+                    int btDeviceClass = btClass == null ? 0 : btClass.getDeviceClass();
+                    if (btDeviceClass == BluetoothClass.Device.PERIPHERAL_KEYBOARD
+                            || btDeviceClass
+                                    == BluetoothClass.Device.PERIPHERAL_KEYBOARD_POINTING) {
                         // Its a keyboard. Follow the HID spec recommendation of creating the
                         // passkey and displaying it to the user. If the keyboard doesn't follow
                         // the spec recommendation, check if the keyboard has a fixed PIN zero