Why is the VID wrong when I try to use Android accessory mode?

208 Views Asked by At

I am trying to communicate between a Linux PC and an Android phone over USB using the AOA protocol.

All of the resources I've been able to find, including the documentation and source code examples like this, seem to expect the VID of a device that supports the Android Open Accessory protocol to be 0x18d1.

However, I'm trying to test this on a Samsung Galaxy S10e, and the VID is 0x04e8 instead. I already installed a dummy app on this phone that has a USB accessory intent filter, but no luck.

How do I get the Samsung phone to act in USB accessory mode? Is it already enabled, and the VID of 0x18d1 only applies to Google phones? Or do I have to do something to get the VID to change? If the former is the case, then how can I check whether a given USB device is an Android phone?

2

There are 2 best solutions below

0
On BEST ANSWER

It seems that the VID of the Android device will change to 0x18d1 only when accessory mode has already been activated. This seems to mean that I have to detect Android phones some other way, attempt to activate accessory mode, and then see if it works.

0
On

How do I get the Samsung phone to act in USB accessory mode?

I was able to do this, by activating the USB debugging inside the settings of my Samsung A20e. After this, I was able to connect from my Windows App to the Android device to start the accessory mode.

The procedure inside my Windows App:

  1. Get the device ID of the USB adapter (ADB interface) with the GUID f72fe0d4-cbcb-407d-8814-9ed673d0dd6b.
  2. This can be used as the file name to get a file handle with CreateFile (please use FILE_FLAG_OVERLAPPED).
  3. The file handle can be passed to WinUsb_Initialize to get a WinUsb handle.
  4. Now you can request the protocol (51) and send some information (52) like manufacturer, model, etc. to the Samsung device with WinUsb_ControlTransfer.
  5. After this, you can start the accessory mode with command 53.

Is it already enabled, and the VID of 0x18d1 only applies to Google phones?

Normally, the accessory mode is not enabled. If you enable it, your Samsung device (VID 0x04E8) will be removed. So after enabling the accessory mode, I wasn't able use MTP or RNDIS furthermore.

Or do I have to do something to get the VID to change?

Like described before, you have to enable the accessory more to show the Samsung device as a Google device instead.

If the former is the case, then how can I check whether a given USB device is an Android phone?

By using the mentioned GUID, you list only Android devices with enabled USB debugging (the ADB interface is active).