[automerger] DO NOT MERGE Fix unexpected behavior in Bluetooth pairing am: ac6c49d2b0 am: 5b98c9f4a3 am: dfe4cc74f7

Change-Id: I69b00aebae95532bf9fe51191b14e12d8948b0bf
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
index 1ff99f7..a71ad24 100755
--- a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
@@ -30,6 +30,7 @@
 import android.text.InputType;
 import android.text.TextWatcher;
 import android.text.InputFilter.LengthFilter;
+import android.util.EventLog;
 import android.util.Log;
 import android.view.View;
 import android.widget.Button;
@@ -197,8 +198,9 @@
         } else {
             if (mDevice.getBluetoothClass().getDeviceClass()
                     == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE) {
-                contactSharing.setChecked(true);
-                mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
+                contactSharing.setChecked(false);
+                mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
+                EventLog.writeEvent(0x534e4554, "73173182", -1, "");
             } else {
                 contactSharing.setChecked(false);
                 mDevice.setPhonebookAccessPermission(BluetoothDevice.ACCESS_REJECTED);
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
index 2267555..0a7c7df 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
@@ -24,6 +24,7 @@
 import android.content.IntentFilter;
 import android.os.Bundle;
 import android.preference.Preference;
+import android.util.EventLog;
 import android.util.Log;
 import android.view.View;
 import android.widget.TextView;
@@ -154,7 +155,11 @@
         String mRemoteName = mDevice != null ? mDevice.getAliasName() : null;
 
         if (mRemoteName == null) mRemoteName = getString(R.string.unknown);
-        return mRemoteName;
+        String nameNoNewline = mRemoteName.replaceAll("[\\t\\n\\r]+", " ");
+        if (!mRemoteName.equals(nameNoNewline)) {
+            EventLog.writeEvent(0x534e4554, "72872376", -1, "");
+        }
+        return nameNoNewline;
     }
 
     // TODO(edjee): createConnectionDialogView, createPhonebookDialogView and createMapDialogView