Refactor setCurrentFunction and setUsbDataUnlocked into one method
This allows us to get rid of an extraneous config switch and simplify some code. Test: Manually change usb configuration Change-Id: Id78da530ff485ecd7a915056832eec1dd8c91954
This commit is contained in:
@@ -101,20 +101,16 @@ public class UsbBackend {
|
||||
private void setUsbFunction(int mode) {
|
||||
switch (mode) {
|
||||
case MODE_DATA_MTP:
|
||||
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP);
|
||||
mUsbManager.setUsbDataUnlocked(true);
|
||||
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP, true);
|
||||
break;
|
||||
case MODE_DATA_PTP:
|
||||
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_PTP);
|
||||
mUsbManager.setUsbDataUnlocked(true);
|
||||
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_PTP, true);
|
||||
break;
|
||||
case MODE_DATA_MIDI:
|
||||
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MIDI);
|
||||
mUsbManager.setUsbDataUnlocked(true);
|
||||
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MIDI, true);
|
||||
break;
|
||||
default:
|
||||
mUsbManager.setCurrentFunction(null);
|
||||
mUsbManager.setUsbDataUnlocked(false);
|
||||
mUsbManager.setCurrentFunction(null, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user