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

Commit 1d5da504 authored by William Escande's avatar William Escande
Browse files

Simplify StateChangeHandler

Bug: 262605980
Test: None  | no-op
Change-Id: Ie08c7b479fcb5ad63dde0a8becabe7a9dcd9cd68
parent f8f1c8af
Loading
Loading
Loading
Loading
+20 −31
Original line number Diff line number Diff line
@@ -2563,9 +2563,8 @@ class BluetoothManagerService {
            }
            sendBluetoothServiceDownCallback();
            unbindAndFinish();
        } else if (newState == STATE_BLE_ON) {
            if (prevState != STATE_TURNING_OFF) {
            // connect to GattService
        } else if (newState == STATE_BLE_ON && prevState == STATE_BLE_TURNING_ON) {
            if (DBG) {
                Log.d(TAG, "Bluetooth is in LE only mode");
            }
@@ -2577,27 +2576,13 @@ class BluetoothManagerService {
                if (DBG) {
                    Log.d(TAG, "Binding Bluetooth GATT service");
                }
                    Intent i = new Intent(IBluetoothGatt.class.getName());
                doBind(
                            i,
                        new Intent(IBluetoothGatt.class.getName()),
                        mConnection,
                        Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT,
                        UserHandle.CURRENT);
            }
            } else {
                if (DBG) {
                    Log.d(TAG, " Back to LE only mode");
                }
                // For LE only mode, broadcast as is
                sendBluetoothStateCallback(false); // BT is OFF for general users
                // Broadcast as STATE_OFF
                sendBrEdrDownCallback(mContext.getAttributionSource());
            }
        } else if (newState == STATE_BLE_TURNING_OFF) {
            if (prevState == STATE_TURNING_OFF) {
                sendBrEdrDownCallback(mContext.getAttributionSource());
            }
        } // Nothing specific to do for STATE_TURNING_ON | STATE_TURNING_OFF | STATE_BLE_TURNING_ON
        } // Nothing specific to do for STATE_TURNING_<X>

        broadcastIntentStateChange(BluetoothAdapter.ACTION_BLE_STATE_CHANGED, prevState, newState);

@@ -2606,6 +2591,10 @@ class BluetoothManagerService {
        final int newBrEdrState = isBleState(newState) ? STATE_OFF : newState;

        if (prevBrEdrState != newBrEdrState) { // Only broadcast when there is a BrEdr state change.
            if (newBrEdrState == STATE_OFF) {
                sendBluetoothStateCallback(false);
                sendBrEdrDownCallback(mContext.getAttributionSource());
            }
            broadcastIntentStateChange(
                    BluetoothAdapter.ACTION_STATE_CHANGED, prevBrEdrState, newBrEdrState);
        }