diff options
7 files changed, 25 insertions, 8 deletions
diff --git a/android-adb/src/com/android/tools/idea/adb/wireless/AdbServiceWrapper.kt b/android-adb/src/com/android/tools/idea/adb/wireless/AdbServiceWrapper.kt index 6579920dd77..19db84810c1 100644 --- a/android-adb/src/com/android/tools/idea/adb/wireless/AdbServiceWrapper.kt +++ b/android-adb/src/com/android/tools/idea/adb/wireless/AdbServiceWrapper.kt @@ -58,7 +58,10 @@ data class AdbOnlineDevice(val id: String, val properties: Map<String, String>) // TODO: Use DeviceNameRenderer class when it has moved out of android.core module val manufacturer = properties[IDevice.PROP_DEVICE_MANUFACTURER] ?: "" val model = properties[IDevice.PROP_DEVICE_MODEL] ?: id - return "${manufacturer} ${model}" + return if (model.startsWith(manufacturer, true)) + model + else + "$manufacturer $model" } } diff --git a/android-adb/src/com/android/tools/idea/ddms/DeviceNameProperties.kt b/android-adb/src/com/android/tools/idea/ddms/DeviceNameProperties.kt index 73b6f32cdde..1daffc770cf 100644 --- a/android-adb/src/com/android/tools/idea/ddms/DeviceNameProperties.kt +++ b/android-adb/src/com/android/tools/idea/ddms/DeviceNameProperties.kt @@ -39,7 +39,10 @@ data class DeviceNameProperties(val model: String?, return model } - return "$manufacturer $model" + return if (model.startsWith(manufacturer, true)) + model + else + "$manufacturer $model" } } } diff --git a/android-adb/src/com/android/tools/idea/ddms/DeviceRenderer.java b/android-adb/src/com/android/tools/idea/ddms/DeviceRenderer.java index f1722a87086..b72e9d1c1e4 100644 --- a/android-adb/src/com/android/tools/idea/ddms/DeviceRenderer.java +++ b/android-adb/src/com/android/tools/idea/ddms/DeviceRenderer.java @@ -27,6 +27,7 @@ import com.intellij.ui.ColoredTextContainer; import com.intellij.ui.SimpleTextAttributes; import icons.StudioIcons; import java.util.List; +import java.util.Locale; import java.util.Set; import javax.swing.JList; import javax.swing.JTable; @@ -95,8 +96,13 @@ public class DeviceRenderer { @NotNull private static String getDeviceName(@NotNull DeviceNameProperties deviceNameProperties) { - return String.format("%1$s %2$s ", DevicePropertyUtil.getManufacturer(deviceNameProperties.getManufacturer(), false, ""), - DevicePropertyUtil.getModel(deviceNameProperties.getModel(), "")); + String manufacturer = DevicePropertyUtil.getManufacturer(deviceNameProperties.getManufacturer(), false, ""); + String model = DevicePropertyUtil.getModel(deviceNameProperties.getModel(), ""); + if (model.toUpperCase(Locale.US).startsWith(manufacturer.toUpperCase(Locale.US))) { + return String.format("%1$s ", model); + } else { + return String.format("%1$s %2$s ", manufacturer, model); + } } public static boolean shouldShowSerialNumbers(@NotNull List<IDevice> devices, @NotNull DeviceNamePropertiesProvider provider) { diff --git a/logcat/src/com/android/tools/idea/logcat/devices/Device.kt b/logcat/src/com/android/tools/idea/logcat/devices/Device.kt index 389cc5fce3e..7a5c08b39f8 100644 --- a/logcat/src/com/android/tools/idea/logcat/devices/Device.kt +++ b/logcat/src/com/android/tools/idea/logcat/devices/Device.kt @@ -40,7 +40,8 @@ internal data class Device private constructor( manufacturer: String, model: String, ): Device { - return Device(deviceId = serialNumber, name = "$manufacturer $model", serialNumber, isOnline, release, sdk, model) + val deviceName = if (model.startsWith(manufacturer)) model else "$manufacturer $model" + return Device(deviceId = serialNumber, name = deviceName, serialNumber, isOnline, release, sdk, model) } fun createEmulator( diff --git a/profilers-android/src/com/android/tools/idea/profilers/AndroidProfilerToolWindow.java b/profilers-android/src/com/android/tools/idea/profilers/AndroidProfilerToolWindow.java index 915c50a8a3e..675b083f3d6 100644 --- a/profilers-android/src/com/android/tools/idea/profilers/AndroidProfilerToolWindow.java +++ b/profilers-android/src/com/android/tools/idea/profilers/AndroidProfilerToolWindow.java @@ -58,6 +58,7 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.io.File; +import java.util.Locale; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComponent; @@ -268,7 +269,7 @@ public class AndroidProfilerToolWindow implements Disposable { if (model.endsWith(suffix)) { model = model.substring(0, model.length() - suffix.length()); } - if (!StringUtil.isEmpty(manufacturer)) { + if (!StringUtil.isEmpty(manufacturer) && !model.toUpperCase(Locale.US).startsWith(manufacturer.toUpperCase(Locale.US))) { deviceNameBuilder.append(manufacturer); deviceNameBuilder.append(" "); } diff --git a/profilers/src/com/android/tools/profilers/StudioProfilers.java b/profilers/src/com/android/tools/profilers/StudioProfilers.java index 0981b5aaa7b..aa1896f9d64 100644 --- a/profilers/src/com/android/tools/profilers/StudioProfilers.java +++ b/profilers/src/com/android/tools/profilers/StudioProfilers.java @@ -75,6 +75,7 @@ import java.util.Collection; import java.util.Comparator; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -992,7 +993,7 @@ public class StudioProfilers extends AspectModel<ProfilerAspect> implements Upda if (model.endsWith(suffix)) { model = model.substring(0, model.length() - suffix.length()); } - if (!StringUtil.isEmpty(manufacturer)) { + if (!StringUtil.isEmpty(manufacturer) && !model.toUpperCase(Locale.US).startsWith(manufacturer.toUpperCase(Locale.US))) { deviceNameBuilder.append(manufacturer); deviceNameBuilder.append(" "); } diff --git a/wear-pairing/src/com/android/tools/idea/wearpairing/WearPairingManager.kt b/wear-pairing/src/com/android/tools/idea/wearpairing/WearPairingManager.kt index 353311ce93a..a9207e687f4 100644 --- a/wear-pairing/src/com/android/tools/idea/wearpairing/WearPairingManager.kt +++ b/wear-pairing/src/com/android/tools/idea/wearpairing/WearPairingManager.kt @@ -519,7 +519,9 @@ internal fun AvdInfo.isWearOrPhone(): Boolean = when (tag) { } private fun IDevice.getDeviceName(unknown: String): String { - val deviceName = "${getManufacturer(this, "")} ${getModel(this, "")}" + val model = getModel(this, "") + val manufacturer = getManufacturer(this, "") + val deviceName = if (model.startsWith(manufacturer, true)) model else "$manufacturer $model" return deviceName.ifBlank { unknown } } |