Usb tethering /etc/hotplug.d/usb adb

I created a script in:

cat /etc/hotplug.d/usb/99-my-device
MYPRODUCT="my-id"

if [ ${ACTION} = "bind" ]; then
if [ ${PRODUCT} = ${MYPRODUCT} ]; then
adb start-server
adb shell svc data enable
adb shell svc usb setFunctions rndis
fi
fi

it works

but the smartphone every time I connect it asks me to
allow the connection, even if I have allowed more
once hooking.

how do i solve this

1 Like

That is a security feature in Android OS. A human (presumably the phone's owner) has to unlock the screen to allow the connection. Otherwise someone who doesn't know the unlock code could use adb to read your files.

I understand it's a safety feature to be after
allowed this the first time, I expect that it is no longer required see example below

my linux pc correctly runs "adb always allow from this computer" and does not ask me again after the first access?

Make sure you are using persistent keys:

/root/.android/adbkey
/root/.android/adbkey.pub

yes

I've already tried:

reset smartphone and more

they do not solve the problem

1 Like

I modified the script with the parameter:

HOME = "/ root"

as i found that the script runs but creates /.android
now correctly create directory in /root/.android

find / -iname "* .android *"
/overlay/upper/root/.android
/root/.android

but I haven't solved the problem yet the smartphone asks me several times to authorize the commands

how can i solve

I solved the problem (solution not appropriate but working) by copying the files:

adbkey
adbkey.pub

from my computer to the router in the directory

/root/.android

and now everything works perfectly

on the router I have:

openwrt 19.07.5
adb android.5.0.2_r1-3

I would like someone who knows what the program that creates the .android / adbkey and .android / adbkey.pub files is to communicate
the related problem to the maintainer of the package

I assume the adb package creates the files, but they are not
of course.

thanks for the time dedicated to me

1 Like

Yep, but this is performed implicitly when starting the server.
The newer adb version supports the keygen command that can generate the keys explicitly.

But why did the created keys not allow what I wanted?

There is an alternative command somewhere to create
keys, in order to test the actual bug.

Perhaps the phone can remember only one key, or for some reason only the first one.
Also the adb version might be too old creating incompatible or weak keys.

adb kill-server
mv .android .android.bak
adb start-server

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.