merge in nyc-dr1-release history after reset to nyc-dr1-dev
diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml
index 53ce817..ed31bb1 100644
--- a/res/values-ca/strings.xml
+++ b/res/values-ca/strings.xml
@@ -27,7 +27,7 @@
     <string name="airplane_error_msg" msgid="8698965595254137230">"No pots utilitzar Bluetooth en mode d\'avió."</string>
     <string name="bt_enable_title" msgid="8657832550503456572"></string>
     <string name="bt_enable_line1" msgid="7203551583048149">"Per utilitzar serveis Bluetooth, primer cal que activeu el Bluetooth."</string>
-    <string name="bt_enable_line2" msgid="4341936569415937994">"Voleu activar el Bluetooth ara?"</string>
+    <string name="bt_enable_line2" msgid="4341936569415937994">"Vols activar el Bluetooth ara?"</string>
     <string name="bt_enable_cancel" msgid="1988832367505151727">"Cancel·la"</string>
     <string name="bt_enable_ok" msgid="3432462749994538265">"Activa"</string>
     <string name="incoming_file_confirm_title" msgid="8139874248612182627">"Transferència del fitxer"</string>
diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml
index 9e390dd..bdffe86 100644
--- a/res/values-fa/strings.xml
+++ b/res/values-fa/strings.xml
@@ -99,7 +99,7 @@
     <string name="status_no_sd_card" product="default" msgid="5760944071743325592">"‏هیچ کارت SD موجود نیست. برای ذخیره فایل‌های منتقل شده، یک کارت SD در گوشی قرار دهید."</string>
     <string name="status_connection_error" msgid="947681831523219891">"اتصال ناموفق بود."</string>
     <string name="status_protocol_error" msgid="3245444473429269539">"درخواست به درستی انجام نمی‌شود."</string>
-    <string name="status_unknown_error" msgid="8156660554237824912">"خطای ناشناخته."</string>
+    <string name="status_unknown_error" msgid="8156660554237824912">"خطای ناشناس."</string>
     <string name="btopp_live_folder" msgid="7967791481444474554">"بلوتوث دریافت شد"</string>
     <string name="download_success" msgid="7036160438766730871">"<xliff:g id="FILE_SIZE">%1$s</xliff:g> دریافت کامل شد."</string>
     <string name="upload_success" msgid="4014469387779648949">"<xliff:g id="FILE_SIZE">%1$s</xliff:g> ارسال کامل شد."</string>
diff --git a/res/values-fa/strings_pbap.xml b/res/values-fa/strings_pbap.xml
index 945d442..0667ebb 100644
--- a/res/values-fa/strings_pbap.xml
+++ b/res/values-fa/strings_pbap.xml
@@ -5,7 +5,7 @@
     <string name="pbap_session_key_dialog_header" msgid="2772472422782758981">"به کلید جلسه بلوتوث نیاز است"</string>
     <string name="pbap_acceptance_timeout_message" msgid="1107401415099814293">"‏هنگام پذیرش اتصال به %1$s وقفه زمانی ایجاد شده است"</string>
     <string name="pbap_authentication_timeout_message" msgid="4166979525521902687">"‏هنگام ورود کلید جلسه با %1$s وقفه زمانی ایجاد شده است"</string>
-    <string name="auth_notif_ticker" msgid="1575825798053163744">"‏درخواست راستی‌آزمایی Obex"</string>
+    <string name="auth_notif_ticker" msgid="1575825798053163744">"‏درخواست احراز هویت Obex"</string>
     <string name="auth_notif_title" msgid="7599854855681573258">"کلید جلسه"</string>
     <string name="auth_notif_message" msgid="6667218116427605038">"‏تایپ کلید جلسه برای %1$s"</string>
     <string name="defaultname" msgid="4821590500649090078">"کیت خودرو"</string>
diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml
index 9a4a536..85423d7 100644
--- a/res/values-ro/strings.xml
+++ b/res/values-ro/strings.xml
@@ -82,7 +82,7 @@
     <string name="bt_toast_2" msgid="8602553334099066582">"Fișierul nu poate fi primit."</string>
     <string name="bt_toast_3" msgid="6707884165086862518">"Primirea fișierului de la „<xliff:g id="SENDER">%1$s</xliff:g>” a fost anulată"</string>
     <string name="bt_toast_4" msgid="4678812947604395649">"Se trimite fișierul către „<xliff:g id="RECIPIENT">%1$s</xliff:g>”"</string>
-    <string name="bt_toast_5" msgid="2846870992823019494">"Se trimit <xliff:g id="NUMBER">%1$s</xliff:g> (de) fișiere către „<xliff:g id="RECIPIENT">%2$s</xliff:g>”"</string>
+    <string name="bt_toast_5" msgid="2846870992823019494">"Se trimit <xliff:g id="NUMBER">%1$s</xliff:g>   fișiere către „<xliff:g id="RECIPIENT">%2$s</xliff:g>”"</string>
     <string name="bt_toast_6" msgid="1855266596936622458">"Trimiterea fișierului către „<xliff:g id="RECIPIENT">%1$s</xliff:g>” a fost anulată"</string>
     <string name="bt_sm_2_1" product="nosdcard" msgid="352165168004521000">"Nu există spațiu suficient pe stocarea USB pentru a salva fișierul de la „<xliff:g id="SENDER">%1$s</xliff:g>”"</string>
     <string name="bt_sm_2_1" product="default" msgid="1989018443456803630">"Nu există suficient spațiu pe cardul SD pentru a salva fișierul de la „<xliff:g id="SENDER">%1$s</xliff:g>”"</string>
