From 338f27ab28a451d08417e4b2987aba1267b4c95d Mon Sep 17 00:00:00 2001 From: Paul McLean Date: Wed, 13 May 2015 15:41:00 -0700 Subject: [PATCH] New policy for internal and wired device names. For internal and unknowable wired devices, return the product name (i.e. "Nexus 7"). For connected devices with manufacturer-supplied product names, return those. Change getName() to getProductName(). Bug: 20880296 Change-Id: I67ef3d4c73b3acab368b0879faa26fa9127c21bb --- api/current.txt | 2 +- api/system-current.txt | 2 +- media/java/android/media/AudioDeviceInfo.java | 5 +++-- .../core/java/com/android/server/WiredAccessoryManager.java | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/api/current.txt b/api/current.txt index 08d6a9dbebb27..47dfa2f4220f4 100644 --- a/api/current.txt +++ b/api/current.txt @@ -14696,7 +14696,7 @@ package android.media { method public int[] getChannelMasks(); method public int[] getFormats(); method public int getId(); - method public java.lang.CharSequence getName(); + method public java.lang.CharSequence getProductName(); method public int[] getSampleRates(); method public int getType(); method public boolean isSink(); diff --git a/api/system-current.txt b/api/system-current.txt index 7cf49e86f20ca..f490d68c8c9a2 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -15906,7 +15906,7 @@ package android.media { method public int[] getChannelMasks(); method public int[] getFormats(); method public int getId(); - method public java.lang.CharSequence getName(); + method public java.lang.CharSequence getProductName(); method public int[] getSampleRates(); method public int getType(); method public boolean isSink(); diff --git a/media/java/android/media/AudioDeviceInfo.java b/media/java/android/media/AudioDeviceInfo.java index 566f8dc4ee507..b4c109b6db469 100644 --- a/media/java/android/media/AudioDeviceInfo.java +++ b/media/java/android/media/AudioDeviceInfo.java @@ -121,8 +121,9 @@ public final class AudioDeviceInfo { /** * @return The human-readable name of the audio device. */ - public CharSequence getName() { - return mPort.name(); + public CharSequence getProductName() { + String portName = mPort.name(); + return portName.length() != 0 ? portName : android.os.Build.MODEL; } /** diff --git a/services/core/java/com/android/server/WiredAccessoryManager.java b/services/core/java/com/android/server/WiredAccessoryManager.java index 0de8c8dd9df5d..e0e6070a811a6 100644 --- a/services/core/java/com/android/server/WiredAccessoryManager.java +++ b/services/core/java/com/android/server/WiredAccessoryManager.java @@ -216,9 +216,9 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { mWakeLock.acquire(); - Log.i(TAG, "MSG_NEW_DEVICE_STATE "); + Log.i(TAG, "MSG_NEW_DEVICE_STATE"); Message msg = mHandler.obtainMessage(MSG_NEW_DEVICE_STATE, headsetState, - mHeadsetState, newName); + mHeadsetState, ""); mHandler.sendMessage(msg); mHeadsetState = headsetState;