Merge "Don\'t show MIDI USB option if not supported"
am: c2a9cd03f7
* commit 'c2a9cd03f71b3b6b0af2f6faaf877fd9c75dd9fe':
Don't show MIDI USB option if not supported
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.deviceinfo;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.hardware.usb.UsbPort;
|
||||
import android.hardware.usb.UsbPortStatus;
|
||||
@@ -36,6 +37,7 @@ public class UsbBackend {
|
||||
public static final int MODE_DATA_MIDI = 0x03 << 1;
|
||||
|
||||
private final boolean mRestricted;
|
||||
private final boolean mMidi;
|
||||
|
||||
private UserManager mUserManager;
|
||||
private UsbManager mUsbManager;
|
||||
@@ -53,6 +55,8 @@ public class UsbBackend {
|
||||
mUsbManager = context.getSystemService(UsbManager.class);
|
||||
|
||||
mRestricted = mUserManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER);
|
||||
mMidi = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI);
|
||||
|
||||
UsbPort[] ports = mUsbManager.getPorts();
|
||||
// For now look for a connected port, in the future we should identify port in the
|
||||
// notification and pick based on that.
|
||||
@@ -135,6 +139,11 @@ public class UsbBackend {
|
||||
// No USB data modes are supported.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mMidi && (mode & MODE_DATA_MASK) == MODE_DATA_MIDI) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mPort != null) {
|
||||
int power = modeToPower(mode);
|
||||
if ((mode & MODE_DATA_MASK) != 0) {
|
||||
|
Reference in New Issue
Block a user