Merge "Refactor setCurrentFunction and setUsbDataUnlocked into one method"
This commit is contained in:
@@ -1704,11 +1704,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
private void writeUsbConfigurationOption(Object newValue) {
|
private void writeUsbConfigurationOption(Object newValue) {
|
||||||
UsbManager manager = (UsbManager)getActivity().getSystemService(Context.USB_SERVICE);
|
UsbManager manager = (UsbManager)getActivity().getSystemService(Context.USB_SERVICE);
|
||||||
String function = newValue.toString();
|
String function = newValue.toString();
|
||||||
manager.setCurrentFunction(function);
|
|
||||||
if (function.equals("none")) {
|
if (function.equals("none")) {
|
||||||
manager.setUsbDataUnlocked(false);
|
manager.setCurrentFunction(function, false);
|
||||||
} else {
|
} else {
|
||||||
manager.setUsbDataUnlocked(true);
|
manager.setCurrentFunction(function, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -101,20 +101,16 @@ public class UsbBackend {
|
|||||||
private void setUsbFunction(int mode) {
|
private void setUsbFunction(int mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case MODE_DATA_MTP:
|
case MODE_DATA_MTP:
|
||||||
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP);
|
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP, true);
|
||||||
mUsbManager.setUsbDataUnlocked(true);
|
|
||||||
break;
|
break;
|
||||||
case MODE_DATA_PTP:
|
case MODE_DATA_PTP:
|
||||||
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_PTP);
|
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_PTP, true);
|
||||||
mUsbManager.setUsbDataUnlocked(true);
|
|
||||||
break;
|
break;
|
||||||
case MODE_DATA_MIDI:
|
case MODE_DATA_MIDI:
|
||||||
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MIDI);
|
mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MIDI, true);
|
||||||
mUsbManager.setUsbDataUnlocked(true);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mUsbManager.setCurrentFunction(null);
|
mUsbManager.setCurrentFunction(null, false);
|
||||||
mUsbManager.setUsbDataUnlocked(false);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user