yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] newbit:
Hello Fellows,

with this Guide I would like to show what is necessary to do,

to get the new USB passthrough Feature,

from the Android Studio since Emulator 30.0.26 (August 16, 2020),

to work with a USB-Serial Device. Unfortunately the announcement "USB passthrough is now available"

needs to be taken literally. It means, just the passing from the host system to the gates of Android are possible.

There is no "taking it from there" implemented in Android nor the Kernel. And this is what this Guide is all about.

Inspired by Alabate and his Guide Use custom USB device with Android emulator by using custom built kernel on Ubuntu 18.04

Three basic steps needed to be done.

[Update 04.05.2021]

Spoiler content hidden.

Spoiler content hidden.

[Update 15.12.2021]

Spoiler content hidden.

[Update 10.10.2022]

Spoiler content hidden.

Thanks for reading

Cheers NewBit

Thanks and Credits to @topjohnwu , Alabate, Google, Qemu and Jitendra

QEMU/Devices/USB/Root

USB Quick Start

USB recommendations for qemu

qemu usb storage emulation
[Android Software/Hacking General [Developers Only]] tomek_be:
Have you mange to make it work on windows ?
[Android Software/Hacking General [Developers Only]] newbit:
Sorry for the late response, I didn't get any notice...

No I did not even try it. Did you?
[Android Software/Hacking General [Developers Only]] tomek_be:
I did but with no luck. Emulator correctly creates USB controller and /sys/kernel/debug/usb/devices contains entries corresponding with command line options but passthrough USB device is not discovered by the kernel. Sometimes emulator produces message on stdout that devices has been attached or detached but it is not repeatable. I tried different hardware accelerations ( HAXM and WHPX ) - nothing . BTW - on linux it worked like a charm - only thing I need to do was creating proper /system/etc/permissions/android.hardware.usb.host.xml. After that non modified kernel picked up usb device.
[Android Software/Hacking General [Developers Only]] newbit:
Weird, I still don't get any notice.

So you did try it on Linux with Stock Kernel and permission xml file!? -> it worked

You also tried the same thing on Windows? -> it didn't worked

Is it the same/similar AVD version? Is the syntax on windows different? What commands did you use exactly?

Is your AVD rooted? Did you cross compare the Kernel Configs? Kernel Versions?

What USB Device exactly you are trying to pass through?
[Android Software/Hacking General [Developers Only]] mariodantas:
Hello fellows, Did you find the way to make it work in Windows ?, It's hard to create apps that need interaction with USB / Bluetooth devices under Windows environment !, I wonder why these guys at Google make it so hard ?
[Android Software/Hacking General [Developers Only]] newbit:
It was actually already solved, the same way like on linux. But Google

decided to take out the USB Pass Through Feature on Windows.

Android emulator USB passthrough fails: " 'usb-host' is not a valid device model name"

So the only chance would be to get back to Version 30.5.2 (build_id 7175973) (Feb 27, 2021) to try it out.
[Android Software/Hacking General [Developers Only]] mariodantas:
Hard to develop apks that need to cope with USB or BT in Windows machines, what's wrong with Google ?

Thanks for your information buddy !
[Android Software/Hacking General [Developers Only]] newbit:
I've stopped wondering since they put this sneaky covid "feature" undetected on my phone.

Yes, totally. But Microsoft is to blame as well, according to Erwin Jansen.

I guess you need to remotely debug your apk directly on your phone/device.

No problem, If there is any USB update in the Windows Version, I am happily updating this Guide.
[Android Software/Hacking General [Developers Only]] nrajeevlochan:
Hello newbit,

USB passthrough with (ASUS USB-BT400 USB Adapter USBBT400) on Linux is working fine, Emulator is able to connect to phone with BT dongle mentioned above - followed steps in android link - https://source.android.com/devices/automotive/start/passthrough

But when trying the same in MAC OS, I could see BT dongle is getting detected in Emulator as shown below (0b05:17cb) but BT in emulator not working. So, not able to connect to phone.

1|emulator:/ # lsusb

Bus 004 Device 001: ID 1d6b:0002

Bus 004 Device 002: ID 0b05:17cb

