Hacker News new | past | comments | ask | show | jobs | submit login
Android developers no longer need Windows USB drivers (fabiensanglard.net)
200 points by titaniumtown on Dec 30, 2023 | hide | past | favorite | 67 comments



I really love adb. It's so damn useful. You can even reroute ports through a VPN running on the phone. It's like a swiss army knife. And I'm not even an android developer lol

It's one of the biggest reasons I prefer android. That and the work profile that allows me to compartmentalise all work stuff and other privacy invading shit without needing a second phone.


I wish that the people that wrote it at the beginning of Android had left it as a socket multiplexer over USB and delegated to ssh for everything else. adb started out extremely barebones, but it grew to reimplement basically all of ssh.


Haha. I read the comment and wondered "How does this guy knows so much about ad....". Oh. Its Josh!


Well out of the box Android doesn't even come with an SSH daemon. I run one sometimes through termux but it's not standard.

And some of the functionality it offers doesn't really have an SSH equivalent, like the install command.


Even funnier is during the pandemic, we got adb over ssh so our desktops in the office could still connect to devices at our house.


Hah I did the opposite.

I set up an OpenSmartphoneTestFarm (openSTF) instance at the office so people working from home could fully control smartphones inside the office to debug wifi issues. Because some countries had lockdowns at different times, so it could be that production users could work in the office but some of our support people couldn't. This way they could still test things inside the actual office. And we didn't have to supply our support people with tons of testing phones. Only issue was that it never supported iOS but we use mainly Android anyway for corporate phones, because dual-use (work/private) is a lot better on android. Only in the US they demanded to have iPhones and we outsource the support there.

It worked pretty well actually. https://openstf.io/

But they dropped support on it and moved to another product (device farmer) which never seems to have materialised at all. I don't know what happened to it but we just kept running openstf until the end of the pandemic. It worked fine anyway. But it's too bad it seems to be completely gone as it was actually a great piece of software. A bit overly complex to set up with tons of different docker containers for each part of the service, it was clearly meant for huge distributed installs, which we didn't really need.


Tell us more about this work profile. Is this on all Android phones?


It is yes. It's a separate profile which is open at the same time as the regular profile (unlike the multi user function of Android where only one is open at the same time)

It separates your app list and files into two sections, work and personal. The work apps get a briefcase overlay icon.

I use it to separate my work apps and to shield privacy invading apps from my main profile. You can use the insular or island apps to invoke it on pretty much any phone. Even AOSP has it. MDM can also invoke it, which is what it's intended for.

It also allows you to turn off the whole work profile with one button. Great if you do use it for work and you want to have a quiet weekend. The benefit for your employer is that it stops you from copying work data to private apps.

If you do use it for work it stops your employer from seeing your personal side like what apps you have installed. This can be pretty privacy invasive. For example if you have tinder or Grindr installed. I work in MDM management and on apple I can see this. On Android when work profile is used I can't.



It should be nowadays; but to provision it, you need MDM.

https://www.android.com/enterprise/work-profile/



Nice, thanks!


No you don't! You can just use the island (or insular) app to leverage it for your own purposes


Shelter is another option: https://gitea.angry.im/PeterCxy/Shelter


TestDPC is even simpler/lightweight


Use island! It implements the MDM functions with an app you manage!


adb is indeed useful. I can use adb inside a HyperV Win11 guest OS and have it communicate to my Host Win11's Windows Subsystem for Android and run test android apps in the host OS. I like this approach as it doesn't pollute my host OS with development tools, while using Microsoft WSA for simplicity.

All I need to do is some virtual networking fu via 'netsh interface portproxy' inside both guest OS and host OS.


