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

Commit 395d1023 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Send the name of the device in the DeviceFound signal.

When name resolution is done, we get a DeviceFound signal.
Settings app was not updating the cache.
parent aba6af92
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -809,7 +809,16 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {
    }

    /* package */ synchronized void addRemoteDeviceProperties(String address, String[] properties) {
        Map<String, String> propertyValues = new HashMap<String, String>();
        /*
         * We get a DeviceFound signal every time RSSI changes or name changes.
         * Don't create a new Map object every time */
        Map<String, String> propertyValues = mRemoteDeviceProperties.get(address);
        if (propertyValues != null) {
            propertyValues.clear();
        } else {
            propertyValues = new HashMap<String, String>();
        }

        for (int i = 0; i < properties.length; i+=2) {
            String value = null;
            if (propertyValues.containsKey(properties[i])) {
+3 −1
Original line number Diff line number Diff line
@@ -130,12 +130,14 @@ class BluetoothEventLoop {
        mBluetoothService.addRemoteDeviceProperties(address, properties);
        String rssi = mBluetoothService.getRemoteDeviceProperty(address, "RSSI");
        String classValue = mBluetoothService.getRemoteDeviceProperty(address, "Class");
        String name = mBluetoothService.getRemoteDeviceProperty(address, "Name");

        if (rssi != null && classValue != null) {
            Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION);
            intent.putExtra(BluetoothIntent.ADDRESS, address);
            intent.putExtra(BluetoothIntent.CLASS, classValue);
            intent.putExtra(BluetoothIntent.CLASS, Integer.valueOf(classValue));
            intent.putExtra(BluetoothIntent.RSSI, (short)Integer.valueOf(rssi).intValue());
            intent.putExtra(BluetoothIntent.NAME, name);

            mContext.sendBroadcast(intent, BLUETOOTH_PERM);
        } else {