Bus 002 Device 001: ID 1d6b:0002

My question is that, In linux I have Update udev settings to allow the user process (e.g. QEMU) to have read/write permissions:

$ echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", ATTRS{idProduct}=="17cb", MODE="0666", GROUP="plugdev"' | sudo tee /etc/udev/rules.d/99-mynew.rules >/dev/null

$ sudo udevadm control --reload

$ sudo udevadm trigger

But in MAC OS I am not sure how to do the same ie Update udev settings to allow user process to have read/write permissions ? I am not sure if this is the problem ? Are you successful with USB passthrough on MAC OS ?

I am currently blocked and any inputs on this regard would be great. Thanks
[Android Software/Hacking General [Developers Only]] newbit:
Hi @nrajeevlochan,

as mentioned above, Mac doesn't have this UDEV feature like Linux has it. Depending on the Mac OS Version,

I had to extract and copy some dylib files from a newer Mac OS Version to my running Version. The Error

output was gone, but the USB Device wasn't passed through. So for now, I cannot provide something useful to get the USB Pass through feature running on Mac OS. The only, non-convenient work around is, to adb remote connect to your Linux AVD. But you need either 2 separate Machines or a virtual Machine running in your Mac. Which will cost you a lot of performance. Is there any error message on the terminal regarding your USB?
[Android Software/Hacking General [Developers Only]] nrajeevlochan:
Hi newbit,

Thanks for your quick response.

Please see the error I am getting with "dmesg | grep usb" below:

emulator:/ # dmesg | grep usb

[ 205.231407] usb 1-1: new high-speed USB device number 2 using xhci_hcd

[ 205.383241] usb 1-1: config 1 interface 0 altsetting 0 bulk endpoint 0x82 has invalid maxpacket 64

[ 205.384500] usb 1-1: config 1 interface 0 altsetting 0 bulk endpoint 0x2 has invalid maxpacket 64

[ 205.385742] usb 1-1: config 1 interface 2 altsetting 0 bulk endpoint 0x84 has invalid maxpacket 32

[ 205.387163] usb 1-1: config 1 interface 2 altsetting 0 bulk endpoint 0x4 has invalid maxpacket 32

[ 205.392405] usb 1-1: New USB device found, idVendor=0b05, idProduct=17cb, bcdDevice= 1.12

[ 205.393828] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[ 205.395216] usb 1-1: Product: BCM20702A0

[ 205.395983] usb 1-1: Manufacturer: Broadcom Corp

[ 205.396874] usb 1-1: SerialNumber: 5CF370A4407D

[ 205.405316] usb 1-1: can't set config #1, error -32

[ 205.566482] usb 1-1: usbfs: USBDEVFS_CONTROL failed cmd UsbDeviceHandle rqt 192 rq 51 len 2 ret -110

[ 205.621767] usb 1-1: usbfs: USBDEVFS_CONTROL failed cmd UsbDeviceHandle rqt 192 rq 51 len 2 ret -110
[Android Software/Hacking General [Developers Only]] newbit:
My apologies @nrajeevlochan,

I didn't even notice that you've replied to my question.

[ 205.405316] usb 1-1: can't set config #1, error -32

indicates, that the AVD actually detects the device, and can even read some low level information from it.

Like Product, VID, PID etc. But the host system doesn't fully let it go, so this error can't set config #1, error -32 shows up, indicating that state.

I do have some positive updates tho, you might wanna check out the

[Update 10.10.2022]

For MacOS Only.

Cheers NewBit
[Android Software/Hacking General [Developers Only]] JitendraKarma:
Hi @newbit

is there any limit in qemu or Android for usb passthrough because I can only pass 3 usb devices ?

My requirement is to pass 4 usb devices at once. But always last device is not getting recognize in android emulator.

Please share your though or finding on this.

Thank you.
[Android Software/Hacking General [Developers Only]] newbit:
hi, possible, but not that I know for sure.

Depending on the OS as well i guess. how did you pass it and on which OS?
[Android Software/Hacking General [Developers Only]] JitendraKarma:
Hi

I tried on Ubuntu 20.04 and Windows as well (below command was different for windows)