> Going through my personal collection of Pixels, MODs support seems to have started between Pixel 2 (2017) and Pixel 3a (2019) (sorry, I don't have a Pixel 3 to test).

This definitely would have made it to Pixel 3, per the commit message (https://android.googlesource.com/platform/system/core/+/db64...), it was my primary development device when I implemented this :-)

Everything that's CTS-compliant that got Android 11 should have support: the only change needed from the OEM would be to write a 1 to /config/usb_gadgets/g1/os_desc/use in their USB HAL and there's a CTS test to make sure they did so.


No idea you implemented it. Thanks a lot for that!


Link for reference:

> Bingxing Wang's awesome driver[0].

Windows Precision Touchpad Implementation for Apple MacBook family/Magic Trackpad 2

[0] https://github.com/imbushuo/mac-precision-touchpad


I was using that for years.

Apple hates their own customers for not having written that themselves, and forcing us to use some half-assed driver included in Bootcamp that made the whole thing seem state-of-the-art circa Windows 98.

That said, my MBPr eventually phased out of Windows support (Intel GPU drivers aged out; more and more apps were losing/removing acceleration features due to (unfixed/unfixable) driver and hw bugs, didn't meet Win11 CPU requirements but ran Win11 fine), it now runs Linux with Waylandized KDE; Linux supports the entire feature set of these trackpads without any work).

But yeah, imbushuo is doing some serious work and deserves recognition.


I always thought apple provided crap drivers to make macOS look better. They also drop driver support way too quickly and go out of their way to block boot Camp installations with Windows versions that are newer than they 'support' (whatever little their support is actually worth)


Bootcamp is a joke. Every Intel Mac runs a complete EFI impl based on the stock Intel one, and can just boot Windows without Bootcamp.

Also the only way to install using GPT, as Bootcamp's bootloader hides the GPT header (and OSX uses 2 out of the 4 MBR partition slots) and forces Window to use "legacy single partition mode", which means no Bitlockering C:\ as the EFI boot partition (required since Vista, no matter if it is a EFI/GPT or Legacy Bios/MBR machine) is where ntldr lives now (same way in the MBR days you had /boot on a different unecrypted partition, so you can boot linux, load the initrd, and then unlock the root partition); Windows uses 3 partitions, EFI boot, C:\, and the recovery partition.

Once I realized that, I blanked the entire disk, and purged OSX forever. I made that decision 10 years ago (the MBPr is still alive!), and I never looked back.


Karmakaze is very apt ;) — taking the quote, which is a link, and extracting it to a comment with the link "for reference", but really it's to harvest karma from people who didn't read the article


And then, you pointing it out so you can get in on the karma train as well! And then this comment, made just for the points, which are worth so much that I'm trading in my cheap car for a flashy new one next week!


Akshully.. it's my way of bookmarking/remembering this for later when I'll want it again And thought it might be useful to highlight (or discuss).


I went to college with that dude, neat to see his work getting recognized.


That explains it, I was wondering why things suddenly worked. Not just relevant for devs, but also people who want a better and/or more private android experience than what vendors offer.


Or if you want to use scrcpy, which I find indispensable.

https://github.com/Genymobile/scrcpy


Scrcpy is an awesome tool, but I never found a use for it in my workflow (built a couple of small, unpublished Android apps)

What do you use it for that makes it better than just picking up your device?


I just had a strong use case: a broken screen.

A combination of Google Assistant, Talkback, USB-C-to-USB-A-Adapter and Keyboard, a Bluetooth keyboard, scrcpy, Anydesk and a new Pixel phone for practicing helped get some data off the device and even do a migration to the new phone. Needed all of the above and a lot of trial and error and time!!


I keep a copy of scrcpy around for exactly this. It's saved me twice now, and helped me rescue some data from a friend's phone, too.


I do most of my meetings on my phone, and enlarging the screen if someone is sharing their screen works pretty well (it's not perfect, but more than enough for presentations). But I can of course transfer the call to my PC if need be.

But I just have scrcpy up in a window on one of my screens/workspace constantly. The keyboard shortcuts work quite well and I don't have to break my flow just to do something on my phone. Clipboard is synced as well.

If I get a notification I can check what it is about without taking my hands of my keyboard etc.

I'm sure it sounds a bit convoluted, and each usecase (meetings, notifications etc.) have other better/more-native solutions but the experience all in all is a game-changer.

To the point where "just picking up your device" is too much of a bother. Why not do it through scrcpy instead? Quicker, proper keyboard etc. and the mouse works really well. To the point where I kind of miss right-click is "back" when I'm outside the scrcpy window.


For your last point, there are many mice with 2+ side buttons, which are mapped as forward and back by default and can typically be remapped, it works in pretty much any application that has a "back" option.


Don't feel it is the same, because desktop applications don't work the same. And when you are on the "last screen" and press back on a phone you get to the home-screen. So in most cases a single tap or double-tap takes me to the home-screen.

So it is both for going back and "quitting" applications.

On the desktop it wouldn't even work in the browser, because I work by tabbing new pages and closing tabs rather than navigating back.

So to be fair, I don't want it om my desktop. Because I really don't want my applications to mimic the behavior they do on phones, that would be horrible. But the end result is really nice for the weird usecase of running a phone inside a desktop.


Do you have a good method for cleaning things up? I usually factory reset any new phone and then uninstall via adb the obvious pre-installed spyware/adware/junk (facebook, chrome, candycrush, etc). But it's hard to know what else I can uninstall. I usually go overkill, uninstall most things, see what broke, factory reset again, and then uninstall a little less on the next round. But surely there's a better way.


I unlock the bootloader and install a custom rom (pretty much exclusively LineageOS nowadays, I’d try GrapheneOS, but I’d have to spend far more on the phone than I’m willing to get that). That is everything cleaned ;) I only buy phones with LineageOS support.


GrapheneOS is no harder to install or use than LineageOS. If anything, it is easier, since the documentation is far better and almost always applicable to all supported devices.


It’s not about hard/easy, it’s the supported devices. I spend very little on phones (current one is a OnePlus Nord, which I bought for 250€) as I don’t like to use them.


Graphene is Google Pixel only still. The current cheapest available looks like the Pixel 7A at £379 (new). So I agree, the added cost doesn't seem worth it.

https://store.google.com/config/pixel_7a


Does it come with it's own version of the 'core apps' (calendar, phone, calculator etc.) or do You install and use some third party apps from app store?


You'll get AOSP versions of the basics, though some things like the camera app might actually be made/modified by Lineage. I run LineageOS with no gapps and find it to be quite usable. I get most apps from F-Droid, but there's also Aurora Store (installable from F-Droid) if you need anything from the Play Store.


You can install a custom Google Apps package, e.g.:

https://nikgapps.com/


At that point why would I go for the trouble of installing custom rom though?


Besides what sibling said, and lack of bloatware, I find LineageOS to simply be better than original ROMs. Just using vol up/down to move the cursor is already a godsend for me.

I’ve also been using CyanogenMod/LineageOS since my first android (HTC Desire Z/T-Mobile G2, damn do I miss that full keyboard) and it’s great to be able to always use the same OS.


Because you can choose how many of them you want. None, only the Play Store or the whole shebang.


I remember being annoyed at this. However, this was a solved problem a long time ago — sometime after I switched to macOS and stopped paying attention to the Windows side of things, there started appearing universal ADB drivers.


I remember being annoyed at this too, then I stopped doing Android development so I also consider it a solved problem.


I remember being annoyed at the development process in general so I stopped developing and now live in stasis inside a glass egg.


Do you happen to have a Nix flake for that egg setup?


I remember being annoyed in general, but then I ascended beyond human emotions and now exist as a being of pure logic. I make PWAs instead.


lucky you, personally I just stopped at "I remember being annoyed.", and have been stuck here for years.


TL;DR: Android only needs winusb to work, before Windows 8 (2012) windows only used Vendor ID and Product ID to decide what driver to load, so you had to install a new .inf driver file for every new device. Newer versions ask the device for a Microsoft OS Descriptors (MOD) payload that tell windows what drivers to load, usually winusb and MTP. The devices need to support this, the author says the pixels started supporting this since the Pixel 2 (2017).


> windows only used Vendor ID and Product ID to decide what driver to load

Even if you plug in standard device classes like HID?


No, Windows has a list of specific "generic device classes" where it will automatically load a generic driver. Mass storage and HID are the primary users of this.

But if it doesn't fall into one of those buckets Windows just doesn't enable the device whatsoever.

As noted in the article macOS and Linux do the opposite. They allow userspace programs to enumerate unknown USB devices and manually communicate with them.


How would userspace programs communicate with usb devices without a driver. Does adb itself on Linux internally contain a driver?


On macOS you open the IOKit device and post/receive messages or use transfer buffers. Only one program can do that at once since the OS doesn't know anything about the protocol, but it works without a driver.


Great, so it looks like this requires phone manufacturers to add Microsoft-proprietary garbage to the USB descriptors. Instead of just having Windows do something sane like Linux and macOS do, and fall back to a standardized userspace interface.

Dumb.


The USB driver scene on windows is confusing and sometimes even dangerous. I've seen some students unable to use Arduino clones on windows when they worked perfectly on Linux. I then found this: https://learnarduinonow.com/2014/10/24/does-windows-ftdi-upd... (TLDR: windows auto-installs a driver that will brick your device if they think it is "counterfeit") and decided plugging something other than a storage device (if you trust the system to be free from viruses) on a windows machine is something that should be done as a last resort only.


No longer, as of when? I was working on this exact problem two days ago, using an old Lenovo M7 for a magic mirror project for a gift. I went through every relevant SO article and gave up without getting it to show up for adb, so it's odd to see this declared a solved problem.


Requires the device to support the extended USB information query. Pixel devices do, at least, presumably your random Lenovo doesn't though for some reason so you'd need a "driver" (even though all the INF does is say "use the standard winusb driver")


I used raw HID protocol in my USB connected device. This worked on all versions of Windows. Granted it is not suitable for every need but worked just fine for my case.


It is especially not suitable for adb, one of the primary use cases of which is pushing a multi-gigabyte system image to the device. You can get 200+ MB/s of real-life throughput with bulk transfers, whereas the theoretical limit of HID is what, 64 kB per millisecond?


This has been a solved problem for several years now.


I've been using wireless adb since 4.4


Android should have used HID to have better compatibility with Windows. But I guess the Android developers were on Linux so it wasn't such a big problem for them. Glad it's fixed on Windows now.


(ab)using hid for anything it's not been designed for usually is a pita, especially if you want decent throughput.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: