0

I have a problem with my device. When I do adb reboot then it stuck on boot in a loop.

But, when I do adb shell and then reboot, it works fine.

I searched over the internet and understand that both have different behavior:

  • adb reboot works like you plug the phone battery out. Means, it will not close any application, not show any pretty Restarting splash screen.
  • adb shell reboot uses /system/bin/reboot executable and it does a soft reboot with closing opened application, showing the splash screen, etc..

To verify that adb shell reboot execute /system/bin/reboot, I have moved the /system/bin/reboot to another place and as expected the reboot command not working anymore so I put it back after confirmation.

I want adb reboot to use /system/bin/reboot executable.

I want to do it from within the Android device that makes it a general solution for all users of the device. I know I can execute adb shell reboot but other users will not do this.

Is there any way of doing this?

  • i am afraid you are looking for a solution on device, not for pc? – alecxs Nov 29 '19 at 10:46
  • You are right that I am looking for a solution for the device. – Vatish Sharma Nov 29 '19 at 11:19
  • Both adb reboot and /system/bin/reboot do the same thing i.e. set sys.powerctl property to reboot (with optional arguments), which you can do manually too. Both should do a graceful shutdown/reboot. Not sure if the behavior was different with old adb binaries. – Irfan Latif Nov 29 '19 at 12:15
2

Write a script in your PC, look for 'reboot' argument, and execute your own command instead.

I do not know how a Window's compatible script would look like, but this is how a simple bash script would look like.

#!/bin/bash
ADB="PATH_TO_RENAMED_ADB_BINARY"

if [[ "$1" == "reboot" ]] && [[ -z ${2} ]]; then         # $1 is the first argument received by adb
    "$ADB" shell '/system/bin/reboot'    
else
    "$ADB" "$@"                            # $@ contains all the arguments received by adb
fi

Save the script as adb, give executable permission to it, rename adb binary with the name adb_orig, and then save this script as adb where adb is originally located.

| improve this answer | |
  • I need a general solution. This will require me to place this script into the machine of a person who will be going to use this device. This is not possible for me. So, I want to do it from an Android device. Is it possible to write such script in the Android? – Vatish Sharma Nov 29 '19 at 10:48
  • Hey, if I will use your script at ./system/bin/adbd and rename old adbd to orig_adbd and edit the script with ADB="orig_adbd". Is it will work? – Vatish Sharma Nov 29 '19 at 10:53
  • 1
    it is maybe easier to put a sticker on the back "warning: don't use adb reboot" – alecxs Nov 29 '19 at 11:00
  • 1
    @VatishSharma the adb binary I've asked to rename is the adb client, simply named as adb. I do not know how to interact with adbd. You can try and experiment and post an answer. :) – Firelord Nov 29 '19 at 11:05
  • 2
    @VatishSharma When you press on Restart button in the device, this is how it is initiated. You can follow the trail in the source code. See What's the best way to restart Android via command line (remotely)? and How can I shutdown my Android phone using an adb command? – Firelord Nov 29 '19 at 11:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.