I am using below command in ubuntu to passthrough

emulator -no-snapshot -selinux permissive -qemu -usb -device qemu-xhci,id=ehci -device usb-host,bus=ehci.0,vendorid=0x18d1,productid=0x4ee7 -device usb-host,bus=ehci.0,vendorid=0x18d1,productid=0x2d01 &

Similar way adding 2 more USB device's VID & PID.
[Android Software/Hacking General [Developers Only]] newbit:
I don't think you need the -selinux permissive flag. Magisk should do this

for you already.

You could try not to pass discrete PIDs and VIDs, but just a specific port.

And on this port, every usb device gets passed through. And If you hook a USB Hub on this port, all devices should get passed through. But this is just a theory of mine, didn't tried this one out. But I have another Linux engine and will try to pass more than 3 devices. I will let you know what happens.
[Android Software/Hacking General [Developers Only]] asmarf6:
Will the following command also install USB host permission magisk module ?

rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-32\google_apis_playstore\x86_64\ramdisk.img PATCHFSTAB GetUSBHPmodZ

I installed magisk but still the USB is not accessible in emulator. I can only notice that it is passed through and not accessible in Windows host machine. Any help would be appreciated.
[Android Software/Hacking General [Developers Only]] newbit:
it could be missing due the gitlab movement. Download and install the zip file manually.
[Android Software/Hacking General [Developers Only]] asmarf6:
Thank you for your response. I get following message when I run the command "TLS error from peer".

What does this refer to ? Just for info, internet is working both inside emulator and host machine. Also I tried it twice but I get the same problem.

I appreciate your help. Thanks

View attachment 6045702
[Android Software/Hacking General [Developers Only]] newbit:
Hi @JitendraKarma,

my apologies for this very late feedback,

I guess Life Is What Happens When You're Busy Making Other Plans.

I've updated my Linux machine to Linux Mint 21 and updated Android Studio

to Hedgehog.

I also fixed the script to download the usb host permissions module (@asmarf6).

Gitlab removed the attached binary from the github to gitlab migration,

and it uses different ways to upload assets, anyway.

I had no issues passing 6 USB Devices through. But I've noticed each time,

I've added one more, the AVD became a bit slower. But they were all mounted and accessible in the AVD.

View attachment 6046434 View attachment 6046433

Here are my USB Devices:

Bus 002 Device 008: ID 0930:6545 Toshiba Corp. Kingston DataTraveler 102/2.0 / HEMA Flash Drive 2 GB / PNY Attache 4GB Stick
Bus 005 Device 002: ID 058f:6387 Alcor Micro Corp. Flash Drive
Bus 005 Device 004: ID 067b:2506 Prolific Technology, Inc. Kaser 8gB micro hard drive
Bus 002 Device 010: ID 9710:7720 MosChip Semiconductor MCS7720 Dual serial port adapter
Bus 005 Device 003: ID 08bb:2704 Texas Instruments PCM2704 16-bit stereo audio DAC
Bus 001 Device 010: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC

Here are my /etc/udev/rules.d/99-usb-android.rules content:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", ATTRS{idProduct}=="6545", OWNER="libvirt-qemu", GROUP="kvm"
SUBSYSTEM=="usb", ATTRS{idVendor}=="214b", ATTRS{idProduct}=="7250", OWNER="libvirt-qemu", GROUP="kvm"
SUBSYSTEM=="usb", ATTRS{idVendor}=="058f", ATTRS{idProduct}=="6387", OWNER="libvirt-qemu", GROUP="kvm"
SUBSYSTEM=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2506", OWNER="libvirt-qemu", GROUP="kvm"
SUBSYSTEM=="usb", ATTRS{idVendor}=="9710", ATTRS{idProduct}=="7720", OWNER="libvirt-qemu", GROUP="kvm"
SUBSYSTEM=="usb", ATTRS{idVendor}=="08bb", ATTRS{idProduct}=="2704", OWNER="libvirt-qemu", GROUP="kvm"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", OWNER="libvirt-qemu", GROUP="kvm"

Here are my command to start the AVD:

