From 9189f5f0252e1ef3e7d00978ef12e964565dd6f1 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Thu, 9 Apr 2015 17:51:32 -0700 Subject: [PATCH 1/2] Add MidiDeviceInfo.getPortList() This replaces MidiDeviceInfo.getInputPortInfo() and getOutputPortInfo() Change-Id: I0a9bc7c34a172a072e86718d465967c6c618fb3b --- api/current.txt | 3 +- api/system-current.txt | 3 +- .../android/media/midi/MidiDeviceInfo.java | 32 ++++++++----------- .../android/media/midi/MidiDeviceService.java | 2 +- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/api/current.txt b/api/current.txt index a13ff67aed1da..e2551987668bd 100644 --- a/api/current.txt +++ b/api/current.txt @@ -16762,9 +16762,8 @@ package android.media.midi { method public int describeContents(); method public int getId(); method public int getInputPortCount(); - method public android.media.midi.MidiDeviceInfo.PortInfo getInputPortInfo(int); method public int getOutputPortCount(); - method public android.media.midi.MidiDeviceInfo.PortInfo getOutputPortInfo(int); + method public android.media.midi.MidiDeviceInfo.PortInfo[] getPortList(); method public android.os.Bundle getProperties(); method public int getType(); method public boolean isPrivate(); diff --git a/api/system-current.txt b/api/system-current.txt index 310de535fe000..106f141cd901c 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -18038,9 +18038,8 @@ package android.media.midi { method public int describeContents(); method public int getId(); method public int getInputPortCount(); - method public android.media.midi.MidiDeviceInfo.PortInfo getInputPortInfo(int); method public int getOutputPortCount(); - method public android.media.midi.MidiDeviceInfo.PortInfo getOutputPortInfo(int); + method public android.media.midi.MidiDeviceInfo.PortInfo[] getPortList(); method public android.os.Bundle getProperties(); method public int getType(); method public boolean isPrivate(); diff --git a/media/java/android/media/midi/MidiDeviceInfo.java b/media/java/android/media/midi/MidiDeviceInfo.java index 7201e25dac23c..af108eb308e66 100644 --- a/media/java/android/media/midi/MidiDeviceInfo.java +++ b/media/java/android/media/midi/MidiDeviceInfo.java @@ -237,29 +237,23 @@ public final class MidiDeviceInfo implements Parcelable { } /** - * Returns information about an input port. + * Returns information about the device's ports. + * The ports are in unspecified order. * - * @param portNumber the number of the input port - * @return the input port's information object + * @return array of {@link PortInfo} */ - public PortInfo getInputPortInfo(int portNumber) { - if (portNumber < 0 || portNumber >= mInputPortCount) { - throw new IllegalArgumentException("portNumber out of range"); - } - return new PortInfo(PortInfo.TYPE_INPUT, portNumber, mInputPortNames[portNumber]); - } + public PortInfo[] getPortList() { + PortInfo[] portInfoList = new PortInfo[mInputPortCount + mOutputPortCount]; - /** - * Returns information about an output port. - * - * @param portNumber the number of the output port - * @return the output port's information object - */ - public PortInfo getOutputPortInfo(int portNumber) { - if (portNumber < 0 || portNumber >= mOutputPortCount) { - throw new IllegalArgumentException("portNumber out of range"); + int index = 0; + for (int i = 0; i < mInputPortCount; i++) { + portInfoList[index++] = new PortInfo(PortInfo.TYPE_INPUT, i, mInputPortNames[i]); } - return new PortInfo(PortInfo.TYPE_OUTPUT, portNumber, mOutputPortNames[portNumber]); + for (int i = 0; i < mOutputPortCount; i++) { + portInfoList[index++] = new PortInfo(PortInfo.TYPE_OUTPUT, i, mOutputPortNames[i]); + } + + return portInfoList; } /** diff --git a/media/java/android/media/midi/MidiDeviceService.java b/media/java/android/media/midi/MidiDeviceService.java index 8b1de3e7dbffd..ce12a4f53339e 100644 --- a/media/java/android/media/midi/MidiDeviceService.java +++ b/media/java/android/media/midi/MidiDeviceService.java @@ -91,7 +91,7 @@ abstract public class MidiDeviceService extends Service { /** * Returns an array of {@link MidiReceiver} for the device's input ports. * Subclasses must override this to provide the receivers which will receive - * data sent to the device's input ports. An empty array or null should be returned if + * data sent to the device's input ports. An empty array should be returned if * the device has no input ports. * @return array of MidiReceivers */ From dee5f1bb6e42875a1134d0e8efeef528b92cc548 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Fri, 10 Apr 2015 08:25:55 -0700 Subject: [PATCH 2/2] Add user visible name for USB peripheral MIDI device Change-Id: I075a54dc3890bc5cf3927cecba3750e1d342d290 --- core/res/res/values/strings.xml | 6 ++++-- core/res/res/values/symbols.xml | 3 ++- .../usb/java/com/android/server/usb/UsbAlsaManager.java | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index a48e9648c7e10..601f01a8d4d6b 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -5232,10 +5232,12 @@ SS request is modified to USSD request. SS request is modified to new SS request. + + Android USB Peripheral Port Android - - USB Peripheral Port + + USB Peripheral Port diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index c2c00b5bdcc3d..4f1980f296ec2 100755 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2182,8 +2182,9 @@ + - + diff --git a/services/usb/java/com/android/server/usb/UsbAlsaManager.java b/services/usb/java/com/android/server/usb/UsbAlsaManager.java index 2728af118767a..8f0c6c8f27c5b 100644 --- a/services/usb/java/com/android/server/usb/UsbAlsaManager.java +++ b/services/usb/java/com/android/server/usb/UsbAlsaManager.java @@ -469,10 +469,12 @@ public final class UsbAlsaManager { if (enabled && mPeripheralMidiDevice == null) { Bundle properties = new Bundle(); Resources r = mContext.getResources(); + properties.putString(MidiDeviceInfo.PROPERTY_NAME, r.getString( + com.android.internal.R.string.usb_midi_peripheral_name)); properties.putString(MidiDeviceInfo.PROPERTY_MANUFACTURER, r.getString( com.android.internal.R.string.usb_midi_peripheral_manufacturer_name)); properties.putString(MidiDeviceInfo.PROPERTY_PRODUCT, r.getString( - com.android.internal.R.string.usb_midi_peripheral_model_name)); + com.android.internal.R.string.usb_midi_peripheral_product_name)); properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_CARD, card); properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_DEVICE, device); mPeripheralMidiDevice = UsbMidiDevice.create(mContext, properties, card, device);