Software Accessory for Android on Windows

I would like to turn my computer into an Android accessory using my application. Therefore, instead of specialized equipment, it will be only a PC that switches the phone to accessory mode, thus launching some Java application on the phone connected to the host equipment and creating a communication channel.

I found a code sample (plus some Java Android app) to do this on Linux using libusb. It works when you "open" the phone using standard VID and PID. He then sends a command to enable accessory mode , as well as metadata such as model, version, etc.

If the phone supports accessory mode, it will turn off and restart with a different PID. Then the sample code checks to see if it succeeded and opens a new device.

However, I am trying to run this on Windows. I found several USB libraries, for example LibUsbDotNet , but they all need a device using the WinUSB / libusb driver. I used the tool in LibUsbDotNet to create the libusb driver for my phone by installing it on top of an old universal removable drive. But this means that now I can’t access the phone as a removable disk when I want, so this is not a solution.

Is there a way (preferably a library) that can open any connected USB device based on VID and PID, and then send some raw commands?

After that, the device will reuse another PID, which I can use to create my own WinUSB driver, so this is not a problem. I just need to enter some commands through / around the default driver to enable helper mode.

(I would prefer a .NET solution, but all that Windows is fine and I can write my own interaction shell)

+6
source share
1 answer

I am also looking for a similar solution. I tried the Linux version, with libusb, with small hickups, was able to communicate with the device. When searching for solutions on windows, I tried many hacks. If you need to contact the device in ADK mode, I need to send several commands to the provider, now I need to do this while it is connected in Mass Storage mode. This is not possible with the Mass Storage driver. I tried to get the Node descriptor of the connected USB device to find out if it could send a provider command, but there I could only handle Get Descriptor requests. So I went with the ugly method, replaced the storage driver with libusb-win32, to see that it can do the same, YES, it worked, but is not a good solution at all.

Continuation of the search.

0
source

Source: https://habr.com/ru/post/906957/


All Articles