OSDN Git Service

Added code to ignore the empty value of remote device property change
authorzzy <zhenye@broadcom.com>
Tue, 26 Jun 2012 22:01:20 +0000 (15:01 -0700)
committerMatthew Xie <mattx@google.com>
Wed, 25 Jul 2012 08:29:44 +0000 (01:29 -0700)
Change-Id: I0d6b293c0bf35d9b4a2df00e9b3cd810c4a9b251

src/com/android/bluetooth/btservice/RemoteDevices.java

index 8ba2b1c..fb767bd 100755 (executable)
@@ -236,48 +236,52 @@ final class RemoteDevices {
         for (int j = 0; j < types.length; j++) {
             type = types[j];
             val = values[j];
-            synchronized(mObject) {
-                switch (type) {
-                    case AbstractionLayer.BT_PROPERTY_BDNAME:
-                        device.mName = new String(val);
-                        intent = new Intent(BluetoothDevice.ACTION_NAME_CHANGED);
-                        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, bdDevice);
-                        intent.putExtra(BluetoothDevice.EXTRA_NAME, device.mName);
-                        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
-                        mAdapterService.sendBroadcast(intent, mAdapterService.BLUETOOTH_PERM);
-                        debugLog("Remote Device name is: " + device.mName);
-                        break;
-                    case AbstractionLayer.BT_PROPERTY_REMOTE_FRIENDLY_NAME:
-                        // TODO(BT) is null device.mAlias a valid senario?
-                        if (device.mAlias != null) {
-                            System.arraycopy(val, 0, device.mAlias, 0, val.length);
-                        }
-                        break;
-                    case AbstractionLayer.BT_PROPERTY_BDADDR:
-                        device.mAddress = val;
-                        debugLog("Remote Address is:" + Utils.getAddressStringFromByte(val));
-                        break;
-                    case AbstractionLayer.BT_PROPERTY_CLASS_OF_DEVICE:
-                        device.mBluetoothClass =  Utils.byteArrayToInt(val);
-                        intent = new Intent(BluetoothDevice.ACTION_CLASS_CHANGED);
-                        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, bdDevice);
-                        intent.putExtra(BluetoothDevice.EXTRA_CLASS,
-                                new BluetoothClass(device.mBluetoothClass));
-                        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
-                        mAdapterService.sendBroadcast(intent, mAdapterService.BLUETOOTH_PERM);
-                        debugLog("Remote class is:" + device.mBluetoothClass);
-                        break;
-                    case AbstractionLayer.BT_PROPERTY_UUIDS:
-                        int numUuids = val.length/AbstractionLayer.BT_UUID_SIZE;
-                        device.mUuids = Utils.byteArrayToUuid(val);
-                        sendUuidIntent(bdDevice);
-                        break;
-                    case AbstractionLayer.BT_PROPERTY_TYPE_OF_DEVICE:
-                        device.mDeviceType = Utils.byteArrayToInt(val);
-                        break;
-                    case AbstractionLayer.BT_PROPERTY_REMOTE_RSSI:
-                        device.mRssi = Utils.byteArrayToShort(val);
-                        break;
+            if(val.length <= 0)
+                errorLog("devicePropertyChangedCallback: bdDevice: " + bdDevice + ", value is empty for type: " + type);
+            else {
+                synchronized(mObject) {
+                    switch (type) {
+                        case AbstractionLayer.BT_PROPERTY_BDNAME:
+                            device.mName = new String(val);
+                            intent = new Intent(BluetoothDevice.ACTION_NAME_CHANGED);
+                            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, bdDevice);
+                            intent.putExtra(BluetoothDevice.EXTRA_NAME, device.mName);
+                            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+                            mAdapterService.sendBroadcast(intent, mAdapterService.BLUETOOTH_PERM);
+                            debugLog("Remote Device name is: " + device.mName);
+                            break;
+                        case AbstractionLayer.BT_PROPERTY_REMOTE_FRIENDLY_NAME:
+                            // TODO(BT) is null device.mAlias a valid senario?
+                            if (device.mAlias != null) {
+                                System.arraycopy(val, 0, device.mAlias, 0, val.length);
+                            }
+                            break;
+                        case AbstractionLayer.BT_PROPERTY_BDADDR:
+                            device.mAddress = val;
+                            debugLog("Remote Address is:" + Utils.getAddressStringFromByte(val));
+                            break;
+                        case AbstractionLayer.BT_PROPERTY_CLASS_OF_DEVICE:
+                            device.mBluetoothClass =  Utils.byteArrayToInt(val);
+                            intent = new Intent(BluetoothDevice.ACTION_CLASS_CHANGED);
+                            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, bdDevice);
+                            intent.putExtra(BluetoothDevice.EXTRA_CLASS,
+                                    new BluetoothClass(device.mBluetoothClass));
+                            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+                            mAdapterService.sendBroadcast(intent, mAdapterService.BLUETOOTH_PERM);
+                            debugLog("Remote class is:" + device.mBluetoothClass);
+                            break;
+                        case AbstractionLayer.BT_PROPERTY_UUIDS:
+                            int numUuids = val.length/AbstractionLayer.BT_UUID_SIZE;
+                            device.mUuids = Utils.byteArrayToUuid(val);
+                            sendUuidIntent(bdDevice);
+                            break;
+                        case AbstractionLayer.BT_PROPERTY_TYPE_OF_DEVICE:
+                            device.mDeviceType = Utils.byteArrayToInt(val);
+                            break;
+                        case AbstractionLayer.BT_PROPERTY_REMOTE_RSSI:
+                            device.mRssi = Utils.byteArrayToShort(val);
+                            break;
+                    }
                 }
             }
         }