0

The setprop service.adb.tcp.port 5555 worked on my non-rooted device, now I need to restart adbd as the shell user :

$ adb shell
shell@android:/ $ getprop ro.build.version.release                             
4.1.2
shell@android:/ $ getprop service.adb.tcp.port                                 

shell@android:/ $ setprop service.adb.tcp.port 5555                            
shell@android:/ $ getprop service.adb.tcp.port                                 
5555

I tried this to restart adbd, but the PID of adbd didn't change :

shell@android:/ $ ps -C adbd
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
shell     161   1     4724   308   ffffffff 00000000 S /sbin/adbd
shell@android:/ $ stop adbd
shell@android:/ $ start adbd                                                   
shell@android:/ $ ps -C adbd                                                    
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
shell     161   1     4724   308   ffffffff 00000000 S /sbin/adbd
shell@android:/ $ exit
$ adb connect 192.168.2.27
failed to connect to '192.168.2.27:5555': Connection refused

Then I sent a SIGHUP to try and trigger a adbd restart, but all it did was to kill adbd and now I cannot connect via USB anymore :

shell@android:/ $ kill -SIGHUP 161
$ adb shell
error: device offline

So now I HAVE to reboot in order start adbd which I've accidentally killed.

After reboot I also tried setprop ctl.restart adbd but it didn't work :

shell@android:/ $ ps -C adbd
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
shell     176   1     4720   300   ffffffff 00000000 S /sbin/adbd
shell@android:/ $ getprop ctl.restart

shell@android:/ $ setprop ctl.restart adbd
shell@android:/ $ getprop ctl.restart                                          

shell@android:/ $ ps -C adbd                                                   
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
shell     176   1     4720   300   ffffffff 00000000 S /sbin/adbd
shell@android:/ $ 

Can you help me restart adbd on my non-rooted device without reboot ?

6
  • 1
    Disable and enable USB Debugging in Developer Options. Dec 10, 2019 at 14:36
  • @IrfanLatif Great, just what I needed :) ! Can this also be done via a command line ?
    – SebMa
    Dec 10, 2019 at 15:18
  • 2
    settings put global adb_enabled 0 and settings put global adb_enabled 1. setprop ctl.restart adbd should also work. Tag shows you are on JB where SELinux should not be a problem. Dec 10, 2019 at 15:32
  • @IrfanLatif As you surely expected, the settings put global adb_enabled 0 command got me disconnect before the next settings put global adb_enabled 1 command got executed
    – SebMa
    Dec 10, 2019 at 16:31
  • @IrfanLatif Yes it does but I found this 14 minutes ago :) See my own answer at the bottom.
    – SebMa
    Dec 10, 2019 at 17:18

1 Answer 1

0

In the specific context of setting the adb tcp/ip port, the adb tcpip 5555 command does restart the adbd service.

As one can see the PID of adbd is changed after the adb tcpip command :

$ adb shell ps | egrep -w "adbd|PID"
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
shell     3675  1     4720   300   ffffffff 00000000 S /sbin/adbd
$ adb tcpip 5555
restarting in TCP mode port: 5555
$ adb shell ps | egrep -w "adbd|PID"
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
shell     3800  1     4720   300   ffffffff 00000000 S /sbin/adbd

Not the answer you're looking for? Browse other questions tagged .