| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.midi; | 5 package org.chromium.midi; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.media.midi.MidiDevice; | 8 import android.media.midi.MidiDevice; |
| 9 import android.media.midi.MidiDeviceInfo; | 9 import android.media.midi.MidiDeviceInfo; |
| 10 import android.os.Build; | 10 import android.os.Build; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 @CalledByNative | 95 @CalledByNative |
| 96 String getManufacturer() { | 96 String getManufacturer() { |
| 97 return getProperty(MidiDeviceInfo.PROPERTY_MANUFACTURER); | 97 return getProperty(MidiDeviceInfo.PROPERTY_MANUFACTURER); |
| 98 } | 98 } |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Returns the product name. | 101 * Returns the product name. |
| 102 */ | 102 */ |
| 103 @CalledByNative | 103 @CalledByNative |
| 104 String getProduct() { | 104 String getProduct() { |
| 105 return getProperty(MidiDeviceInfo.PROPERTY_PRODUCT); | 105 String product = getProperty(MidiDeviceInfo.PROPERTY_PRODUCT); |
| 106 // TODO(crbug.com/636455): Following code to use PROPERTY_NAME is a |
| 107 // workaround for a BLE MIDI device issue that Android does not provide |
| 108 // information for PROPERTY_MANUFACTURER, PROPERTY_PRODUCT, and |
| 109 // PROPERTY_VERSION. Confirmed on Android M and N. |
| 110 // See discussion at http://crbug.com/636455 and http://b/32259464. |
| 111 if (product == null || product.isEmpty()) { |
| 112 return getProperty(MidiDeviceInfo.PROPERTY_NAME); |
| 113 } |
| 114 return product; |
| 106 } | 115 } |
| 107 | 116 |
| 108 /** | 117 /** |
| 109 * Returns the version string. | 118 * Returns the version string. |
| 110 */ | 119 */ |
| 111 @CalledByNative | 120 @CalledByNative |
| 112 String getVersion() { | 121 String getVersion() { |
| 113 return getProperty(MidiDeviceInfo.PROPERTY_VERSION); | 122 return getProperty(MidiDeviceInfo.PROPERTY_VERSION); |
| 114 } | 123 } |
| 115 | 124 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 126 */ | 135 */ |
| 127 @CalledByNative | 136 @CalledByNative |
| 128 MidiOutputPortAndroid[] getOutputPorts() { | 137 MidiOutputPortAndroid[] getOutputPorts() { |
| 129 return mOutputPorts; | 138 return mOutputPorts; |
| 130 } | 139 } |
| 131 | 140 |
| 132 private String getProperty(String name) { | 141 private String getProperty(String name) { |
| 133 return mDevice.getInfo().getProperties().getString(name); | 142 return mDevice.getInfo().getProperties().getString(name); |
| 134 } | 143 } |
| 135 } | 144 } |
| OLD | NEW |