[automerger] DO NOT MERGE Fix unexpected behavior in Bluetooth pairing am: 4f58c19afa am: e25ebddfdc am: ee220e0238 am: 7b2b84c617

Change-Id: I23c3c75844ff136521f67f94d4d911a44571ae07
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
index 300451d..11b3b1a 100755
--- a/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDialog.java
@@ -30,6 +30,7 @@
 import android.text.InputFilter.LengthFilter;
 import android.text.InputType;
 import android.text.TextWatcher;
+import android.util.EventLog;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.View;
@@ -209,8 +210,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 efcc7f9..e49f981 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.support.v7.preference.Preference;
+import android.util.EventLog;
 import android.util.Log;
 import android.view.View;
 import android.widget.Button;
@@ -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