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

Commit 088a61fb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Audio: Check if BluetoothDevice.getName() returns null"

parents 099d3ae0 cb49964b
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ public final class AudioDeviceInventory {
                    mDeviceBroker.setDeviceVolume(
                            streamState, AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
                }
                makeA2dpDeviceAvailable(address, btDevice.getName(),
                makeA2dpDeviceAvailable(address, BtHelper.getName(btDevice),
                        "onSetA2dpSinkConnectionState", a2dpCodec);
            }
        }
@@ -257,7 +257,7 @@ public final class AudioDeviceInventory {
            if (isConnected && state != BluetoothProfile.STATE_CONNECTED) {
                makeHearingAidDeviceUnavailable(address);
            } else if (!isConnected && state == BluetoothProfile.STATE_CONNECTED) {
                makeHearingAidDeviceAvailable(address, btDevice.getName(),
                makeHearingAidDeviceAvailable(address, BtHelper.getName(btDevice),
                        "onSetHearingAidConnectionState");
            }
        }
@@ -318,7 +318,7 @@ public final class AudioDeviceInventory {
                }
            }
            if (AudioSystem.handleDeviceConfigChange(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address,
                    btDevice.getName(), a2dpCodec) != AudioSystem.AUDIO_STATUS_OK) {
                    BtHelper.getName(btDevice), a2dpCodec) != AudioSystem.AUDIO_STATUS_OK) {
                int musicDevice = mDeviceBroker.getDeviceForStream(AudioSystem.STREAM_MUSIC);
                // force A2DP device disconnection in case of error so that AudioService state is
                // consistent with audio policy manager state
@@ -603,10 +603,9 @@ public final class AudioDeviceInventory {
                }
                // A2DP device exists, handle active device change
                final String existingDevicekey = mConnectedDevices.keyAt(i);
                final String deviceName = device.getName();
                mConnectedDevices.remove(existingDevicekey);
                mConnectedDevices.put(deviceKey, new DeviceInfo(
                        AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, deviceName,
                        AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, BtHelper.getName(device),
                        address, a2dpCodec));
                mDeviceBroker.postA2dpActiveDeviceChange(
                        new BtHelper.BluetoothA2dpDeviceInfo(
+9 −1
Original line number Diff line number Diff line
@@ -152,6 +152,14 @@ public class BtHelper {
        }
    }

    /*package*/ @NonNull static String getName(@NonNull BluetoothDevice device) {
        final String deviceName = device.getName();
        if (deviceName == null) {
            return "";
        }
        return deviceName;
    }

    //----------------------------------------------------------------------
    // Interface for AudioDeviceBroker

@@ -515,7 +523,7 @@ public class BtHelper {
        if (!BluetoothAdapter.checkBluetoothAddress(address)) {
            address = "";
        }
        String btDeviceName =  btDevice.getName();
        String btDeviceName =  getName(btDevice);
        boolean result = false;
        if (isActive) {
            result |= mDeviceBroker.handleDeviceConnection(