Fixed incorrect handling of the RSSI during inquiry which causes the devices to not get sorted properly.

Change-Id: Ib4eca5405a3393aef79f43943853adf76da23e76
diff --git a/jni/com_android_bluetooth_btservice_AdapterService.cpp b/jni/com_android_bluetooth_btservice_AdapterService.cpp
index 4e68bff..9d49b65 100755
--- a/jni/com_android_bluetooth_btservice_AdapterService.cpp
+++ b/jni/com_android_bluetooth_btservice_AdapterService.cpp
@@ -85,6 +85,17 @@
     if (*types == NULL) goto Fail;
 
     for (int i = 0; i < num_properties; i++) {
+
+       /* The higher layers expect rssi as a short int value, while the value is sent as a byte
+        * to jni. Converting rssi value to the expected format.*/
+       if (properties[i].type == BT_PROPERTY_REMOTE_RSSI)
+       {
+           jbyte rssi = *((jbyte *) properties[i].val);
+           short rssiValue = rssi;
+           properties[i].len = sizeof(rssiValue);
+           properties[i].val = &rssiValue;
+       }
+
        propVal = callbackEnv->NewByteArray(properties[i].len);
        if (propVal == NULL) goto Fail;
 
diff --git a/src/com/android/bluetooth/btservice/AbstractionLayer.java b/src/com/android/bluetooth/btservice/AbstractionLayer.java
index 2e06ef6..3d3b86c 100644
--- a/src/com/android/bluetooth/btservice/AbstractionLayer.java
+++ b/src/com/android/bluetooth/btservice/AbstractionLayer.java
@@ -30,8 +30,8 @@
     static final int BT_PROPERTY_ADAPTER_BONDED_DEVICES = 0x08;
     static final int BT_PROPERTY_ADAPTER_DISCOVERABLE_TIMEOUT = 0x09;
 
-    static final int BT_PROPERTY_REMOTE_FRIENDLY_NAME = 0x10;
-    static final int BT_PROPERTY_REMOTE_RSSI = 0x11;
+    static final int BT_PROPERTY_REMOTE_FRIENDLY_NAME = 0x0A;
+    static final int BT_PROPERTY_REMOTE_RSSI = 0x0B;
 
     static final int BT_DEVICE_TYPE_BREDR = 0x01;
     static final int BT_DEVICE_TYPE_BLE = 0x02;