nohajc / termux-adb

Run adb in Termux without root permissions!
MIT License
311 stars 32 forks source link

no devices after upgrading to android 14 #22

Closed AlphaBs closed 4 months ago

AlphaBs commented 5 months ago

Describe the bug termux-adb devices shows nothing after upgrading my device to Android 14

To Reproduce Screenshot_20240209_145139_Termux

Expected behavior shows connected device

Smartphone (please complete the following information):

Attach output of the following commands

~/termux-gnirehtet $ pkg show android-tools
Package: android-tools
Version: 34.0.4-4
Maintainer: @termux
Installed-Size: 11.9 MB
Depends: abseil-cpp, brotli, libc++, liblz4, libprotobuf, libusb, pcre2, zlib, zstd
Homepage: https://developer.android.com/
Download-Size: 1798 kB
APT-Sources: https://packages-cf.termux.dev/apt/termux-main stable/main aarch64 Packages
Description: Android platform tools

~/termux-gnirehtet $ termux-adb version
Android Debug Bridge version 1.0.41
Version 34.0.4-android-tools
Installed as /data/data/com.termux/files/usr/bin/termux-adb
Running on Linux 5.4.242-27760517-abG991NKSU4FWK7 (aarch64)
~/termux-gnirehtet $ ANDROID_NO_USE_FWMARK_CLIENT=1 fakeroot termux-adb devices
List of devices attached

Attach contents of the following files (after running with debug logs enabled)

adb.0.log

Additional context Screenshot_20240209_150751_Termux

In the log adb were trying to open directory /dev/bus/usb, but it seems the permission is denied, even termux-usb /dev/bus/usb/002/005 shows access granted.

before upgrading I can connect to my android tablet without any problem. and I can still connect to my tablet using my second device (android 13).

nohajc commented 5 months ago

Hi, regarding the permission denied error, that's expected behavior. That's why termux-adb is needed in the first place. To work around this issue.

You can try running directly termux-usb -l which is how Termux can enumerate usb devices and that's what I'm using under the hood.

If this gives you an empty result ([]), I'm afraid it's beyond my control. I cannot verify if this is a breaking change caused by Android or just some sort of Samsung regression. The Termux devs might have more information.

AlphaBs commented 5 months ago

termux-usb -l shows my device as shown in the first screenshot.

nohajc commented 5 months ago

Ah, sorry, I don't know how I missed that. It's interesting that from the log, it looks like termux-adb detects the device as well. Just doesn't show it... I'll investigate more.

nohajc commented 5 months ago

Device is detected from the list but then it should also get its USB file descriptor and inject it to a simulated filesystem hierarchy (creating a fake file with the expected /dev/usb path). This doesn't happen for some reason. Could be that unix sockets (used for passing the descriptor) are somehow broken.

I'll think about how I could verify that assumption but I don't have Android 14 on any of my devices at the moment (none of them is Samsung either).

nohajc commented 5 months ago

To further clarify, it could either be a problem with passing descriptors between processes (using Unix sockets) or with termux-usb itself (it could enumerate devices fine but still be unable to give you the device descriptor). Looking at the code, it seems it's probably the former.

Anyway, if I'm not able to reproduce it, I can write a simple program to test it on your device. Then we'll see.

With some changes to termux-adb I think I could even make it work without the sockets albeit with some limitations.

AlphaBs commented 5 months ago

thank you for investigating. I'm willing to do your test.

nohajc commented 5 months ago

Ok, so this is two tests in one: https://github.com/nohajc/termux-usb-test/releases/tag/0.1.0

I compiled the binary for ARM 64-bit (aarch64), hopefully that's correct.

Put this anywhere in termux, go to that directory and get your connected device path by running termux-usb -l. (Also run chmod +x ./termux-usb-test if needed.)

First test - run termux-usb -e ./termux-usb-test -E -r /dev/bus/usb/001/002 (replacing path according to your case). This should print the serial number of the device.

Second test - just run ./termux-usb-test --test-uds. This should also print the serial number with some additional logs but it may hang indefinitely if Unix sockets don't work correctly.

If you could post here the output of both runs, that would be super helpful.

AlphaBs commented 5 months ago

it shows nothing..Screenshot_20240211_122750_Termux.jpg

AlphaBs commented 5 months ago

I found that termux-usb -e <command> /dev/... does not work with even very simple command like ls, echo. it shows nothing and it does not execute the command.

maybe the problem is termux-usb.

AlphaBs commented 5 months ago

I found https://github.com/termux/termux-api/issues/643

it was termux-api...

nohajc commented 5 months ago

Oh, that's interesting. Anyway, have you tried running it with the usual Samsung workaround? (ANDROID_NO_USE_FWMARK_CLIENT=1 fakeroot). Tbh, I don't know if these are related to termux or just adb...

AlphaBs commented 5 months ago

yes I've already tried but no luck

AlphaBs commented 4 months ago

termux/termux-api#643 was fixed!

after installing nightly build of termux-api, now adb devices shows my device well.