Compare commits

...

2 Commits

Author SHA1 Message Date
Roberto Viola
2eba8e83f6 Update qdomyos-zwift.pri 2025-11-18 17:56:48 +01:00
Roberto Viola
de2ac21aa9 Computrainer Android 6 2025-11-18 17:54:28 +01:00
3 changed files with 53 additions and 6 deletions

View File

@@ -48,9 +48,16 @@ public class Usbserial {
public static void open(Context context, int baudRate) {
QLog.d("QZ","UsbSerial open with baud rate: " + baudRate);
// DEBUG: List all USB devices detected by Android
UsbserialDebug.listAllUsbDevices(context);
// Find all available drivers from attached devices.
UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
List<UsbSerialDriver> availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager);
QLog.d("QZ","UsbSerial drivers found by UsbSerialProber: " + availableDrivers.size());
if (availableDrivers.isEmpty()) {
QLog.d("QZ","UsbSerial no available drivers");
return;
@@ -73,12 +80,20 @@ public class Usbserial {
int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0;
PendingIntent permissionIntent = PendingIntent.getBroadcast(context, 0, new Intent("org.cagnulen.qdomyoszwift.USB_PERMISSION"), flags);
IntentFilter filter = new IntentFilter("org.cagnulen.qdomyoszwift.USB_PERMISSION");
ContextCompat.registerReceiver(
context,
usbReceiver,
filter,
ContextCompat.RECEIVER_EXPORTED
);
// Fix for Android 6 compatibility: RECEIVER_EXPORTED only available in Android 13+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
ContextCompat.registerReceiver(
context,
usbReceiver,
filter,
ContextCompat.RECEIVER_EXPORTED
);
} else {
// Use old API for Android 6-12
context.registerReceiver(usbReceiver, filter);
}
manager.requestPermission(driver.getDevice(), permissionIntent);
for(int i=0; i<5000; i++) {
if(granted[0] != null) break;

View File

@@ -0,0 +1,31 @@
package org.cagnulen.qdomyoszwift;
import android.content.Context;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import java.util.HashMap;
public class UsbserialDebug {
public static void listAllUsbDevices(Context context) {
QLog.d("QZ", "=== USB DEVICE DEBUG START ===");
UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
QLog.d("QZ", "Total USB devices found: " + deviceList.size());
for (UsbDevice device : deviceList.values()) {
QLog.d("QZ", "----------------------------");
QLog.d("QZ", "Device Name: " + device.getDeviceName());
QLog.d("QZ", "Vendor ID: " + device.getVendorId() + " (0x" + Integer.toHexString(device.getVendorId()) + ")");
QLog.d("QZ", "Product ID: " + device.getProductId() + " (0x" + Integer.toHexString(device.getProductId()) + ")");
QLog.d("QZ", "Device Class: " + device.getDeviceClass());
QLog.d("QZ", "Device Subclass: " + device.getDeviceSubclass());
QLog.d("QZ", "Device Protocol: " + device.getDeviceProtocol());
QLog.d("QZ", "Has Permission: " + manager.hasPermission(device));
QLog.d("QZ", "Interface Count: " + device.getInterfaceCount());
}
QLog.d("QZ", "=== USB DEVICE DEBUG END ===");
}
}

View File

@@ -920,6 +920,7 @@ DISTFILES += \
android/src/SpeedChannelController.java \
android/src/SDMChannelController.java \
android/src/Usbserial.java \
android/src/UsbserialDebug.java \
android/src/com/cgutman/adblib/AdbBase64.java \
android/src/com/cgutman/adblib/AdbConnection.java \
android/src/com/cgutman/adblib/AdbCrypto.java \