diff options
-rw-r--r-- | core/java/android/alsa/AlsaCardsParser.java | 7 | ||||
-rw-r--r-- | core/jni/android_media_AudioSystem.cpp | 30 | ||||
-rw-r--r-- | media/java/android/media/AudioDevicePort.java | 5 | ||||
-rw-r--r-- | media/java/android/media/AudioManager.java | 4 | ||||
-rw-r--r-- | media/java/android/media/AudioMixPort.java | 5 | ||||
-rw-r--r-- | media/java/android/media/AudioPort.java | 17 | ||||
-rw-r--r-- | media/java/android/media/AudioRoutesInfo.java | 1 | ||||
-rw-r--r-- | media/java/android/media/AudioService.java | 116 | ||||
-rw-r--r-- | media/java/android/media/AudioSystem.java | 3 | ||||
-rw-r--r-- | media/java/android/media/IAudioService.aidl | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/WiredAccessoryManager.java | 11 | ||||
-rw-r--r-- | services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java | 2 | ||||
-rw-r--r-- | services/usb/java/com/android/server/usb/UsbAlsaManager.java | 9 | ||||
-rw-r--r-- | services/usb/java/com/android/server/usb/UsbAudioDevice.java | 1 |
14 files changed, 154 insertions, 59 deletions
diff --git a/core/java/android/alsa/AlsaCardsParser.java b/core/java/android/alsa/AlsaCardsParser.java index 2c7d502..26a61ae 100644 --- a/core/java/android/alsa/AlsaCardsParser.java +++ b/core/java/android/alsa/AlsaCardsParser.java @@ -80,8 +80,11 @@ public class AlsaCardsParser { } else if (lineIndex == 1) { tokenIndex = mTokenizer.nextToken(line, 0); if (tokenIndex != -1) { - mCardDescription = line.substring(tokenIndex); - mIsUsb = mCardDescription.contains(kUsbCardKeyStr); + int keyIndex = line.indexOf(kUsbCardKeyStr); + mIsUsb = keyIndex != -1; + if (mIsUsb) { + mCardDescription = line.substring(tokenIndex, keyIndex - 1); + } } } diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp index 0bf269f..ef78fde 100644 --- a/core/jni/android_media_AudioSystem.cpp +++ b/core/jni/android_media_AudioSystem.cpp @@ -338,13 +338,15 @@ android_media_AudioSystem_error_callback(status_t err) } static jint -android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address) +android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address, jstring device_name) { const char *c_address = env->GetStringUTFChars(device_address, NULL); + const char *c_name = env->GetStringUTFChars(device_name, NULL); int status = check_AudioSystem_Command(AudioSystem::setDeviceConnectionState(static_cast <audio_devices_t>(device), static_cast <audio_policy_dev_state_t>(state), - c_address)); + c_address, c_name)); env->ReleaseStringUTFChars(device_address, c_address); + env->ReleaseStringUTFChars(device_name, c_name); return (jint) status; } @@ -788,10 +790,11 @@ static jint convertAudioPortFromNative(JNIEnv *env, jintArray jFormats = NULL; jobjectArray jGains = NULL; jobject jHandle = NULL; + jstring jDeviceName = NULL; bool useInMask; - ALOGV("convertAudioPortFromNative id %d role %d type %d", - nAudioPort->id, nAudioPort->role, nAudioPort->type); + ALOGV("convertAudioPortFromNative id %d role %d type %d name %s", + nAudioPort->id, nAudioPort->role, nAudioPort->type, nAudioPort->name); jSamplingRates = env->NewIntArray(nAudioPort->num_sample_rates); if (jSamplingRates == NULL) { @@ -871,17 +874,21 @@ static jint convertAudioPortFromNative(JNIEnv *env, goto exit; } + jDeviceName = env->NewStringUTF(nAudioPort->name); + if (nAudioPort->type == AUDIO_PORT_TYPE_DEVICE) { ALOGV("convertAudioPortFromNative is a device %08x", nAudioPort->ext.device.type); jstring jAddress = env->NewStringUTF(nAudioPort->ext.device.address); *jAudioPort = env->NewObject(gAudioDevicePortClass, gAudioDevicePortCstor, - jHandle, jSamplingRates, jChannelMasks, jFormats, jGains, + jHandle, jDeviceName, + jSamplingRates, jChannelMasks, jFormats, jGains, nAudioPort->ext.device.type, jAddress); env->DeleteLocalRef(jAddress); } else if (nAudioPort->type == AUDIO_PORT_TYPE_MIX) { ALOGV("convertAudioPortFromNative is a mix"); *jAudioPort = env->NewObject(gAudioMixPortClass, gAudioMixPortCstor, - jHandle, nAudioPort->role, jSamplingRates, jChannelMasks, + jHandle, nAudioPort->role, jDeviceName, + jSamplingRates, jChannelMasks, jFormats, jGains); } else { ALOGE("convertAudioPortFromNative unknown nAudioPort type %d", nAudioPort->type); @@ -905,6 +912,9 @@ static jint convertAudioPortFromNative(JNIEnv *env, env->SetObjectField(*jAudioPort, gAudioPortFields.mActiveConfig, jAudioPortConfig); exit: + if (jDeviceName != NULL) { + env->DeleteLocalRef(jDeviceName); + } if (jSamplingRates != NULL) { env->DeleteLocalRef(jSamplingRates); } @@ -1496,7 +1506,7 @@ static JNINativeMethod gMethods[] = { {"isStreamActiveRemotely","(II)Z", (void *)android_media_AudioSystem_isStreamActiveRemotely}, {"isSourceActive", "(I)Z", (void *)android_media_AudioSystem_isSourceActive}, {"newAudioSessionId", "()I", (void *)android_media_AudioSystem_newAudioSessionId}, - {"setDeviceConnectionState", "(IILjava/lang/String;)I", (void *)android_media_AudioSystem_setDeviceConnectionState}, + {"setDeviceConnectionState", "(IILjava/lang/String;Ljava/lang/String;)I", (void *)android_media_AudioSystem_setDeviceConnectionState}, {"getDeviceConnectionState", "(ILjava/lang/String;)I", (void *)android_media_AudioSystem_getDeviceConnectionState}, {"setPhoneState", "(I)I", (void *)android_media_AudioSystem_setPhoneState}, {"setForceUse", "(II)I", (void *)android_media_AudioSystem_setForceUse}, @@ -1556,7 +1566,7 @@ int register_android_media_AudioSystem(JNIEnv *env) jclass audioPortClass = FindClassOrDie(env, "android/media/AudioPort"); gAudioPortClass = MakeGlobalRefOrDie(env, audioPortClass); gAudioPortCstor = GetMethodIDOrDie(env, audioPortClass, "<init>", - "(Landroid/media/AudioHandle;I[I[I[I[Landroid/media/AudioGain;)V"); + "(Landroid/media/AudioHandle;ILjava/lang/String;[I[I[I[Landroid/media/AudioGain;)V"); gAudioPortFields.mHandle = GetFieldIDOrDie(env, audioPortClass, "mHandle", "Landroid/media/AudioHandle;"); gAudioPortFields.mRole = GetFieldIDOrDie(env, audioPortClass, "mRole", "I"); @@ -1594,12 +1604,12 @@ int register_android_media_AudioSystem(JNIEnv *env) jclass audioDevicePortClass = FindClassOrDie(env, "android/media/AudioDevicePort"); gAudioDevicePortClass = MakeGlobalRefOrDie(env, audioDevicePortClass); gAudioDevicePortCstor = GetMethodIDOrDie(env, audioDevicePortClass, "<init>", - "(Landroid/media/AudioHandle;[I[I[I[Landroid/media/AudioGain;ILjava/lang/String;)V"); + "(Landroid/media/AudioHandle;Ljava/lang/String;[I[I[I[Landroid/media/AudioGain;ILjava/lang/String;)V"); jclass audioMixPortClass = FindClassOrDie(env, "android/media/AudioMixPort"); gAudioMixPortClass = MakeGlobalRefOrDie(env, audioMixPortClass); gAudioMixPortCstor = GetMethodIDOrDie(env, audioMixPortClass, "<init>", - "(Landroid/media/AudioHandle;I[I[I[I[Landroid/media/AudioGain;)V"); + "(Landroid/media/AudioHandle;ILjava/lang/String;[I[I[I[Landroid/media/AudioGain;)V"); jclass audioGainClass = FindClassOrDie(env, "android/media/AudioGain"); gAudioGainClass = MakeGlobalRefOrDie(env, audioGainClass); diff --git a/media/java/android/media/AudioDevicePort.java b/media/java/android/media/AudioDevicePort.java index b10736b..82da27d 100644 --- a/media/java/android/media/AudioDevicePort.java +++ b/media/java/android/media/AudioDevicePort.java @@ -36,12 +36,13 @@ public class AudioDevicePort extends AudioPort { private final int mType; private final String mAddress; - AudioDevicePort(AudioHandle handle, int[] samplingRates, int[] channelMasks, + AudioDevicePort(AudioHandle handle, String deviceName, + int[] samplingRates, int[] channelMasks, int[] formats, AudioGain[] gains, int type, String address) { super(handle, (AudioManager.isInputDevice(type) == true) ? AudioPort.ROLE_SOURCE : AudioPort.ROLE_SINK, - samplingRates, channelMasks, formats, gains); + deviceName, samplingRates, channelMasks, formats, gains); mType = type; mAddress = address; } diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 986ae46..912d644 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -3199,10 +3199,10 @@ public class AudioManager { * @param name device name * {@hide} */ - public void setWiredDeviceConnectionState(int device, int state, String name) { + public void setWiredDeviceConnectionState(int type, int state, String address, String name) { IAudioService service = getService(); try { - service.setWiredDeviceConnectionState(device, state, name); + service.setWiredDeviceConnectionState(type, state, address, name); } catch (RemoteException e) { Log.e(TAG, "Dead object in setWiredDeviceConnectionState "+e); } diff --git a/media/java/android/media/AudioMixPort.java b/media/java/android/media/AudioMixPort.java index 1500a43..9fac8d1 100644 --- a/media/java/android/media/AudioMixPort.java +++ b/media/java/android/media/AudioMixPort.java @@ -26,9 +26,10 @@ package android.media; public class AudioMixPort extends AudioPort { - AudioMixPort(AudioHandle handle, int role, int[] samplingRates, int[] channelMasks, + AudioMixPort(AudioHandle handle, int role, String deviceName, + int[] samplingRates, int[] channelMasks, int[] formats, AudioGain[] gains) { - super(handle, role, samplingRates, channelMasks, formats, gains); + super(handle, role, deviceName, samplingRates, channelMasks, formats, gains); } /** diff --git a/media/java/android/media/AudioPort.java b/media/java/android/media/AudioPort.java index 1ab7e89..b046791 100644 --- a/media/java/android/media/AudioPort.java +++ b/media/java/android/media/AudioPort.java @@ -15,7 +15,7 @@ */ package android.media; - +import android.util.Slog; /** * An audio port is a node of the audio framework or hardware that can be connected to or @@ -37,6 +37,7 @@ package android.media; * @hide */ public class AudioPort { + private static final String TAG = "AudioPort"; /** * For use by the audio framework. @@ -68,16 +69,20 @@ public class AudioPort { AudioHandle mHandle; protected final int mRole; + private final String mName; private final int[] mSamplingRates; private final int[] mChannelMasks; private final int[] mFormats; private final AudioGain[] mGains; private AudioPortConfig mActiveConfig; - AudioPort(AudioHandle handle, int role, int[] samplingRates, int[] channelMasks, + AudioPort(AudioHandle handle, int role, String name, + int[] samplingRates, int[] channelMasks, int[] formats, AudioGain[] gains) { + mHandle = handle; mRole = role; + mName = name; mSamplingRates = samplingRates; mChannelMasks = channelMasks; mFormats = formats; @@ -96,6 +101,14 @@ public class AudioPort { } /** + * Get the human-readable name of this port. Perhaps an internal + * designation or an physical device. + */ + public String name() { + return mName; + } + + /** * Get the list of supported sampling rates * Empty array if sampling rate is not relevant for this audio port */ diff --git a/media/java/android/media/AudioRoutesInfo.java b/media/java/android/media/AudioRoutesInfo.java index df9fc06..3e0ec07 100644 --- a/media/java/android/media/AudioRoutesInfo.java +++ b/media/java/android/media/AudioRoutesInfo.java @@ -30,6 +30,7 @@ public class AudioRoutesInfo implements Parcelable { static final int MAIN_HEADPHONES = 1<<1; static final int MAIN_DOCK_SPEAKERS = 1<<2; static final int MAIN_HDMI = 1<<3; + static final int MAIN_USB = 1<<4; CharSequence mBluetoothName; int mMainType = MAIN_SPEAKER; diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 98a43a8..7c07fb5 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -536,6 +536,20 @@ public class AudioService extends IAudioService.Stub { private AudioManagerInternal.RingerModeDelegate mRingerModeDelegate; + // Intent "extra" data keys. + public static final String CONNECT_INTENT_KEY_PORT_NAME = "portName"; + public static final String CONNECT_INTENT_KEY_STATE = "state"; + public static final String CONNECT_INTENT_KEY_ADDRESS = "address"; + public static final String CONNECT_INTENT_KEY_HAS_PLAYBACK = "hasPlayback"; + public static final String CONNECT_INTENT_KEY_HAS_CAPTURE = "hasCapture"; + public static final String CONNECT_INTENT_KEY_HAS_MIDI = "hasMIDI"; + public static final String CONNECT_INTENT_KEY_DEVICE_CLASS = "class"; + + // Defines the format for the connection "address" for ALSA devices + public static String makeAlsaAddressString(int card, int device) { + return "card=" + card + ";device=" + device + ";"; + } + /////////////////////////////////////////////////////////////////////////// // Construction /////////////////////////////////////////////////////////////////////////// @@ -3433,14 +3447,32 @@ public class AudioService extends IAudioService.Stub { return device; } - public void setWiredDeviceConnectionState(int device, int state, String name) { + /* + * A class just for packaging up a set of connection parameters. + */ + private class WiredDeviceConnectionState { + public int mType; + public int mState; + public String mAddress; + public String mName; + + public WiredDeviceConnectionState(int type, int state, String address, String name) { + mType = type; + mState = state; + mAddress = address; + mName = name; + } + } + + public void setWiredDeviceConnectionState(int type, int state, String address, + String name) { synchronized (mConnectedDevices) { - int delay = checkSendBecomingNoisyIntent(device, state); + int delay = checkSendBecomingNoisyIntent(type, state); queueMsgUnderWakeLock(mAudioHandler, MSG_SET_WIRED_DEVICE_CONNECTION_STATE, - device, - state, - name, + 0, + 0, + new WiredDeviceConnectionState(type, state, address, name), delay); } } @@ -4172,7 +4204,8 @@ public class AudioService extends IAudioService.Stub { AudioSystem.setDeviceConnectionState( ((Integer)device.getKey()).intValue(), AudioSystem.DEVICE_STATE_AVAILABLE, - (String)device.getValue()); + (String)device.getValue(), + "unknown-device"); } } // Restore call state @@ -4274,8 +4307,12 @@ public class AudioService extends IAudioService.Stub { break; case MSG_SET_WIRED_DEVICE_CONNECTION_STATE: - onSetWiredDeviceConnectionState(msg.arg1, msg.arg2, (String)msg.obj); - mAudioEventWakeLock.release(); + { WiredDeviceConnectionState connectState = + (WiredDeviceConnectionState)msg.obj; + onSetWiredDeviceConnectionState(connectState.mType, connectState.mState, + connectState.mAddress, connectState.mName); + mAudioEventWakeLock.release(); + } break; case MSG_SET_A2DP_SRC_CONNECTION_STATE: @@ -4388,7 +4425,8 @@ public class AudioService extends IAudioService.Stub { setBluetoothA2dpOnInt(true); AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, AudioSystem.DEVICE_STATE_AVAILABLE, - address); + address, + "a2dp-device"); // Reset A2DP suspend state each time a new sink is connected AudioSystem.setParameters("A2dpSuspended=false"); mConnectedDevices.put( new Integer(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP), @@ -4406,7 +4444,8 @@ public class AudioService extends IAudioService.Stub { } AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, AudioSystem.DEVICE_STATE_UNAVAILABLE, - address); + address, + "a2dp-device"); mConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP); synchronized (mCurAudioRoutes) { // Remove A2DP routes as well @@ -4435,7 +4474,8 @@ public class AudioService extends IAudioService.Stub { private void makeA2dpSrcAvailable(String address) { AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP, AudioSystem.DEVICE_STATE_AVAILABLE, - address); + address, + "a2dp-device"); mConnectedDevices.put( new Integer(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP), address); } @@ -4444,7 +4484,8 @@ public class AudioService extends IAudioService.Stub { private void makeA2dpSrcUnavailable(String address) { AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP, AudioSystem.DEVICE_STATE_UNAVAILABLE, - address); + address, + "a2dp-device"); mConnectedDevices.remove(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP); } @@ -4560,22 +4601,26 @@ public class AudioService extends IAudioService.Stub { } } - private boolean handleDeviceConnection(boolean connected, int device, String params) { + private boolean handleDeviceConnection(boolean connect, int device, String address, String deviceName) { + Slog.i(TAG, "handleDeviceConnection(" + connect + + " dev:" + Integer.toHexString(device) + + " address:" + address + + " name:" + deviceName + ")"); synchronized (mConnectedDevices) { boolean isConnected = (mConnectedDevices.containsKey(device) && - (params.isEmpty() || mConnectedDevices.get(device).equals(params))); + (address.isEmpty() || mConnectedDevices.get(device).equals(address))); - if (isConnected && !connected) { + if (isConnected && !connect) { AudioSystem.setDeviceConnectionState(device, AudioSystem.DEVICE_STATE_UNAVAILABLE, - mConnectedDevices.get(device)); + address, deviceName); mConnectedDevices.remove(device); return true; - } else if (!isConnected && connected) { + } else if (!isConnected && connect) { AudioSystem.setDeviceConnectionState(device, AudioSystem.DEVICE_STATE_AVAILABLE, - params); - mConnectedDevices.put(new Integer(device), params); + address, deviceName); + mConnectedDevices.put(new Integer(device), address); return true; } } @@ -4628,12 +4673,18 @@ public class AudioService extends IAudioService.Stub { return delay; } - private void sendDeviceConnectionIntent(int device, int state, String name) + private void sendDeviceConnectionIntent(int device, int state, String address, String deviceName) { + Slog.i(TAG, "sendDeviceConnectionIntent(dev:0x" + Integer.toHexString(device) + + " state:0x" + Integer.toHexString(state) + + " address:" + address + + " name:" + deviceName + ");"); Intent intent = new Intent(); - intent.putExtra("state", state); - intent.putExtra("name", name); + intent.putExtra(CONNECT_INTENT_KEY_STATE, state); + intent.putExtra(CONNECT_INTENT_KEY_ADDRESS, address); + intent.putExtra(CONNECT_INTENT_KEY_PORT_NAME, deviceName); + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); int connType = 0; @@ -4652,6 +4703,8 @@ public class AudioService extends IAudioService.Stub { device == AudioSystem.DEVICE_OUT_HDMI_ARC) { connType = AudioRoutesInfo.MAIN_HDMI; configureHdmiPlugIntent(intent, state); + } else if (device == AudioSystem.DEVICE_OUT_USB_DEVICE) { + connType = AudioRoutesInfo.MAIN_USB; } synchronized (mCurAudioRoutes) { @@ -4678,8 +4731,14 @@ public class AudioService extends IAudioService.Stub { } } - private void onSetWiredDeviceConnectionState(int device, int state, String name) + private void onSetWiredDeviceConnectionState(int device, int state, String address, + String deviceName) { + Slog.i(TAG, "onSetWiredDeviceConnectionState(dev:" + Integer.toHexString(device) + + " state:" + Integer.toHexString(state) + + " address:" + address + + " deviceName:" + deviceName + ");"); + synchronized (mConnectedDevices) { if ((state == 0) && ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) || (device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE) || @@ -4689,7 +4748,7 @@ public class AudioService extends IAudioService.Stub { boolean isUsb = ((device & ~AudioSystem.DEVICE_OUT_ALL_USB) == 0) || (((device & AudioSystem.DEVICE_BIT_IN) != 0) && ((device & ~AudioSystem.DEVICE_IN_ALL_USB) == 0)); - handleDeviceConnection((state == 1), device, (isUsb ? name : "")); + handleDeviceConnection(state == 1, device, address, deviceName); if (state != 0) { if ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) || (device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE) || @@ -4727,8 +4786,8 @@ public class AudioService extends IAudioService.Stub { } } } - if (!isUsb && (device != AudioSystem.DEVICE_IN_WIRED_HEADSET)) { - sendDeviceConnectionIntent(device, state, name); + if (!isUsb && device != AudioSystem.DEVICE_IN_WIRED_HEADSET) { + sendDeviceConnectionIntent(device, state, address, deviceName); } } } @@ -4852,8 +4911,9 @@ public class AudioService extends IAudioService.Stub { } boolean connected = (state == BluetoothProfile.STATE_CONNECTED); - boolean success = handleDeviceConnection(connected, outDevice, address) && - handleDeviceConnection(connected, inDevice, address); + boolean success = + handleDeviceConnection(connected, outDevice, address, "Bluetooth Headset") && + handleDeviceConnection(connected, inDevice, address, "Bluetooth Headset"); if (success) { synchronized (mScoClients) { if (connected) { diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index 46ab7e0..7084656 100644 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -534,7 +534,8 @@ public class AudioSystem public static final int SYNC_EVENT_NONE = 0; public static final int SYNC_EVENT_PRESENTATION_COMPLETE = 1; - public static native int setDeviceConnectionState(int device, int state, String device_address); + public static native int setDeviceConnectionState(int device, int state, + String device_address, String device_name); public static native int getDeviceConnectionState(int device, String device_address); public static native int setPhoneState(int state); public static native int setForceUse(int usage, int config); diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl index bfb78a1..dabd9c2 100644 --- a/media/java/android/media/IAudioService.aidl +++ b/media/java/android/media/IAudioService.aidl @@ -189,7 +189,7 @@ interface IAudioService { IRingtonePlayer getRingtonePlayer(); int getMasterStreamType(); - void setWiredDeviceConnectionState(int device, int state, String name); + void setWiredDeviceConnectionState(int type, int state, String address, String name); int setBluetoothA2dpDeviceConnectionState(in BluetoothDevice device, int state, int profile); AudioRoutesInfo startWatchingRoutes(in IAudioRoutesObserver observer); diff --git a/services/core/java/com/android/server/WiredAccessoryManager.java b/services/core/java/com/android/server/WiredAccessoryManager.java index bffbb4c2..c9a83ec 100644 --- a/services/core/java/com/android/server/WiredAccessoryManager.java +++ b/services/core/java/com/android/server/WiredAccessoryManager.java @@ -219,6 +219,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { mWakeLock.acquire(); + Log.i(TAG, "MSG_NEW_DEVICE_STATE "); Message msg = mHandler.obtainMessage(MSG_NEW_DEVICE_STATE, headsetState, mHeadsetState, newName); mHandler.sendMessage(msg); @@ -286,14 +287,16 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { return; } - if (LOG) - Slog.v(TAG, "device "+headsetName+((state == 1) ? " connected" : " disconnected")); + if (LOG) { + Slog.v(TAG, "headsetName: " + headsetName + + (state == 1 ? " connected" : " disconnected")); + } if (outDevice != 0) { - mAudioManager.setWiredDeviceConnectionState(outDevice, state, headsetName); + mAudioManager.setWiredDeviceConnectionState(outDevice, state, "", headsetName); } if (inDevice != 0) { - mAudioManager.setWiredDeviceConnectionState(inDevice, state, headsetName); + mAudioManager.setWiredDeviceConnectionState(inDevice, state, "", headsetName); } } } diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java index 8241cdc..4f458e6 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java @@ -904,7 +904,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice { // Note that we don't set any name to ARC. mService.getAudioManager().setWiredDeviceConnectionState( AudioSystem.DEVICE_OUT_HDMI_ARC, - enabled ? 1 : 0, ""); + enabled ? 1 : 0, "", ""); } /** diff --git a/services/usb/java/com/android/server/usb/UsbAlsaManager.java b/services/usb/java/com/android/server/usb/UsbAlsaManager.java index b508c89..9d13d3c 100644 --- a/services/usb/java/com/android/server/usb/UsbAlsaManager.java +++ b/services/usb/java/com/android/server/usb/UsbAlsaManager.java @@ -24,6 +24,7 @@ import android.content.res.Resources; import android.hardware.usb.UsbConstants; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbInterface; +import android.media.AudioService; import android.media.AudioSystem; import android.media.IAudioService; import android.midi.MidiDeviceInfo; @@ -179,15 +180,16 @@ public final class UsbAlsaManager { " alsaDevice: " + alsaDevice); return; } - String params = ("card=" + alsaCard + ";device=" + alsaDevice); + String address = AudioService.makeAlsaAddressString(alsaCard, alsaDevice); try { // Playback Device if (audioDevice.mHasPlayback) { int device = (audioDevice == mAccessoryAudioDevice ? AudioSystem.DEVICE_OUT_USB_ACCESSORY : AudioSystem.DEVICE_OUT_USB_DEVICE); - mAudioService.setWiredDeviceConnectionState(device, state, params); + mAudioService.setWiredDeviceConnectionState( + device, state, address, audioDevice.mDeviceName); } // Capture Device @@ -195,7 +197,8 @@ public final class UsbAlsaManager { int device = (audioDevice == mAccessoryAudioDevice ? AudioSystem.DEVICE_IN_USB_ACCESSORY : AudioSystem.DEVICE_IN_USB_DEVICE); - mAudioService.setWiredDeviceConnectionState(device, state, params); + mAudioService.setWiredDeviceConnectionState( + device, state, address, audioDevice.mDeviceName); } } catch (RemoteException e) { Slog.e(TAG, "RemoteException in setWiredDeviceConnectionState"); diff --git a/services/usb/java/com/android/server/usb/UsbAudioDevice.java b/services/usb/java/com/android/server/usb/UsbAudioDevice.java index 069d917..bdd28e4 100644 --- a/services/usb/java/com/android/server/usb/UsbAudioDevice.java +++ b/services/usb/java/com/android/server/usb/UsbAudioDevice.java @@ -53,7 +53,6 @@ public final class UsbAudioDevice { sb.append("UsbAudioDevice: [card: " + mCard); sb.append(", device: " + mDevice); sb.append(", name: " + mDeviceName); - sb.append(", description: " + mDeviceDescription); sb.append(", hasPlayback: " + mHasPlayback); sb.append(", hasCapture: " + mHasCapture); sb.append(", class: 0x" + Integer.toHexString(mDeviceClass) + "]"); |