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

Commit 24ec1ee1 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun Committed by Gerrit Code Review
Browse files

Merge "Don't use getCurrentState() in BatteryStateMachine" into main

parents 7928d21e 15cd1a81
Loading
Loading
Loading
Loading
+2 −12
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ public class BatteryStateMachine extends StateMachine {
    }

    synchronized boolean isConnected() {
        return getCurrentState() == mConnected;
        return mLastConnectionState == BluetoothProfile.STATE_CONNECTED;
    }

    private static String messageWhatToString(int what) {
@@ -153,17 +153,7 @@ public class BatteryStateMachine extends StateMachine {

    @BluetoothProfile.BtProfileState
    int getConnectionState() {
        String currentState = getCurrentState().getName();
        return switch (currentState) {
            case "Disconnected" -> BluetoothProfile.STATE_DISCONNECTED;
            case "Connecting" -> BluetoothProfile.STATE_CONNECTING;
            case "Connected" -> BluetoothProfile.STATE_CONNECTED;
            case "Disconnecting" -> BluetoothProfile.STATE_DISCONNECTING;
            default -> {
                Log.e(TAG, "Bad currentState: " + currentState);
                yield BluetoothProfile.STATE_DISCONNECTED;
            }
        };
        return mLastConnectionState;
    }

    void dispatchConnectionStateChanged(int toState) {