OSDN Git Service

DO NOT MERGE Truncate newline and tab characters in BluetoothDevice name
authorHansong Zhang <hsz@google.com>
Thu, 26 Apr 2018 21:22:39 +0000 (14:22 -0700)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Fri, 25 May 2018 18:40:23 +0000 (18:40 +0000)
Test: manual
Bug: 73173182
Change-Id: I7f2201cab36adf7f01d1a794d783cb78a536811f
(cherry picked from commit 24da173b63b17a0bc6c80b2fcfefa7fe4574a15b)

core/java/android/bluetooth/BluetoothDevice.java

index 98cd319..9498f12 100644 (file)
@@ -808,7 +808,11 @@ public final class BluetoothDevice implements Parcelable {
             return null;
         }
         try {
-            return service.getRemoteName(this);
+            String name = service.getRemoteName(this);
+            if (name != null) {
+                return name.replaceAll("[\\t\\n\\r]+", " ");
+            }
+            return null;
         } catch (RemoteException e) {
             Log.e(TAG, "", e);
         }