summaryrefslogtreecommitdiff
path: root/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
diff options
context:
space:
mode:
authoryueg <yueg@google.com>2018-04-27 10:39:27 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-28 22:25:53 -0700
commit9bd6277786305f98dd85c4256f228b3ae191e05d (patch)
treefae59fda1ed1a786bf9cc32593fa767449e5f2c1 /java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
parentea1acce9b02cc6cf305c75cad733939527c7775b (diff)
HFP device support change.
Test: manual PiperOrigin-RevId: 194561401 Change-Id: Ia94765a3979b5f3c3e4d02c1dc235f5e41fbf6f9
Diffstat (limited to 'java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java')
-rw-r--r--java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java b/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
index 79cae098d..316dd128b 100644
--- a/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
+++ b/java/com/android/incallui/audioroute/AudioRouteSelectorDialogFragment.java
@@ -16,6 +16,7 @@
package com.android.incallui.audioroute;
+import android.annotation.SuppressLint;
import android.app.Dialog;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
@@ -35,6 +36,8 @@ import android.widget.TextView;
import com.android.dialer.common.FragmentUtils;
import com.android.dialer.common.LogUtil;
import com.android.incallui.audiomode.BluetoothDeviceProviderComponent;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.Set;
/** Shows picker for audio routes */
@@ -142,7 +145,7 @@ public class AudioRouteSelectorDialogFragment extends BottomSheetDialogFragment
int selectedColor = getResources().getColor(R.color.dialer_theme_color);
TextView textView =
(TextView) getLayoutInflater().inflate(R.layout.audioroute_item, null, false);
- textView.setText(bluetoothDevice.getName());
+ textView.setText(getAliasName(bluetoothDevice));
if (selected) {
textView.setTextColor(selectedColor);
textView.setCompoundDrawableTintList(ColorStateList.valueOf(selectedColor));
@@ -163,4 +166,16 @@ public class AudioRouteSelectorDialogFragment extends BottomSheetDialogFragment
return textView;
}
+
+ @SuppressLint("PrivateApi")
+ private String getAliasName(BluetoothDevice bluetoothDevice) {
+ try {
+ Method getActiveDeviceMethod = bluetoothDevice.getClass().getDeclaredMethod("getAliasName");
+ getActiveDeviceMethod.setAccessible(true);
+ return (String) getActiveDeviceMethod.invoke(bluetoothDevice);
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
+ e.printStackTrace();
+ return bluetoothDevice.getName();
+ }
+ }
}