34 lines
1.2 KiB
Diff

From d6e2ed21c5c8be3dfb7916626003375f0756514b Mon Sep 17 00:00:00 2001
From: Hansong Zhang <hsz@google.com>
Date: Wed, 18 Aug 2021 16:35:00 -0700
Subject: [PATCH] DO NOT MERGE Bluetooth: Fix formatting in getAlias()
Bug: 180747689
Test: manual
Change-Id: Ic309f4aad116fd424d5d0d0e2016d61be8826b78
(cherry picked from commit 3bdad2df2e34c948bde80a51ae232c46848dab06)
---
core/java/android/bluetooth/BluetoothDevice.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 3cf80746652e..8916b537ff29 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -894,7 +894,14 @@ public String getAlias() {
return null;
}
try {
- return service.getRemoteAlias(this);
+ String alias = service.getRemoteAlias(this);
+ if (alias == null) {
+ return getName();
+ }
+ return alias
+ .replace('\t', ' ')
+ .replace('\n', ' ')
+ .replace('\r', ' ');
} catch (RemoteException e) {
Log.e(TAG, "", e);
}