diff --git a/src/com/android/bluetooth/btservice/RemoteDevices.java b/src/com/android/bluetooth/btservice/RemoteDevices.java
index 3ae2455..9eaf7e5 100644
--- a/src/com/android/bluetooth/btservice/RemoteDevices.java
+++ b/src/com/android/bluetooth/btservice/RemoteDevices.java
@@ -45,13 +45,13 @@
     private static final int UUID_INTENT_DELAY = 6000;
     private static final int MESSAGE_UUID_INTENT = 1;
 
-    private HashMap<BluetoothDevice, DeviceProperties> mDevices;
+    private HashMap<String, DeviceProperties> mDevices;
 
     RemoteDevices(AdapterService service) {
         mAdapter = BluetoothAdapter.getDefaultAdapter();
         mAdapterService = service;
         mSdpTracker = new ArrayList<BluetoothDevice>();
-        mDevices = new HashMap<BluetoothDevice, DeviceProperties>();
+        mDevices = new HashMap<String, DeviceProperties>();
     }
 
 
@@ -70,26 +70,23 @@
 
     DeviceProperties getDeviceProperties(BluetoothDevice device) {
         synchronized (mDevices) {
-            return mDevices.get(device);
+            return mDevices.get(device.getAddress());
         }
     }
 
     BluetoothDevice getDevice(byte[] address) {
-        for (BluetoothDevice dev : mDevices.keySet()) {
-            if (dev.getAddress().equals(Utils.getAddressStringFromByte(address))) {
-                return dev;
-            }
-        }
-        return null;
+        DeviceProperties prop = mDevices.get(Utils.getAddressStringFromByte(address));
+        if (prop == null)
+           return null;
+        return prop.getDevice();
     }
 
     DeviceProperties addDeviceProperties(byte[] address) {
         synchronized (mDevices) {
             DeviceProperties prop = new DeviceProperties();
-            BluetoothDevice device =
-                    mAdapter.getRemoteDevice(Utils.getAddressStringFromByte(address));
+            prop.mDevice = mAdapter.getRemoteDevice(Utils.getAddressStringFromByte(address));
             prop.mAddress = address;
-            mDevices.put(device, prop);
+            mDevices.put(Utils.getAddressStringFromByte(address), prop);
             return prop;
         }
     }
@@ -103,6 +100,7 @@
         private int mDeviceType;
         private String mAlias;
         private int mBondState;
+        private BluetoothDevice mDevice;
 
         DeviceProperties() {
             mBondState = BluetoothDevice.BOND_NONE;
@@ -145,6 +143,15 @@
         }
 
         /**
+         * @return the mDevice
+         */
+        BluetoothDevice getDevice() {
+            synchronized (mObject) {
+                return mDevice;
+            }
+        }
+
+        /**
          * @return mRssi
          */
         short getRssi() {
diff --git a/src/com/android/bluetooth/gatt/ScanManager.java b/src/com/android/bluetooth/gatt/ScanManager.java
index 1982cab..d93e838 100644
--- a/src/com/android/bluetooth/gatt/ScanManager.java
+++ b/src/com/android/bluetooth/gatt/ScanManager.java
@@ -232,7 +232,7 @@
                         Message msg = mHandler.obtainMessage(MSG_SCAN_TIMEOUT);
                         msg.obj = client;
                         // Only one timeout message should exist at any time
-                        mHandler.removeMessages(SCAN_TIMEOUT_MS);
+                        mHandler.removeMessages(MSG_SCAN_TIMEOUT);
                         mHandler.sendMessageDelayed(msg, SCAN_TIMEOUT_MS);
                     }
                 }
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
index 1688c70..1b431f9 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
@@ -415,13 +415,13 @@
                         outputStream.write(buffer, 0, readLength);
 
                         position += readLength;
+                        /* check remote accept or reject */
+                        responseCode = putOperation.getResponseCode();
 
                         mCallback.removeMessages(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT);
                         synchronized (this) {
                             mWaitingForRemote = false;
                         }
-                        /* check remote accept or reject */
-                        responseCode = putOperation.getResponseCode();
 
                         if (responseCode == ResponseCodes.OBEX_HTTP_CONTINUE
                                 || responseCode == ResponseCodes.OBEX_HTTP_OK) {
@@ -497,7 +497,7 @@
             } finally {
                 try {
                     if (outputStream != null) {
-                      outputStream.close();
+                        outputStream.close();
                     }
 
                     // Close InputStream and remove SendFileInfo from map
diff --git a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
index b8cb641..b9d2b9f 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppSendFileInfo.java
@@ -117,7 +117,11 @@
             } catch (SQLiteException e) {
                 // some content providers don't support the DISPLAY_NAME or SIZE columns
                 metadataCursor = null;
+            } catch (SecurityException e) {
+                Log.e(TAG, "generateFileInfo: Permission error, could not access URI: " + uri);
+                return SEND_FILE_INFO_ERROR;
             }
+
             if (metadataCursor != null) {
                 try {
                     if (metadataCursor.moveToFirst()) {
diff --git a/src/com/android/bluetooth/opp/BluetoothOppUtility.java b/src/com/android/bluetooth/opp/BluetoothOppUtility.java
index ab4613f..bd671b2 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppUtility.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppUtility.java
@@ -331,6 +331,9 @@
 
     static void putSendFileInfo(Uri uri, BluetoothOppSendFileInfo sendFileInfo) {
         if (D) Log.d(TAG, "putSendFileInfo: uri=" + uri + " sendFileInfo=" + sendFileInfo);
+        if (sendFileInfo == BluetoothOppSendFileInfo.SEND_FILE_INFO_ERROR) {
+            Log.e(TAG, "putSendFileInfo: bad sendFileInfo, URI: " + uri);
+        }
         sSendFileMap.put(uri, sendFileInfo);
     }