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

Commit 8f2c782c authored by Sal Savage's avatar Sal Savage
Browse files

Use profile names instead of integer constants when logging

It is far more understandable in logs to see profile=A2DP_SINK instead
of profile=11. This change updates a few spots we use profile IDs in
logs messages to instead use the result of getProfileName. Many other
places in code have been udpated to do this already.

Tag: #refactor
Bug: 282988270
Test: atest BluetoothInstrumentationTests
Change-Id: If47c46413f0f2567643561ec267ac09f86ef3aab
parent fec3d3ff
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -729,16 +729,16 @@ class AdapterProperties {
                    metricId, device.getName());
            MetricsLogger.getInstance().logSanitizedBluetoothDeviceName(metricId, device.getName());
        }
        Log.d(TAG,
                "PROFILE_CONNECTION_STATE_CHANGE: profile=" + profile + ", device=" + device + ", "
        Log.d(TAG, "PROFILE_CONNECTION_STATE_CHANGE: profile="
                + BluetoothProfile.getProfileName(profile) + ", device=" + device + ", "
                + prevState + " -> " + state);
        BluetoothStatsLog.write(BluetoothStatsLog.BLUETOOTH_CONNECTION_STATE_CHANGED, state,
                0 /* deprecated */, profile, mService.obfuscateAddress(device),
                metricId, 0, -1);

        if (!isNormalStateTransition(prevState, state)) {
            Log.w(TAG,
                    "PROFILE_CONNECTION_STATE_CHANGE: unexpected transition for profile=" + profile
            Log.w(TAG, "PROFILE_CONNECTION_STATE_CHANGE: unexpected transition for profile="
                    + BluetoothProfile.getProfileName(profile)
                    + ", device=" + device + ", " + prevState + " -> " + state);
        }
        sendConnectionStateChange(device, profile, state, prevState);
+6 −4
Original line number Diff line number Diff line
@@ -506,8 +506,9 @@ class PhonePolicy {
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)
    private void processProfileStateChanged(BluetoothDevice device, int profileId, int nextState,
            int prevState) {
        debugLog("processProfileStateChanged, device=" + device + ", profile=" + profileId + ", "
                + prevState + " -> " + nextState);
        debugLog("processProfileStateChanged, device=" + device + ", profile="
                + BluetoothProfile.getProfileName(profileId) + ", " + prevState + " -> "
                + nextState);
        if (((profileId == BluetoothProfile.A2DP) || (profileId == BluetoothProfile.HEADSET)
                || (profileId == BluetoothProfile.LE_AUDIO)
                || (profileId == BluetoothProfile.CSIP_SET_COORDINATOR)
@@ -544,8 +545,9 @@ class PhonePolicy {
     * @param device is the device we just made the active device
     */
    private void processActiveDeviceChanged(BluetoothDevice device, int profileId) {
        debugLog("processActiveDeviceChanged, device=" + device + ", profile=" + profileId
                + " isDualModeAudioEnabled=" + isDualModeAudioEnabled());
        debugLog("processActiveDeviceChanged, device=" + device + ", profile="
                + BluetoothProfile.getProfileName(profileId) + " isDualModeAudioEnabled="
                + isDualModeAudioEnabled());

        if (device != null) {
            mDatabaseManager.setConnection(device, profileId == BluetoothProfile.A2DP);
+4 −2
Original line number Diff line number Diff line
@@ -300,7 +300,8 @@ public class SilenceDeviceManager {

    void addConnectedDevice(BluetoothDevice device, int profile) {
        if (VERBOSE) {
            Log.d(TAG, "addConnectedDevice: " + device + ", profile:" + profile);
            Log.d(TAG, "addConnectedDevice: " + device + ", profile:"
                    + BluetoothProfile.getProfileName(profile));
        }
        switch (profile) {
            case BluetoothProfile.A2DP:
@@ -318,7 +319,8 @@ public class SilenceDeviceManager {

    void removeConnectedDevice(BluetoothDevice device, int profile) {
        if (VERBOSE) {
            Log.d(TAG, "removeConnectedDevice: " + device + ", profile:" + profile);
            Log.d(TAG, "removeConnectedDevice: " + device + ", profile:"
                    + BluetoothProfile.getProfileName(profile));
        }
        switch (profile) {
            case BluetoothProfile.A2DP: