OSDN Git Service

DO NOT MERGE Truncate newline and tab characters in BluetoothDevice name
authorHansong Zhang <hsz@google.com>
Thu, 26 Apr 2018 21:13:45 +0000 (14:13 -0700)
committerHansong Zhang <hsz@google.com>
Thu, 26 Apr 2018 21:17:52 +0000 (14:17 -0700)
Test: manual
Bug: 73173182
Change-Id: I3c25af233742e63351a68e8c5a279b51a94e49e2

core/java/android/bluetooth/BluetoothDevice.java

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