Skip to content

Commit ead121e

Browse files
committed
Bump minimum API level to 21
1 parent 31203bf commit ead121e

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ android {
66

77
defaultConfig {
88
applicationId "org.cgutman.usbipserverforandroid"
9-
minSdk 19
9+
minSdk 21
1010
targetSdk 34
1111
}
1212

app/src/main/java/org/cgutman/usbip/service/UsbIpService.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,7 @@ private UsbDeviceInfo getInfoForDevice(UsbDevice dev, UsbDeviceConnection devCon
342342
ipDev.bDeviceProtocol = (byte) dev.getDeviceProtocol();
343343

344344
ipDev.bConfigurationValue = 0;
345-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
346-
ipDev.bNumConfigurations = (byte) dev.getConfigurationCount();
347-
}
348-
else {
349-
ipDev.bNumConfigurations = 1;
350-
}
345+
ipDev.bNumConfigurations = (byte) dev.getConfigurationCount();
351346

352347
ipDev.bNumInterfaces = (byte) dev.getInterfaceCount();
353348

@@ -371,7 +366,6 @@ private UsbDeviceInfo getInfoForDevice(UsbDevice dev, UsbDeviceConnection devCon
371366
devDesc = UsbControlHelper.readDeviceDescriptor(context.devConn);
372367

373368
ipDev.bcdDevice = devDesc.bcdDevice;
374-
ipDev.bNumConfigurations = devDesc.bNumConfigurations;
375369
}
376370

377371
ipDev.speed = detectSpeed(dev, devDesc);

app/src/main/java/org/cgutman/usbip/usb/UsbControlHelper.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,23 @@ public static boolean handleInternalControlTransfer(UsbDevice dev, UsbDeviceConn
7878
value &= 0xFFFF;
7979
index &= 0xFFFF;
8080

81-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
82-
if (requestType == SET_CONFIGURATION_REQUEST_TYPE && request == SET_CONFIGURATION_REQUEST) {
83-
for (int i = 0; i < dev.getConfigurationCount(); i++) {
84-
UsbConfiguration config = dev.getConfiguration(i);
85-
if (config.getId() == value) {
86-
devConn.setConfiguration(config);
87-
System.out.println("Handled SET_CONFIGURATION via Android API");
88-
return true;
89-
}
81+
if (requestType == SET_CONFIGURATION_REQUEST_TYPE && request == SET_CONFIGURATION_REQUEST) {
82+
for (int i = 0; i < dev.getConfigurationCount(); i++) {
83+
UsbConfiguration config = dev.getConfiguration(i);
84+
if (config.getId() == value) {
85+
devConn.setConfiguration(config);
86+
System.out.println("Handled SET_CONFIGURATION via Android API");
87+
return true;
9088
}
9189
}
92-
else if (requestType == SET_INTERFACE_REQUEST_TYPE && request == SET_INTERFACE_REQUEST) {
93-
for (int i = 0; i < dev.getInterfaceCount(); i++) {
94-
UsbInterface iface = dev.getInterface(i);
95-
if (iface.getId() == index && iface.getAlternateSetting() == value) {
96-
devConn.setInterface(iface);
97-
System.out.println("Handled SET_INTERFACE via Android API");
98-
return true;
99-
}
90+
}
91+
else if (requestType == SET_INTERFACE_REQUEST_TYPE && request == SET_INTERFACE_REQUEST) {
92+
for (int i = 0; i < dev.getInterfaceCount(); i++) {
93+
UsbInterface iface = dev.getInterface(i);
94+
if (iface.getId() == index && iface.getAlternateSetting() == value) {
95+
devConn.setInterface(iface);
96+
System.out.println("Handled SET_INTERFACE via Android API");
97+
return true;
10098
}
10199
}
102100
}

0 commit comments

Comments
 (0)