Merge "Bluetooth: Application changes for A4WP"
diff --git a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java
index 4a9acd8..5d05769 100644
--- a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java
+++ b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java
@@ -642,22 +642,33 @@
          * return ResponseCodes.OBEX_HTTP_NOT_FOUND
          */
         if ((current_path_tmp != null  && current_path_tmp.length() != 0)) {
-            if (create) {
-                if (FileUtils.doesPathExist(current_path_tmp)) {
-                    if (D) Log.d(TAG, "Folder already exists");
-                    return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
-                } else {
+            if (!FileUtils.doesPathExist(current_path_tmp)) {
+                if (create) {
                     File filecreate = new File(current_path_tmp);
                     if (filecreate != null && !filecreate.mkdir()) {
                         Log.e(TAG, "Could not create " + tmp_path);
                         return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
                     }
-                }
-            } else {
-                if (!FileUtils.doesPathExist(current_path_tmp)) {
+                } else {
                     Log.e(TAG, "path: " +  current_path_tmp + " not found");
                     return ResponseCodes.OBEX_HTTP_NOT_FOUND;
                 }
+            } else {
+                /* Check if the folder to be created or set is not having same
+                 * name as existing file in same location. If file with same name is
+                 * present, return error to Client. */
+                File file = new File(current_path_tmp);
+                if (file.isFile()) {
+                    if (create) {
+                        Log.e(TAG, "File already exists with same name, " +
+                            "can't create folder with same name");
+                        return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
+                    } else {
+                        Log.e(TAG, "Path is not valid, path being set is " +
+                            "for file not folder");
+                        return ResponseCodes.OBEX_HTTP_NOT_FOUND;
+                    }
+                }
             }
         } else if (current_path_tmp == null && tmp_path != null) {
             if (create) {
diff --git a/src/org/codeaurora/bluetooth/pxpservice/PxpMonitorService.java b/src/org/codeaurora/bluetooth/pxpservice/PxpMonitorService.java
index 59614f2..780a9b7 100644
--- a/src/org/codeaurora/bluetooth/pxpservice/PxpMonitorService.java
+++ b/src/org/codeaurora/bluetooth/pxpservice/PxpMonitorService.java
@@ -1111,10 +1111,18 @@
 
         @Override
         public void onAlert(int evtType, int rssi) {
+            int alertLevelValue = 0;
             Log.d(TAG, "onAlert in PxpMonitorService:: evtType::"+evtType+"::rssi::"+rssi);
 
             DeviceProperties deviceProp = mHashMapDevice.get(mDevice);
-            int alertLevelValue = getAlertLevelValue(evtType);
+            if(deviceProp.minPathLossThreshold == deviceProp.maxPathLossThreshold) {
+                if(evtType == BluetoothLwPwrProximityMonitor.RSSI_HIGH_ALERT) {
+                    alertLevelValue = deviceProp.pathLossAlertLevel;
+                }
+            }
+            else {
+                alertLevelValue = getAlertLevelValue(evtType);
+            }
 
             deviceProp.iasAlertLevelCh.setValue(alertLevelValue,
                     BluetoothGattCharacteristic.FORMAT_UINT8, 0);