USB-устройство на android 9 перенастраивает неправильные интерфейсы - PullRequest
0 голосов
/ 01 мая 2020

, когда я пытаюсь подключить USB-камеру на вкладке samsung s5e (Android 9), я нахожу только 1 интерфейс без конечных точек, поэтому я не могу начать связь с устройством. Сбой только для камеры MJPEG. Если я использую тот же адаптер OTG с камерой YUV, на вкладке s5e отображаются 2 интерфейса и все конечные точки перечислены.

Может ли это быть проблемой Android 9 / Android 10? Начиная с Android 9 (SDK 28), разрешения камеры должны быть добавлены в файл манифеста приложений, чтобы предоставить разрешения USB.

Камера Mjpeg отлично работает на устройствах Android 8. Здесь доступно 2 интерфейса со всеми конечными точками.

Некоторые сторонние приложения из Play Store, такие как:

https://play.google.com/store/apps/details?id=com.shenyaocn.android.usbcamera&hl=de_AT [ ^] или

https://play.google.com/store/apps/details?id=com.econsystems.webeecamtrial&hl=de_AT [ ^]

могут запускать камеру MJPEG на вкладке s5e, поэтому должен быть способ справиться с этим.

Когда Я запускаю следующий код в Android Studio с вкладкой, подключенной к камере MJPEG

HashMap<string, usbdevice=""> deviceList = mManager.getDeviceList();
Iterator<usbdevice> deviceIterator = deviceList.values().iterator();

while (deviceIterator.hasNext())
{
UsbDevice device = deviceIterator.next();
Log.i(TAG,"Model: " + device.getDeviceName());
Log.i(TAG,"ID: " + device.getDeviceId());
Log.i(TAG,"Class: " + device.getDeviceClass());
Log.i(TAG,"Protocol: " + device.getDeviceProtocol());
Log.i(TAG,"Vendor ID " + device.getVendorId());
Log.i(TAG,"Product ID: " + device.getProductId());
Log.i(TAG,"Interface count: " + device.getInterfaceCount());
Log.i(TAG,"---------------------------------------");
// Get interface details
for (int index = 0; index < device.getInterfaceCount(); index++)
{
UsbInterface mUsbInterface = device.getInterface(index);
Log.i(TAG," ***** *****");
Log.i(TAG," Interface index: " + index);
Log.i(TAG," Interface ID: " + mUsbInterface.getId());
Log.i(TAG," Inteface class: " + mUsbInterface.getInterfaceClass());
Log.i(TAG," Interface protocol: " + mUsbInterface.getInterfaceProtocol());
Log.i(TAG," Endpoint count: " + mUsbInterface.getEndpointCount());
// Get endpoint details
for (int epi = 0; epi < mUsbInterface.getEndpointCount(); epi++)
{
UsbEndpoint mEndpoint = mUsbInterface.getEndpoint(epi);
Log.i(TAG," ++++ ++++ ++++");
Log.i(TAG," Endpoint index: " + epi);
Log.i(TAG," Attributes: " + mEndpoint.getAttributes());
Log.i(TAG," Direction: " + mEndpoint.getDirection());
Log.i(TAG," Number: " + mEndpoint.getEndpointNumber());
Log.i(TAG," Interval: " + mEndpoint.getInterval());
Log.i(TAG," Packet size: " + mEndpoint.getMaxPacketSize());
Log.i(TAG," Type: " + mEndpoint.getType());
}
}
}
Log.i(TAG," No more devices connected."); 

Я получаю следующее:

ID: 1002
Class: 239
Protocol: 1
Vendor ID 1338
Product ID: 37424
Interface count: 1
---------------------------------------
***** *****
Interface index: 0
Interface ID: 0
I/SetUpTheUsbDevice: Inteface class: 14
Interface protocol: 0
Endpoint count: 0
No more devices connected. 

И тот же планшет (тот же адаптер OTG) с камерой YUV работает нормально:

ID: 1002
Class: 239
Protocol: 1
Vendor ID 6380
Product ID: 13200
Interface count: 13
---------------------------------------
I/SetUpTheUsbDevice: ***** *****
Interface index: 0
Interface ID: 0
Inteface class: 14
Interface protocol: 0
Endpoint count: 1
++++ ++++ ++++
Endpoint index: 0
Attributes: 3
Direction: 128
Number: 1
Interval: 10
Packet size: 16
Type: 3
***** *****
Interface index: 1
I/SetUpTheUsbDevice: Interface ID: 1
Inteface class: 14
Interface protocol: 0
Endpoint count: 0

... All the other 11 Interfaces / Endpoints were displayed too ...
***** ***** 

...