diff options
author | Mike Lockwood <lockwood@google.com> | 2015-03-27 13:23:41 -0700 |
---|---|---|
committer | Mike Lockwood <lockwood@google.com> | 2015-03-27 13:23:41 -0700 |
commit | 5781cd5b218dc3e5a19d8f69e6fb9f310bed4df6 (patch) | |
tree | 7c74f6c49adbe1da5d4b580bbdd69561116f76b9 /services/usb/java/com/android | |
parent | 1e650e26a7bb2f02635530a46ecd715f9911d40e (diff) | |
download | frameworks_base-5781cd5b218dc3e5a19d8f69e6fb9f310bed4df6.zip frameworks_base-5781cd5b218dc3e5a19d8f69e6fb9f310bed4df6.tar.gz frameworks_base-5781cd5b218dc3e5a19d8f69e6fb9f310bed4df6.tar.bz2 |
Make the MIDI Manager optional, enabled by "android.software.midi" feature
Change-Id: I76d442ea28beea4b9e2876bfef501d8f61403702
Diffstat (limited to 'services/usb/java/com/android')
-rw-r--r-- | services/usb/java/com/android/server/usb/UsbAlsaManager.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbAlsaManager.java b/services/usb/java/com/android/server/usb/UsbAlsaManager.java index c041029..2728af1 100644 --- a/services/usb/java/com/android/server/usb/UsbAlsaManager.java +++ b/services/usb/java/com/android/server/usb/UsbAlsaManager.java @@ -17,6 +17,7 @@ package com.android.server.usb; import android.content.Context; +import android.content.pm.PackageManager; import android.content.res.Resources; import android.hardware.usb.UsbConstants; import android.hardware.usb.UsbDevice; @@ -55,6 +56,7 @@ public final class UsbAlsaManager { private final Context mContext; private IAudioService mAudioService; + private final boolean mHasMidiFeature; private final AlsaCardsParser mCardsParser = new AlsaCardsParser(); private final AlsaDevicesParser mDevicesParser = new AlsaDevicesParser(); @@ -126,6 +128,7 @@ public final class UsbAlsaManager { /* package */ UsbAlsaManager(Context context) { mContext = context; + mHasMidiFeature = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI); // initial scan mCardsParser.scan(); @@ -389,7 +392,7 @@ public final class UsbAlsaManager { // mDevicesParser.scan() boolean hasMidi = mDevicesParser.hasMIDIDevices(addedCard); - if (hasMidi) { + if (hasMidi && mHasMidiFeature) { int device = mDevicesParser.getDefaultDeviceNum(addedCard); AlsaDevice alsaDevice = waitForAlsaDevice(addedCard, device, AlsaDevice.TYPE_MIDI); if (alsaDevice != null) { @@ -459,6 +462,10 @@ public final class UsbAlsaManager { } /* package */ void setPeripheralMidiState(boolean enabled, int card, int device) { + if (!mHasMidiFeature) { + return; + } + if (enabled && mPeripheralMidiDevice == null) { Bundle properties = new Bundle(); Resources r = mContext.getResources(); |