summaryrefslogtreecommitdiffstats
path: root/core/java/android/server/BluetoothEventLoop.java
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2009-06-24 16:42:51 -0700
committerJaikumar Ganesh <jaikumar@google.com>2009-06-29 11:41:19 -0700
commit8bc8ce44f7e5a720e7b989bdd63bb33da512103b (patch)
treebb35a2276936b4bf48888a3e30b1cdcec0b3b948 /core/java/android/server/BluetoothEventLoop.java
parentafed82bca9e173cabe2c2f25314b202e5c1ccbca (diff)
downloadframeworks_base-8bc8ce44f7e5a720e7b989bdd63bb33da512103b.zip
frameworks_base-8bc8ce44f7e5a720e7b989bdd63bb33da512103b.tar.gz
frameworks_base-8bc8ce44f7e5a720e7b989bdd63bb33da512103b.tar.bz2
Rework the property parsing code.
1. Fix and remove CodeDuplication TODO 2. Fix crash while unpairing. 3. For array properties, make it a bit more efficient by passing, lesser String objects from JNI. 4. Remove void pointer usage and use union to make code more readble.
Diffstat (limited to 'core/java/android/server/BluetoothEventLoop.java')
-rw-r--r--core/java/android/server/BluetoothEventLoop.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index ed66dce..38eb4d7 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -260,11 +260,15 @@ class BluetoothEventLoop {
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
mBluetoothService.setProperty(name, propValues[1]);
} else if (name.equals("Devices")) {
- String value = "";
- for (int i = 1; i < propValues.length; i++) {
- value = value + propValues[i] + ',';
+ String value = null;
+ int len = Integer.valueOf(propValues[1]);
+ if (len > 0) {
+ value = "";
+ for (int i = 2; i < propValues.length; i++) {
+ value = value + propValues[i] + ',';
+ }
}
- mBluetoothService.setProperty(name, value.equals("") ? null : value);
+ mBluetoothService.setProperty(name, value);
} else if (name.equals("Powered")) {
// bluetoothd has restarted, re-read all our properties.
// Note: bluez only sends this property change when it restarts.
@@ -303,12 +307,15 @@ class BluetoothEventLoop {
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]);
} else if (name.equals("UUIDs")) {
- String uuid = "" ;
- for (int i = 1; i < propValues.length; i++) {
- uuid = uuid + propValues[i] + ",";
+ String uuid = null;
+ int len = Integer.valueOf(propValues[1]);
+ if (len > 0) {
+ uuid = "";
+ for (int i = 2; i < propValues.length; i++) {
+ uuid = uuid + propValues[i] + ",";
+ }
}
- mBluetoothService.setRemoteDeviceProperty(address, name,
- uuid.equals("") ? null : uuid);
+ mBluetoothService.setRemoteDeviceProperty(address, name, uuid);
}
}