~/Android/Sdk/emulator/emulator \
-netdelay none -netspeed full -no-snapstorage -avd Pixel_4_API_Tiramisu \
-usb-passthrough vendorid=0x0930,productid=0x6545 \
-usb-passthrough vendorid=0x058f,productid=0x6387 \
-usb-passthrough vendorid=0x067b,productid=0x2506 \
-usb-passthrough vendorid=0x9710,productid=0x7720 \
-usb-passthrough vendorid=0x08bb,productid=0x2704 \
-usb-passthrough vendorid=0x0403,productid=0x6001

I hope this helps?!

I couldn't get my USB Hub passed through, even though in an "old" Qemu Doc it

is explicit mentioned. -device usb-hub,bus=usb-bus.0,port=2

But it seems this command doesn't apply to the AVDs qemu binary.

I still need to read through the AVDs qemu source, to see if there is anything mentioned regarding usb hubs.

Cheers
[Android Software/Hacking General [Developers Only]] asmarf6:
Hi ,

Thank you that you updated the github source. I executed the command again and this time the usb host permission zip file is installed in local Downloads folder of AVD but how to proceed afterwards ?

My Magisk application look like following after running the command

View attachment 6046480

What do I have to install to mount the usb stick to emulator ? I still dont see it in Storage.

I would appreciate if you could update the guide with step by step instructions. Thank you.
[Android Software/Hacking General [Developers Only]] newbit:
Ok this is actually basic knowledge on how magisk and its modules work and how they get installed. First you need to have the AVD rooted, your is not according to your screenshot. After it is rooted, hit to the modules tap, install from storage, change to the download location of your built-in sdcard, and there is the zip file, install it and reboot. After that, you can start passing usb devices through. Make sure you have KVM installed as described on the first page.
[Android Software/Hacking General [Developers Only]] asmarf6:
Hi,

I am able to pass through USB stick. Thank you for your support :) But can I also passthrough Bluetooth USB dongle using the same way ? I tried but it does not connect the dongle within the emulator.
[Android Software/Hacking General [Developers Only]] newbit:
Congrates, well done.

I would check always if the passed through device gets recognized by the USB Device Info APK. That way you can be sure the device is really passed through.

According to the AOSP, yes it should be possible, but you need to build your own kernel. You could also extract the kernel config first, to see if the drivers are already implemented. If you make it work, please leave a feedback.
[Android Software/Hacking General [Developers Only]] JitendraKarma:
Sorry for late response.

I am trying this on AAOS emulator version 12. With you suggestion, I am able to see usb devices listing inside android shell.

Thank you for your support and guidance.
[Android Software/Hacking General [Developers Only]] newandroiddev:
I am trying to follow the guide but certain dependencies cant be installed, e.g

E: Package 'kernel-package' has no installation candidate

E: Package 'qt5-default' has no installation candidate
[Android Software/Hacking General [Developers Only]] newbit:
Which linux distri are you using?
[Android Software/Hacking General [Developers Only]] newandroiddev:
i am on Mint 21.3
[Android Software/Hacking General [Developers Only]] newbit:
you need to check if these packages are still available or renamed in this linux.
[Android Software/Hacking General [Developers Only]] newbit:
On the AOSP Establishing a build environment, you can use the recommended packages from there.

As it seems, the kernel-package was removed on linux mint 21.3 and also the qt5 package.

So you can just remove the kernel-package from your apt command.

The qt5 as well, or you can try some of these methods here -> qt5-default not in Ubuntu 21.04
[Android Software/Hacking General [Developers Only]] chiizuuru:
First of all, thank you for your contribution! I've been trying to root my Android Studio for some time, but for some reason the installation doesn't proceed, any tips?

- ADB installed and specified in environment variables.

Thx for all!
[Android Software/Hacking General [Developers Only]] newbit:
Please read the first page!

Provide full logs

Dont use PS

Use CMD

Dont use the installapps argument

read the whole thread
[Android Software/Hacking General [Developers Only]] seeya09:
@newbit Hi, thanks for the guide. I'm currently trying to passthrough a USB on a MacOS Ventura 13.5.2 however I haven't been successful.

The command I'm running is this.

