1

It seems that I can only get ADB permissions for my device only while in MTP or PTP mode and NOT in USB tethering mode, which is what I need.

I have done plenty of research but I stumbled upon so much contradicting and very old information that I can no longer see how to proceed.

Here they say that it is not possible, but it dates back to 2012. Here and here they propose to invoke the shell via ADB to put the device in USB tethering mode (which works for me as well) but also to disable it, which in my case fails since as once stepped away from MTP or PTP mode I no longer have permissions for my device.

Then I found this interesting post which seems relevant but does not provide a complete solution. This also looks relevant but it does not touch the tethering case.

So, once and for all, how do I keep ADB permissions for my device when it is NOT in MTP or PTP mode? I only care about recent Android versions. I obviously have root access for my device as well the possibility to deploy custom ROMs, although, for personal taste, I tend to stick to LineageOS.


Additional note: this is the error that I get when not in MTP/PTP:

$ adb devices 
List of devices attached
2d8568f6    no permissions; see [http://developer.android.com/tools/device.html]

$ adb shell
error: insufficient permissions for device
See [http://developer.android.com/tools/device.html] for more information

Unfortunately the link is quite useless, but it seems that ADB identifies and communicates with the device, but this does not accept any request.

I don't think that this has something to do with my PC, the udev rules are in place, plus ADB works fine when the device is in MTP or PTP mode.

Here is a screenshot (click for video browsing to that menu):

dsc


When in MTP mode I can open a shell via ADB, this is what I see:

$ su

# pwd
/

# ls -lah                                                                                                   
total 1.0M
drwxr-xr-x  18 root   root   4.0K 2008-12-31 19:30 .
drwxr-xr-x  18 root   root   4.0K 2008-12-31 19:30 ..
dr-xr-xr-x  56 root   root      0 1971-04-23 21:51 acct
lrw-r--r--   1 root   root     11 2008-12-31 19:30 bin -> /system/bin
lrw-r--r--   1 root   root     50 2008-12-31 19:30 bugreports -> /data/user_de/0/com.android.shell/files/bugreports
drwxrwx---   6 system cache  4.0K 1971-04-23 21:51 cache
lrw-r--r--   1 root   root     13 2008-12-31 19:30 charger -> /sbin/charger
drwxr-xr-x   3 root   root      0 1970-01-01 01:00 config
lrw-r--r--   1 root   root     17 2008-12-31 19:30 d -> /sys/kernel/debug
drwxrwx--x  42 system system 4.0K 2020-05-02 11:50 data
lrw-------   1 root   root     23 2008-12-31 19:30 default.prop -> system/etc/prop.default
drwxr-xr-x  17 root   root   3.4K 2018-03-20 08:10 dev
lrw-r--r--   1 root   root     11 2008-12-31 19:30 dsp -> /vendor/dsp
lrw-r--r--   1 root   root     11 2008-12-31 19:30 etc -> /system/etc
lrw-r--r--   1 root   root     20 2008-12-31 19:30 firmware -> /vendor/firmware_mnt
-rwxr-x---   1 root   shell  2.1M 2008-12-31 19:30 init
-rwxr-x---   1 root   shell  1.2K 2008-12-31 19:30 init.environ.rc
-rwxr-x---   1 root   shell   29K 2008-12-31 19:30 init.rc
-rwxr-x---   1 root   shell  7.5K 2008-12-31 19:30 init.usb.configfs.rc
-rwxr-x---   1 root   shell  5.5K 2008-12-31 19:30 init.usb.rc
-rwxr-x---   1 root   shell   511 2008-12-31 19:30 init.zygote32.rc
-rwxr-x---   1 root   shell   875 2008-12-31 19:30 init.zygote64_32.rc
drwx------   2 root   root    16K 2008-12-31 19:30 lost+found
drwxr-xr-x  12 root   system  260 1971-04-23 21:51 mnt
drwxr-xr-x   2 root   root   4.0K 2008-12-31 19:30 odm
drwxr-xr-x   2 root   root   4.0K 2008-12-31 19:30 oem
dr-xr-xr-x 512 root   root      0 1970-01-01 01:00 proc
lrw-r--r--   1 root   root     15 2008-12-31 19:30 product -> /system/product
drwxr-xr-x   3 root   root   4.0K 2008-12-31 19:30 res
drwxr-xr-x   3 root   root    300 1971-04-23 21:51 sbin
lrw-r--r--   1 root   root     21 2008-12-31 19:30 sdcard -> /storage/self/primary
drwxr-xr-x   4 root   root     80 2020-02-27 08:07 storage
dr-xr-xr-x  12 root   root      0 1971-04-23 21:51 sys
drwxr-xr-x  17 root   root   4.0K 2018-03-20 02:40 system
-rw-r--r--   1 root   root   5.2K 2008-12-31 19:30 ueventd.rc
drwxr-xr-x  15 root   root   4.0K 2008-12-31 19:30 vendor
-rw-r--r--   1 root   root    524 2008-12-31 19:30 verity_key

I can open the various .rc files in there (with nano or /sbin/.magisk/busybox/vi) but in readonly mode. I might be able to get rw permissions from recovery, but still I would not know what to change.

  • That seem to be a device specific problem (-> edit your question and add device details). My Sony XA2 works out of the box with USB tethering and ADB at the same time (however MTP seem to be disabled while USB tethering is active). – Robert May 2 at 11:05
  • @Robert I am trying with a lenovo k6 (karate k33a48). I have the feeling that in the past it used to work, but I cannot remember what ROM I was using. I expect this to be a software issue, possibly device unrelated. – DarioP May 2 at 12:53
  • 1
    Note: Your question is a bit misleading as you always talk about "adb permission". However this is not a permission problem but a configuration of the USB interface. Each physical USB device can have multiple logical devices active at the same time (on my device one for "Remote NDIS" and one for adb or one for adb and one for MTP). On Windows you can view them nicely in the device manager grouped by a USB compound device (virtual device that combines the logical USB devices). Hence your question is how to activate RNDIS and adb at the same time. – Robert May 2 at 13:06
  • You should add this very important info into your question and not hide in comments. However I still don't think that this is a permission problem. The adb permission uses public key auth, hence the permission can't just change. I suspect a bug in the firmware of your device or a general bug if others can reproduce your problem. – Robert May 2 at 13:30
  • 1
    @DarioP I'm glad it helped. I think the question I linked already includes the relevant answers. Reposting isn't encouraged. – Irfan Latif May 2 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.