am c91ad28f: Merge change 23218 into eclair

Merge commit 'c91ad28ff9173971c1d886f884250b1e774a40a6' into eclair-plus-aosp

* commit 'c91ad28ff9173971c1d886f884250b1e774a40a6':
  Fix property being cleared when DeviceFound signal is received.
This commit is contained in:
Jaikumar Ganesh
2009-08-31 16:54:37 -07:00
committed by Android Git Automerger
2 changed files with 24 additions and 19 deletions

View File

@@ -283,10 +283,12 @@ class BluetoothEventLoop {
String value = null; String value = null;
int len = Integer.valueOf(propValues[1]); int len = Integer.valueOf(propValues[1]);
if (len > 0) { if (len > 0) {
value = ""; StringBuilder str = new StringBuilder();
for (int i = 2; i < propValues.length; i++) { 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); mBluetoothService.setProperty(name, value);
} else if (name.equals("Powered")) { } else if (name.equals("Powered")) {
@@ -331,10 +333,12 @@ class BluetoothEventLoop {
String uuid = null; String uuid = null;
int len = Integer.valueOf(propValues[1]); int len = Integer.valueOf(propValues[1]);
if (len > 0) { if (len > 0) {
uuid = ""; StringBuilder str = new StringBuilder();
for (int i = 2; i < propValues.length; i++) { 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); mBluetoothService.setRemoteDeviceProperty(address, name, uuid);
} else if (name.equals("Paired")) { } else if (name.equals("Paired")) {

View File

@@ -551,20 +551,21 @@ public class BluetoothService extends IBluetooth.Stub {
for (int i = 0; i < properties.length; i++) { for (int i = 0; i < properties.length; i++) {
String name = properties[i]; String name = properties[i];
String newValue; String newValue = null;
int len; int len;
if (name == null) { if (name == null) {
Log.e(TAG, "Error:Adapter Property at index" + i + "is null"); Log.e(TAG, "Error:Adapter Property at index" + i + "is null");
continue; continue;
} }
if (name.equals("Devices")) { if (name.equals("Devices")) {
StringBuilder str = new StringBuilder();
len = Integer.valueOf(properties[++i]); len = Integer.valueOf(properties[++i]);
if (len != 0)
newValue = "";
else
newValue = null;
for (int j = 0; j < len; j++) { for (int j = 0; j < len; j++) {
newValue += properties[++i] + ","; str.append(properties[++i]);
str.append(",");
}
if (len > 0) {
newValue = str.toString();
} }
} else { } else {
newValue = properties[++i]; 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. * We get a DeviceFound signal every time RSSI changes or name changes.
* Don't create a new Map object every time */ * Don't create a new Map object every time */
Map<String, String> propertyValues = mDeviceProperties.get(address); Map<String, String> propertyValues = mDeviceProperties.get(address);
if (propertyValues != null) { if (propertyValues == null) {
propertyValues.clear();
} else {
propertyValues = new HashMap<String, String>(); propertyValues = new HashMap<String, String>();
} }
for (int i = 0; i < properties.length; i++) { for (int i = 0; i < properties.length; i++) {
String name = properties[i]; String name = properties[i];
String newValue; String newValue = null;
int len; int len;
if (name == null) { if (name == null) {
Log.e(TAG, "Error: Remote Device Property at index" + i + "is null"); Log.e(TAG, "Error: Remote Device Property at index" + i + "is null");
continue; continue;
} }
if (name.equals("UUIDs") || name.equals("Nodes")) { if (name.equals("UUIDs") || name.equals("Nodes")) {
StringBuilder str = new StringBuilder();
len = Integer.valueOf(properties[++i]); len = Integer.valueOf(properties[++i]);
if (len != 0)
newValue = "";
else
newValue = null;
for (int j = 0; j < len; j++) { for (int j = 0; j < len; j++) {
newValue += properties[++i] + ","; str.append(properties[++i]);
str.append(",");
}
if (len > 0) {
newValue = str.toString();
} }
} else { } else {
newValue = properties[++i]; newValue = properties[++i];
} }
propertyValues.put(name, newValue); propertyValues.put(name, newValue);
} }
mDeviceProperties.put(address, propertyValues); mDeviceProperties.put(address, propertyValues);