sudo ./emulator @Pixel_3a_API_33_arm64-v8a -netdelay none -netspeed full -no-snapstorage -qemu -usb -device qemu-xhci,id=xhci -device usb-host,bus=xhci.0,vendorid=0x045c,productid=0x0195

The logs printed out which is relevant to the USB is shown below.

From the logs, it seems like qemu is trying to acquire exclusive access for the device but failed. My guess is the kernel driver is still active and somehow libusb isn't able to detach the kerner driver and claim it.

I'm not sure how to continue from here. Any suggestions will be appreciated!

2024-04-05 00:43:03.385 qemu-system-aarch64[1719:22602] vendorID: 0x045c (1116), productID: 0x0195 (405)
2024-04-05 00:43:03.385 qemu-system-aarch64[1719:22602] Command line USB devices: (
"vendorID: 0x45c, productID: 0x195"
)
2024-04-05 00:43:03.385 qemu-system-aarch64[1719:22602] Acquiring USB Exclusive access for device: <vendorID: 0x45c, productID: 0x195>
2024-04-05 00:43:03.388 qemu-system-aarch64[1719:22602] Service authorization failed with error with return code: -536870202

The android emulator version I'm using is shown below.

Android emulator version 34.1.20.0 (build_id 11610631)

System Information about the USB device I'm trying to pass through.

USB 3.1 Bus:

Host Controller Driver: AppleT8112USBXHCI

SMART:

Product ID: 0x0195
Vendor ID: 0x045c
Version: 2.00
Serial Number: 2017-2-25
Speed: Up to 12 Mb/s
Manufacturer: SMTCTL
Location ID: 0x01100000 / 2
Current Available (mA): 500
Current Required (mA): 100
Extra Operating Current (mA): 0

I was also reading through https://gist.github.com/Alabate/200f021e644baed84993dd6109811ba2 and it seems like it could be the Android Kernel disabling usb devices. Will try to see if I can build a custom kernel that disable the disabling of usb devices.
[Tilt, TyTN II, MDA Vario III General] Ken0905:
I doubt if this is a new problem.

I cannot get my tytnii to connect via dialup to my isp - message “cannot connect for unknown reasons….reset mobile”. The device works in every other way with both o2 and Orange (uk) getting my isp email and web via wifi and GPRS no problem. I have checked the settings and dialled the isp number direct from my landline and get the modem sounds. I have also changed the number on the device from the isp to my landline number and the land lines does not ring when I set the device to dial up the isp. I have done a hard reset which makes no difference. My other device an o2 xda mini s with the same settings dials up fine.

I need dialup when I can’t get GPRS eg in Cuba. Can anyone help?
[Samsung Galaxy S10 5G Questions & Answers] evgenadze6041990:
купил с рук s10 5g корейский, сверил imei все сходится, но на телефон не приходят обновления, последнее как написано было 1 ноября 20 года, как узнать будут ли приходить обновы по воздуху или что то нужно махинировать? Сорян за мою неграмотность, телефон нравится, хочется чтобы было все как надо.

mod edit - translation added according to the Forum Rules

Spoiler content hidden.
[Samsung Galaxy S10 5G Questions & Answers] hippy dave:
I don't know what you're saying but you probably don't want to post your IMEI publicly.
[Samsung Galaxy S10 5G Questions & Answers] evgenadze6041990:
[QUOTE = "hippy dave, post: 84232965, member: 5307726"]

I don't know what you're talking about, but you probably don't want to publish your IMEI publicly.

[/ QUOTE]
[Samsung Galaxy S10 5G Questions & Answers] razercortex:
You should check on the Sammobile website, if you find a newer firmware then you need to manually update using Odin.
[Huawei P20 Questions & Answers] kcysiu92:
Good evening

I'm trying to unlock bootloader of my Huawei P20 but I don't have a code for that operation. Is it possible to somehow get it for free?
[Windows RT Development and Hacking] frylockk19:
I have ported make and CMake to ARM32 Windows that way if you use LLVM-MinGW, you can now compile on the Surfaces themselves. Code edits were required for CMake, but they were very little and I will say what they are if people want them. Have fun with these!
[Windows RT Development and Hacking] Qiangong2:
That's awesome! Thanks! Are these pre-signed? Or do I need to use the signing tool?
[Windows RT Development and Hacking] frylockk19:
They're not pre-signed, so you'll have to sign them, sorry 'bout that. Forgot to mention it.
[Windows RT Development and Hacking] tkmbid:
It's awesome, if it will work, have some trouble to sign it, may I get further information about that ?

