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

Commit aec4ffb1 authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Added error code mapping to BT connectAudio/disconnectAudio logs." into main

parents 9367abfc 32054459
Loading
Loading
Loading
Loading
+35 −5
Original line number Diff line number Diff line
@@ -602,7 +602,8 @@ public class BluetoothDeviceManager {
            Log.w(this, "disconnectSco: Trying to disconnect audio but no headset service exists.");
        } else {
            result = mBluetoothHeadset.disconnectAudio();
            Log.i(this, "disconnectSco: BluetoothHeadset#disconnectAudio()=%b", result);
            Log.i(this, "disconnectSco: BluetoothHeadset#disconnectAudio()=%s",
                    btCodeToString(result));
        }
        return result;
    }
@@ -888,8 +889,8 @@ public class BluetoothDeviceManager {
            }
            if (getBluetoothHeadset() != null) {
                int scoConnectionRequest = mBluetoothHeadset.connectAudio();
                Log.i(this, "connectAudio: BluetoothHeadset#connectAudio()=%d",
                        scoConnectionRequest);
                Log.i(this, "connectAudio: BluetoothHeadset#connectAudio()=%s",
                        btCodeToString(scoConnectionRequest));
                return scoConnectionRequest == BluetoothStatusCodes.SUCCESS ||
                        scoConnectionRequest
                                == BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_CONNECTED;
@@ -944,8 +945,8 @@ public class BluetoothDeviceManager {
            }
            if (getBluetoothHeadset() != null) {
                int scoConnectionRequest = mBluetoothHeadset.connectAudio();
                Log.i(this, "connectAudio: BluetoothHeadset#connectAudio()=%d",
                        scoConnectionRequest);
                Log.i(this, "connectAudio: BluetoothHeadset#connectAudio()=%s",
                        btCodeToString(scoConnectionRequest));
                return scoConnectionRequest == BluetoothStatusCodes.SUCCESS ||
                        scoConnectionRequest
                                == BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_CONNECTED;
@@ -1015,4 +1016,33 @@ public class BluetoothDeviceManager {
    public void dump(IndentingPrintWriter pw) {
        mLocalLog.dump(pw);
    }

    private String btCodeToString(int code) {
        switch (code) {
            case BluetoothStatusCodes.SUCCESS:
                return "SUCCESS";
            case BluetoothStatusCodes.ERROR_UNKNOWN:
                return "ERROR_UNKNOWN";
            case BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND:
                return "ERROR_PROFILE_SERVICE_NOT_BOUND";
            case BluetoothStatusCodes.ERROR_TIMEOUT:
                return "ERROR_TIMEOUT";
            case BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_CONNECTED:
                return "ERROR_AUDIO_DEVICE_ALREADY_CONNECTED";
            case BluetoothStatusCodes.ERROR_NO_ACTIVE_DEVICES:
                return "ERROR_NO_ACTIVE_DEVICES";
            case BluetoothStatusCodes.ERROR_NOT_ACTIVE_DEVICE:
                return "ERROR_NOT_ACTIVE_DEVICE";
            case BluetoothStatusCodes.ERROR_AUDIO_ROUTE_BLOCKED:
                return "ERROR_AUDIO_ROUTE_BLOCKED";
            case BluetoothStatusCodes.ERROR_CALL_ACTIVE:
                return "ERROR_CALL_ACTIVE";
            case BluetoothStatusCodes.ERROR_PROFILE_NOT_CONNECTED:
                return "ERROR_PROFILE_NOT_CONNECTED";
            case BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_DISCONNECTED:
                return "BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_DISCONNECTED";
            default:
                return Integer.toString(code);
        }
    }
}