Loading media/java/android/media/midi/IMidiManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,8 @@ interface IMidiManager // for registering built-in MIDI devices MidiDeviceInfo registerDeviceServer(in IMidiDeviceServer server, int numInputPorts, int numOutputPorts, in Bundle properties, int type); int numOutputPorts, in String[] inputPortNames, in String[] outputPortNames, in Bundle properties, int type); // for unregistering built-in MIDI devices void unregisterDeviceServer(in IMidiDeviceServer server); Loading media/java/android/media/midi/MidiDeviceInfo.java +102 −10 Original line number Diff line number Diff line Loading @@ -45,12 +45,12 @@ public final class MidiDeviceInfo implements Parcelable { */ public static final int TYPE_VIRTUAL = 2; private final int mType; // USB or virtual private final int mId; // unique ID generated by MidiService private final int mInputPortCount; private final int mOutputPortCount; private final Bundle mProperties; private final boolean mIsPrivate; /** * Bundle key for the device's user visible name property. * Used with the {@link android.os.Bundle} returned by {@link #getProperties}. * For USB devices, this is a concatenation of the manufacturer and product names. */ public static final String PROPERTY_NAME = "name"; /** * Bundle key for the device's manufacturer name property. Loading @@ -60,11 +60,11 @@ public final class MidiDeviceInfo implements Parcelable { public static final String PROPERTY_MANUFACTURER = "manufacturer"; /** * Bundle key for the device's model name property. * Bundle key for the device's product name property. * Used with the {@link android.os.Bundle} returned by {@link #getProperties} * Matches the USB device product name string for USB MIDI devices. */ public static final String PROPERTY_MODEL = "model"; public static final String PROPERTY_PRODUCT = "product"; /** * Bundle key for the device's serial number property. Loading Loading @@ -107,16 +107,77 @@ public final class MidiDeviceInfo implements Parcelable { */ public static final String PROPERTY_SERVICE_INFO = "service_info"; /** * Contains information about an input or output port. */ public static final class PortInfo { /** * Port type for input ports */ public static final int TYPE_INPUT = 1; /** * Port type for output ports */ public static final int TYPE_OUTPUT = 2; private final int mPortType; private final int mPortNumber; private final String mName; PortInfo(int type, int portNumber, String name) { mPortType = type; mPortNumber = portNumber; mName = (name == null ? "" : name); } /** * Returns the port type of the port (either {@link #TYPE_INPUT} or {@link #TYPE_OUTPUT}) * @return the port type */ public int getType() { return mPortType; } /** * Returns the port number of the port * @return the port number */ public int getPortNumber() { return mPortNumber; } /** * Returns the name of the port, or empty string if the port has no name * @return the port name */ public String getName() { return mName; } } private final int mType; // USB or virtual private final int mId; // unique ID generated by MidiService private final int mInputPortCount; private final int mOutputPortCount; private final String[] mInputPortNames; private final String[] mOutputPortNames; private final Bundle mProperties; private final boolean mIsPrivate; /** * MidiDeviceInfo should only be instantiated by MidiService implementation * @hide */ public MidiDeviceInfo(int type, int id, int numInputPorts, int numOutputPorts, Bundle properties, boolean isPrivate) { String[] inputPortNames, String[] outputPortNames, Bundle properties, boolean isPrivate) { mType = type; mId = id; mInputPortCount = numInputPorts; mOutputPortCount = numOutputPorts; mInputPortNames = inputPortNames; mOutputPortNames = outputPortNames; mProperties = properties; mIsPrivate = isPrivate; } Loading Loading @@ -158,6 +219,32 @@ public final class MidiDeviceInfo implements Parcelable { return mOutputPortCount; } /** * Returns information about an input port. * * @param portNumber the number of the input port * @return the input port's information object */ 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]); } /** * 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"); } return new PortInfo(PortInfo.TYPE_OUTPUT, portNumber, mOutputPortNames[portNumber]); } /** * Returns the {@link android.os.Bundle} containing the device's properties. * Loading Loading @@ -207,9 +294,12 @@ public final class MidiDeviceInfo implements Parcelable { int id = in.readInt(); int inputPorts = in.readInt(); int outputPorts = in.readInt(); String[] inputPortNames = in.createStringArray(); String[] outputPortNames = in.createStringArray(); Bundle properties = in.readBundle(); boolean isPrivate = (in.readInt() == 1); return new MidiDeviceInfo(type, id, inputPorts, outputPorts, properties, isPrivate); return new MidiDeviceInfo(type, id, inputPorts, outputPorts, inputPortNames, outputPortNames, properties, isPrivate); } public MidiDeviceInfo[] newArray(int size) { Loading @@ -226,6 +316,8 @@ public final class MidiDeviceInfo implements Parcelable { parcel.writeInt(mId); parcel.writeInt(mInputPortCount); parcel.writeInt(mOutputPortCount); parcel.writeStringArray(mInputPortNames); parcel.writeStringArray(mOutputPortNames); parcel.writeBundle(mProperties); parcel.writeInt(mIsPrivate ? 1 : 0); } Loading media/java/android/media/midi/MidiManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -277,12 +277,14 @@ public final class MidiManager { /** @hide */ public MidiDeviceServer createDeviceServer(MidiReceiver[] inputPortReceivers, int numOutputPorts, Bundle properties, int type, MidiDeviceServer.Callback callback) { int numOutputPorts, String[] inputPortNames, String[] outputPortNames, Bundle properties, int type, MidiDeviceServer.Callback callback) { try { MidiDeviceServer server = new MidiDeviceServer(mService, inputPortReceivers, numOutputPorts, callback); MidiDeviceInfo deviceInfo = mService.registerDeviceServer(server.getBinderInterface(), inputPortReceivers.length, numOutputPorts, properties, type); inputPortReceivers.length, numOutputPorts, inputPortNames, outputPortNames, properties, type); if (deviceInfo == null) { Log.e(TAG, "registerVirtualDevice failed"); return null; Loading services/core/java/com/android/server/MidiService.java +44 −10 Original line number Diff line number Diff line Loading @@ -316,6 +316,8 @@ public class MidiService extends IMidiManager.Stub { client.removeListener(listener); } private static final MidiDeviceInfo[] EMPTY_DEVICE_INFO_ARRAY = new MidiDeviceInfo[0]; public MidiDeviceInfo[] getDeviceList() { ArrayList<MidiDeviceInfo> deviceInfos = new ArrayList<MidiDeviceInfo>(); int uid = Binder.getCallingUid(); Loading @@ -328,7 +330,7 @@ public class MidiService extends IMidiManager.Stub { } } return deviceInfos.toArray(new MidiDeviceInfo[0]); return deviceInfos.toArray(EMPTY_DEVICE_INFO_ARRAY); } @Override Loading @@ -348,15 +350,16 @@ public class MidiService extends IMidiManager.Stub { @Override public MidiDeviceInfo registerDeviceServer(IMidiDeviceServer server, int numInputPorts, int numOutputPorts, Bundle properties, int type) { int numOutputPorts, String[] inputPortNames, String[] outputPortNames, Bundle properties, int type) { int uid = Binder.getCallingUid(); if (type != MidiDeviceInfo.TYPE_VIRTUAL && uid != Process.SYSTEM_UID) { throw new SecurityException("only system can create non-virtual devices"); } synchronized (mDevicesByInfo) { return addDeviceLocked(type, numInputPorts, numOutputPorts, properties, server, null, false, uid); return addDeviceLocked(type, numInputPorts, numOutputPorts, inputPortNames, outputPortNames, properties, server, null, false, uid); } } Loading Loading @@ -420,12 +423,13 @@ public class MidiService extends IMidiManager.Stub { // synchronize on mDevicesByInfo private MidiDeviceInfo addDeviceLocked(int type, int numInputPorts, int numOutputPorts, Bundle properties, IMidiDeviceServer server, ServiceInfo serviceInfo, String[] inputPortNames, String[] outputPortNames, Bundle properties, IMidiDeviceServer server, ServiceInfo serviceInfo, boolean isPrivate, int uid) { int id = mNextDeviceId++; MidiDeviceInfo deviceInfo = new MidiDeviceInfo(type, id, numInputPorts, numOutputPorts, properties, isPrivate); inputPortNames, outputPortNames, properties, isPrivate); Device device = new Device(server, deviceInfo, serviceInfo, uid); if (server != null) { Loading Loading @@ -482,6 +486,8 @@ public class MidiService extends IMidiManager.Stub { } } private static final String[] EMPTY_STRING_ARRAY = new String[0]; private void addPackageDeviceServer(ServiceInfo serviceInfo) { XmlResourceParser parser = null; Loading @@ -494,6 +500,8 @@ public class MidiService extends IMidiManager.Stub { int numInputPorts = 0; int numOutputPorts = 0; boolean isPrivate = false; ArrayList<String> inputPortNames = new ArrayList<String>(); ArrayList<String> outputPortNames = new ArrayList<String>(); while (true) { int eventType = parser.next(); Loading Loading @@ -530,7 +538,18 @@ public class MidiService extends IMidiManager.Stub { continue; } numInputPorts++; // TODO - add support for port properties String portName = null; int count = parser.getAttributeCount(); for (int i = 0; i < count; i++) { String name = parser.getAttributeName(i); String value = parser.getAttributeValue(i); if ("name".equals(name)) { portName = value; break; } } inputPortNames.add(portName); } else if ("output-port".equals(tagName)) { if (properties == null) { Log.w(TAG, "<output-port> outside of <device> in metadata for " Loading @@ -538,7 +557,18 @@ public class MidiService extends IMidiManager.Stub { continue; } numOutputPorts++; // TODO - add support for port properties String portName = null; int count = parser.getAttributeCount(); for (int i = 0; i < count; i++) { String name = parser.getAttributeName(i); String value = parser.getAttributeValue(i); if ("name".equals(name)) { portName = value; break; } } outputPortNames.add(portName); } } else if (eventType == XmlPullParser.END_TAG) { String tagName = parser.getName(); Loading @@ -563,12 +593,16 @@ public class MidiService extends IMidiManager.Stub { synchronized (mDevicesByInfo) { addDeviceLocked(MidiDeviceInfo.TYPE_VIRTUAL, numInputPorts, numOutputPorts, properties, null, serviceInfo, isPrivate, uid); numInputPorts, numOutputPorts, inputPortNames.toArray(EMPTY_STRING_ARRAY), outputPortNames.toArray(EMPTY_STRING_ARRAY), properties, null, serviceInfo, isPrivate, uid); } // setting properties to null signals that we are no longer // processing a <device> properties = null; inputPortNames.clear(); outputPortNames.clear(); } } } Loading services/usb/java/com/android/server/usb/UsbAlsaManager.java +14 −4 Original line number Diff line number Diff line Loading @@ -394,9 +394,19 @@ public final class UsbAlsaManager { AlsaDevice alsaDevice = waitForAlsaDevice(addedCard, device, AlsaDevice.TYPE_MIDI); if (alsaDevice != null) { Bundle properties = new Bundle(); properties.putString(MidiDeviceInfo.PROPERTY_MANUFACTURER, usbDevice.getManufacturerName()); properties.putString(MidiDeviceInfo.PROPERTY_MODEL, usbDevice.getProductName()); String manufacturer = usbDevice.getManufacturerName(); String product = usbDevice.getProductName(); String name; if (manufacturer == null || manufacturer.isEmpty()) { name = product; } else if (product == null || product.isEmpty()) { name = manufacturer; } else { name = manufacturer + " " + product; } properties.putString(MidiDeviceInfo.PROPERTY_NAME, name); properties.putString(MidiDeviceInfo.PROPERTY_MANUFACTURER, manufacturer); properties.putString(MidiDeviceInfo.PROPERTY_PRODUCT, product); properties.putString(MidiDeviceInfo.PROPERTY_SERIAL_NUMBER, usbDevice.getSerialNumber()); properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_CARD, alsaDevice.mCard); Loading Loading @@ -454,7 +464,7 @@ public final class UsbAlsaManager { Resources r = mContext.getResources(); properties.putString(MidiDeviceInfo.PROPERTY_MANUFACTURER, r.getString( com.android.internal.R.string.usb_midi_peripheral_manufacturer_name)); properties.putString(MidiDeviceInfo.PROPERTY_MODEL, r.getString( properties.putString(MidiDeviceInfo.PROPERTY_PRODUCT, r.getString( com.android.internal.R.string.usb_midi_peripheral_model_name)); properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_CARD, card); properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_DEVICE, device); Loading Loading
media/java/android/media/midi/IMidiManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,8 @@ interface IMidiManager // for registering built-in MIDI devices MidiDeviceInfo registerDeviceServer(in IMidiDeviceServer server, int numInputPorts, int numOutputPorts, in Bundle properties, int type); int numOutputPorts, in String[] inputPortNames, in String[] outputPortNames, in Bundle properties, int type); // for unregistering built-in MIDI devices void unregisterDeviceServer(in IMidiDeviceServer server); Loading
media/java/android/media/midi/MidiDeviceInfo.java +102 −10 Original line number Diff line number Diff line Loading @@ -45,12 +45,12 @@ public final class MidiDeviceInfo implements Parcelable { */ public static final int TYPE_VIRTUAL = 2; private final int mType; // USB or virtual private final int mId; // unique ID generated by MidiService private final int mInputPortCount; private final int mOutputPortCount; private final Bundle mProperties; private final boolean mIsPrivate; /** * Bundle key for the device's user visible name property. * Used with the {@link android.os.Bundle} returned by {@link #getProperties}. * For USB devices, this is a concatenation of the manufacturer and product names. */ public static final String PROPERTY_NAME = "name"; /** * Bundle key for the device's manufacturer name property. Loading @@ -60,11 +60,11 @@ public final class MidiDeviceInfo implements Parcelable { public static final String PROPERTY_MANUFACTURER = "manufacturer"; /** * Bundle key for the device's model name property. * Bundle key for the device's product name property. * Used with the {@link android.os.Bundle} returned by {@link #getProperties} * Matches the USB device product name string for USB MIDI devices. */ public static final String PROPERTY_MODEL = "model"; public static final String PROPERTY_PRODUCT = "product"; /** * Bundle key for the device's serial number property. Loading Loading @@ -107,16 +107,77 @@ public final class MidiDeviceInfo implements Parcelable { */ public static final String PROPERTY_SERVICE_INFO = "service_info"; /** * Contains information about an input or output port. */ public static final class PortInfo { /** * Port type for input ports */ public static final int TYPE_INPUT = 1; /** * Port type for output ports */ public static final int TYPE_OUTPUT = 2; private final int mPortType; private final int mPortNumber; private final String mName; PortInfo(int type, int portNumber, String name) { mPortType = type; mPortNumber = portNumber; mName = (name == null ? "" : name); } /** * Returns the port type of the port (either {@link #TYPE_INPUT} or {@link #TYPE_OUTPUT}) * @return the port type */ public int getType() { return mPortType; } /** * Returns the port number of the port * @return the port number */ public int getPortNumber() { return mPortNumber; } /** * Returns the name of the port, or empty string if the port has no name * @return the port name */ public String getName() { return mName; } } private final int mType; // USB or virtual private final int mId; // unique ID generated by MidiService private final int mInputPortCount; private final int mOutputPortCount; private final String[] mInputPortNames; private final String[] mOutputPortNames; private final Bundle mProperties; private final boolean mIsPrivate; /** * MidiDeviceInfo should only be instantiated by MidiService implementation * @hide */ public MidiDeviceInfo(int type, int id, int numInputPorts, int numOutputPorts, Bundle properties, boolean isPrivate) { String[] inputPortNames, String[] outputPortNames, Bundle properties, boolean isPrivate) { mType = type; mId = id; mInputPortCount = numInputPorts; mOutputPortCount = numOutputPorts; mInputPortNames = inputPortNames; mOutputPortNames = outputPortNames; mProperties = properties; mIsPrivate = isPrivate; } Loading Loading @@ -158,6 +219,32 @@ public final class MidiDeviceInfo implements Parcelable { return mOutputPortCount; } /** * Returns information about an input port. * * @param portNumber the number of the input port * @return the input port's information object */ 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]); } /** * 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"); } return new PortInfo(PortInfo.TYPE_OUTPUT, portNumber, mOutputPortNames[portNumber]); } /** * Returns the {@link android.os.Bundle} containing the device's properties. * Loading Loading @@ -207,9 +294,12 @@ public final class MidiDeviceInfo implements Parcelable { int id = in.readInt(); int inputPorts = in.readInt(); int outputPorts = in.readInt(); String[] inputPortNames = in.createStringArray(); String[] outputPortNames = in.createStringArray(); Bundle properties = in.readBundle(); boolean isPrivate = (in.readInt() == 1); return new MidiDeviceInfo(type, id, inputPorts, outputPorts, properties, isPrivate); return new MidiDeviceInfo(type, id, inputPorts, outputPorts, inputPortNames, outputPortNames, properties, isPrivate); } public MidiDeviceInfo[] newArray(int size) { Loading @@ -226,6 +316,8 @@ public final class MidiDeviceInfo implements Parcelable { parcel.writeInt(mId); parcel.writeInt(mInputPortCount); parcel.writeInt(mOutputPortCount); parcel.writeStringArray(mInputPortNames); parcel.writeStringArray(mOutputPortNames); parcel.writeBundle(mProperties); parcel.writeInt(mIsPrivate ? 1 : 0); } Loading
media/java/android/media/midi/MidiManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -277,12 +277,14 @@ public final class MidiManager { /** @hide */ public MidiDeviceServer createDeviceServer(MidiReceiver[] inputPortReceivers, int numOutputPorts, Bundle properties, int type, MidiDeviceServer.Callback callback) { int numOutputPorts, String[] inputPortNames, String[] outputPortNames, Bundle properties, int type, MidiDeviceServer.Callback callback) { try { MidiDeviceServer server = new MidiDeviceServer(mService, inputPortReceivers, numOutputPorts, callback); MidiDeviceInfo deviceInfo = mService.registerDeviceServer(server.getBinderInterface(), inputPortReceivers.length, numOutputPorts, properties, type); inputPortReceivers.length, numOutputPorts, inputPortNames, outputPortNames, properties, type); if (deviceInfo == null) { Log.e(TAG, "registerVirtualDevice failed"); return null; Loading
services/core/java/com/android/server/MidiService.java +44 −10 Original line number Diff line number Diff line Loading @@ -316,6 +316,8 @@ public class MidiService extends IMidiManager.Stub { client.removeListener(listener); } private static final MidiDeviceInfo[] EMPTY_DEVICE_INFO_ARRAY = new MidiDeviceInfo[0]; public MidiDeviceInfo[] getDeviceList() { ArrayList<MidiDeviceInfo> deviceInfos = new ArrayList<MidiDeviceInfo>(); int uid = Binder.getCallingUid(); Loading @@ -328,7 +330,7 @@ public class MidiService extends IMidiManager.Stub { } } return deviceInfos.toArray(new MidiDeviceInfo[0]); return deviceInfos.toArray(EMPTY_DEVICE_INFO_ARRAY); } @Override Loading @@ -348,15 +350,16 @@ public class MidiService extends IMidiManager.Stub { @Override public MidiDeviceInfo registerDeviceServer(IMidiDeviceServer server, int numInputPorts, int numOutputPorts, Bundle properties, int type) { int numOutputPorts, String[] inputPortNames, String[] outputPortNames, Bundle properties, int type) { int uid = Binder.getCallingUid(); if (type != MidiDeviceInfo.TYPE_VIRTUAL && uid != Process.SYSTEM_UID) { throw new SecurityException("only system can create non-virtual devices"); } synchronized (mDevicesByInfo) { return addDeviceLocked(type, numInputPorts, numOutputPorts, properties, server, null, false, uid); return addDeviceLocked(type, numInputPorts, numOutputPorts, inputPortNames, outputPortNames, properties, server, null, false, uid); } } Loading Loading @@ -420,12 +423,13 @@ public class MidiService extends IMidiManager.Stub { // synchronize on mDevicesByInfo private MidiDeviceInfo addDeviceLocked(int type, int numInputPorts, int numOutputPorts, Bundle properties, IMidiDeviceServer server, ServiceInfo serviceInfo, String[] inputPortNames, String[] outputPortNames, Bundle properties, IMidiDeviceServer server, ServiceInfo serviceInfo, boolean isPrivate, int uid) { int id = mNextDeviceId++; MidiDeviceInfo deviceInfo = new MidiDeviceInfo(type, id, numInputPorts, numOutputPorts, properties, isPrivate); inputPortNames, outputPortNames, properties, isPrivate); Device device = new Device(server, deviceInfo, serviceInfo, uid); if (server != null) { Loading Loading @@ -482,6 +486,8 @@ public class MidiService extends IMidiManager.Stub { } } private static final String[] EMPTY_STRING_ARRAY = new String[0]; private void addPackageDeviceServer(ServiceInfo serviceInfo) { XmlResourceParser parser = null; Loading @@ -494,6 +500,8 @@ public class MidiService extends IMidiManager.Stub { int numInputPorts = 0; int numOutputPorts = 0; boolean isPrivate = false; ArrayList<String> inputPortNames = new ArrayList<String>(); ArrayList<String> outputPortNames = new ArrayList<String>(); while (true) { int eventType = parser.next(); Loading Loading @@ -530,7 +538,18 @@ public class MidiService extends IMidiManager.Stub { continue; } numInputPorts++; // TODO - add support for port properties String portName = null; int count = parser.getAttributeCount(); for (int i = 0; i < count; i++) { String name = parser.getAttributeName(i); String value = parser.getAttributeValue(i); if ("name".equals(name)) { portName = value; break; } } inputPortNames.add(portName); } else if ("output-port".equals(tagName)) { if (properties == null) { Log.w(TAG, "<output-port> outside of <device> in metadata for " Loading @@ -538,7 +557,18 @@ public class MidiService extends IMidiManager.Stub { continue; } numOutputPorts++; // TODO - add support for port properties String portName = null; int count = parser.getAttributeCount(); for (int i = 0; i < count; i++) { String name = parser.getAttributeName(i); String value = parser.getAttributeValue(i); if ("name".equals(name)) { portName = value; break; } } outputPortNames.add(portName); } } else if (eventType == XmlPullParser.END_TAG) { String tagName = parser.getName(); Loading @@ -563,12 +593,16 @@ public class MidiService extends IMidiManager.Stub { synchronized (mDevicesByInfo) { addDeviceLocked(MidiDeviceInfo.TYPE_VIRTUAL, numInputPorts, numOutputPorts, properties, null, serviceInfo, isPrivate, uid); numInputPorts, numOutputPorts, inputPortNames.toArray(EMPTY_STRING_ARRAY), outputPortNames.toArray(EMPTY_STRING_ARRAY), properties, null, serviceInfo, isPrivate, uid); } // setting properties to null signals that we are no longer // processing a <device> properties = null; inputPortNames.clear(); outputPortNames.clear(); } } } Loading
services/usb/java/com/android/server/usb/UsbAlsaManager.java +14 −4 Original line number Diff line number Diff line Loading @@ -394,9 +394,19 @@ public final class UsbAlsaManager { AlsaDevice alsaDevice = waitForAlsaDevice(addedCard, device, AlsaDevice.TYPE_MIDI); if (alsaDevice != null) { Bundle properties = new Bundle(); properties.putString(MidiDeviceInfo.PROPERTY_MANUFACTURER, usbDevice.getManufacturerName()); properties.putString(MidiDeviceInfo.PROPERTY_MODEL, usbDevice.getProductName()); String manufacturer = usbDevice.getManufacturerName(); String product = usbDevice.getProductName(); String name; if (manufacturer == null || manufacturer.isEmpty()) { name = product; } else if (product == null || product.isEmpty()) { name = manufacturer; } else { name = manufacturer + " " + product; } properties.putString(MidiDeviceInfo.PROPERTY_NAME, name); properties.putString(MidiDeviceInfo.PROPERTY_MANUFACTURER, manufacturer); properties.putString(MidiDeviceInfo.PROPERTY_PRODUCT, product); properties.putString(MidiDeviceInfo.PROPERTY_SERIAL_NUMBER, usbDevice.getSerialNumber()); properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_CARD, alsaDevice.mCard); Loading Loading @@ -454,7 +464,7 @@ public final class UsbAlsaManager { Resources r = mContext.getResources(); properties.putString(MidiDeviceInfo.PROPERTY_MANUFACTURER, r.getString( com.android.internal.R.string.usb_midi_peripheral_manufacturer_name)); properties.putString(MidiDeviceInfo.PROPERTY_MODEL, r.getString( properties.putString(MidiDeviceInfo.PROPERTY_PRODUCT, r.getString( com.android.internal.R.string.usb_midi_peripheral_model_name)); properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_CARD, card); properties.putInt(MidiDeviceInfo.PROPERTY_ALSA_DEVICE, device); Loading