And further information, what in the soucre has to be edit ?

Thanks a lot

autosign-dlls-exes-V1.cmd

further info, while signing at surface via the tool [autosign-dlls-exes-V1.cmd] :

C:\progs\Compile\CMakeARM32\bin>(call :Sign "C:\progs\Compile\CMakeARM32\bin\cmake.exe" )

C:\progs\Compile\CMakeARM32\bin>## signtool sign /a /v /sm /s Root /n WRTJBCert /tr http://www.startssl.com/timestamp /ph /fd sha256 "C:\progs\Compile\CMakeARM3

2\bin\cmake.exe" 1>nul 2>nul

C:\progs\Compile\CMakeARM32\bin>signtool sign /v /f "my.p12" /p "mypassword" /td sha256 /tr "http://timestamp.comodoca.com/rfc3161" /du "http://mydomain.com/" /

fd sha1 "my.exe"

Die Version von C:\progs\Compile\CMakeARM32\bin\SignTool.exe ist mit der ausgeführten Windows-Version nicht kompatibel. Überprüfen Sie die Systeminformationen d

es Computers, und wenden Sie sich anschließend an den Herausgeber der Software.

C:\progs\Compile\CMakeARM32\bin>if errorlevel 1 echo C:\progs\Compile\CMakeARM32\bin\cmake.exe

C:\progs\Compile\CMakeARM32\bin\cmake.exe
[Windows RT Development and Hacking] frylockk19:
Sorry for being so late, but I cannot guarantee it works on RT8.1. I have upgraded to RT10 and no longer have RT8.1 to test on... I don't know if you're on RT10 or not, but sorry about that. I don't know the signtool you are using either, but it shouldn't matter.
[Samsung Galaxy Note 10+ Questions & Answers] swaspc:
It starts with an Exynos Note 10+ not receiving android updates.

UI 2.0 Security patch 1 December 2019

AP: N975FXXU1BSL7

CP: N975FXXU1BSL4

CSC: N975FOXM1BSL9

AUT/NEE - AUT/XAA [Switzerland (unbranded), Nordic countries, US (unbranded)]

I find a Firmware update for NEE (Nordic countries)

I got

UI 2.5 Security patch 1 December 2020 (good!)

AP: N975FXXS6DTK8

CP: N975FXXS6DTK8

CSC: N975FOSW6DTJ4

NEE/NEE - DBT/XAA [Nordic countries, Germany (unbranded), US (unbranded)]

... and the Kylo Ren custom graphics and sounds!!!

Nice!!! I get the cool factor and I am a Star Wars fan but, in a certain work environment is too much.

Off course I can change the theme and sound, but if I turn off or restart the phone I get the hyperspace effect and the Kylo Ren face is back.

I try to go back to my old firmware

AP: N975FXXU1BSL7

CP: N975FXXU1BSL4

CSC: N975FOXM1BSL9

AUT/NEE - AUT/XAA

With that AP, CP, CSC I can only get an XSG United Arab Emirates Firmware which does not work.

I also found an AUT (Switzerland) which does not work. The CSC was: N975FOXM1BSL7. My old one was CSC: N975FOXM1BSL9).

So what I can do to get rid of Kylo Ren?

or

Where I can find am OXM version?

Any suggestions appreciate!
[Samsung Galaxy Note 10+ Questions & Answers] p220fhf:
This may be the OXM version you're looking for.

OXM
[Samsung Galaxy Note 10+ Questions & Answers] galaxy mini:
Fist of all read the official firmware thread!!

Second of all, post in the Q/A section, this is the developers section!! Its realy anoying...
[Samsung Galaxy Note 10+ Questions & Answers] swaspc:
Please, accept my apologies.
[Samsung Galaxy Note 10+ Questions & Answers] swaspc:
OXM

[/QUOTE]

Thank you!