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

Commit efa33676 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Fix property being cleared when DeviceFound signal is received.

parent 25b9cec8
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -283,10 +283,12 @@ class BluetoothEventLoop {
            String value = null;
            int len = Integer.valueOf(propValues[1]);
            if (len > 0) {
                value = "";
                StringBuilder str = new StringBuilder();
                for (int i = 2; i < propValues.length; i++) {
                    value = value + propValues[i] + ',';
                    str.append(propValues[i]);
                    str.append(",");
                }
                value = str.toString();
            }
            mBluetoothService.setProperty(name, value);
        } else if (name.equals("Powered")) {
@@ -331,10 +333,12 @@ class BluetoothEventLoop {
            String uuid = null;
            int len = Integer.valueOf(propValues[1]);
            if (len > 0) {
                uuid = "";
                StringBuilder str = new StringBuilder();
                for (int i = 2; i < propValues.length; i++) {
                    uuid = uuid + propValues[i] + ",";
                    str.append(propValues[i]);
                    str.append(",");
                }
                uuid = str.toString();
            }
            mBluetoothService.setRemoteDeviceProperty(address, name, uuid);
        } else if (name.equals("Paired")) {
+16 −15
Original line number Diff line number Diff line
@@ -551,20 +551,21 @@ public class BluetoothService extends IBluetooth.Stub {

        for (int i = 0; i < properties.length; i++) {
            String name = properties[i];
            String newValue;
            String newValue = null;
            int len;
            if (name == null) {
                Log.e(TAG, "Error:Adapter Property at index" + i + "is null");
                continue;
            }
            if (name.equals("Devices")) {
                StringBuilder str = new StringBuilder();
                len = Integer.valueOf(properties[++i]);
                if (len != 0)
                    newValue = "";
                else
                    newValue = null;
                for (int j = 0; j < len; j++) {
                    newValue += properties[++i] + ",";
                    str.append(properties[++i]);
                    str.append(",");
                }
                if (len > 0) {
                    newValue = str.toString();
                }
            } else {
                newValue = properties[++i];
@@ -837,32 +838,32 @@ public class BluetoothService extends IBluetooth.Stub {
         * 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 = mDeviceProperties.get(address);
        if (propertyValues != null) {
            propertyValues.clear();
        } else {
        if (propertyValues == null) {
            propertyValues = new HashMap<String, String>();
        }

        for (int i = 0; i < properties.length; i++) {
            String name = properties[i];
            String newValue;
            String newValue = null;
            int len;
            if (name == null) {
                Log.e(TAG, "Error: Remote Device Property at index" + i + "is null");
                continue;
            }
            if (name.equals("UUIDs") || name.equals("Nodes")) {
                StringBuilder str = new StringBuilder();
                len = Integer.valueOf(properties[++i]);
                if (len != 0)
                    newValue = "";
                else
                    newValue = null;
                for (int j = 0; j < len; j++) {
                    newValue += properties[++i] + ",";
                    str.append(properties[++i]);
                    str.append(",");
                }
                if (len > 0) {
                    newValue = str.toString();
                }
            } else {
                newValue = properties[++i];
            }

            propertyValues.put(name, newValue);
        }
        mDeviceProperties.put(address, propertyValues);