1. You want that $100.00 in your pocket or an Amazon Fire TV don't you? Well here's the deal. With our new updated look we are in desperate need of an updated logo. The 'old' one has certainly served us well, but it's time. Find all the details here: bit.ly/1q0k6Wa
  2. DroidForums.net is currently undergoing a major software upgrade. If you are experiencing any problems logging in please: Contact Us

Hidden Shutdown Options - How do they work?

Discussion in 'Bugless' started by Se7enLC, Jun 17, 2010.

  1. Se7enLC
    Offline

    Se7enLC New Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    0


    I was intrigued when the way to disable this new feature was to erase /system/bin/shutdown, so I looked at the contents of that script:

    Code:
    #!/system/bin/sh
    
    stop;
    stop dhcpcd;
    
    sleep 1;
    
    for i in `cat /proc/mounts | cut -f 2 -d " "`;
    do
       busybox mount -o remount,ro $i 2>&1 > /dev/null;
    done
    
    sync;
    
    if [ "$1" = "-r" ];
    then
       toolbox reboot;
    fi
    
    if [ "$1" = "-rr" ];
    then
       toolbox reboot recovery;
    else 
       reboot -p;
    fi
    Looks pretty straightforward to me. That must not be what actually checks the keys, though. I looked at a diff between the V01 and V02 update files - and that shutdown script is the only change!

    Does this mean that the hidden recovery options were there all along and the shutdown script was just missing? Did you have to do something else to enable this feature, Pete?

    I'm tempted to go one step further and map those keys to OTHER things by editing this script. It'll be a little (a lot) kludgy to have a shutdown script that does other stuff that isn't shutting down, but remapping hardware keys to custom linux scripts can't be a bad thing...
  2. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    I was trying to figure out how to just disable the camera button shutdown, but keep the reboot options. Tried adding this to the beginning of the script but not having any luck.

    Code:
    if [[ "$1" != "-r" && "$1" != "-rr" ]];
    then
    exit 0;
    fi
    
  3. Se7enLC
    Offline

    Se7enLC New Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    0
    Try single brackets instead of double?
  4. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    nope no go, on both versions none of the shutdown combos work after i've added the if statement.
  5. Se7enLC
    Offline

    Se7enLC New Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    0
    Are you editing the file on the phone, or pushing it from a computer? I've been having some problems with files made on the phone for some reason. I think the semicolon key is wrong, perhaps?

    Anyway, I pasted almost your exact change into the script, and changed all the actual commands to "echo" so I could test it without rebooting all the time. Running it from the commandline directly seems to work fine, only does something when you give it -r and -rr, does nothing when you give it no command.
  6. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    got it, instead of creating the file on my pc and pushing it to the phone, i just edited the current shutdown script and it worked.

    only thing is now, instead of shutdown with the camera button, it now just locks up the phone and i have to do a battery pull. the reboot ones work fine. Should i be exiting the script a different way than "exit 0;" ?
  7. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    hah, just saw this
  8. Se7enLC
    Offline

    Se7enLC New Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    0
    Here's the real (working) version. I just tested it out - the volume buttons still do stuff, camera button doesn't.

    Make sure you chmod 0755 the file once you copy it in.
  9. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    you sure this is the same one you tested? camera button still shuts down on me
  10. Se7enLC
    Offline

    Se7enLC New Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    0
    Positive. But I'm running a non-standard shell for /system/bin/sh, so that could be it. I'll look into it a little closer later, perhaps.
  11. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    ah could be it, i'll keep digging. Thanks for the help
  12. Tallica
    Offline

    Tallica Premium Member Premium Member

    Joined:
    Mar 17, 2010
    Messages:
    3,259
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Middleboro, MA
    This is how you stop it.

    -Hidden Shutdown Options using keys (credit to Pete):
    To Remove These Options Delete /system/bin/shutdown

    to just disable rename the file to shutdown.bak
  13. jgaikwad
    Offline

    jgaikwad New Member

    Joined:
    May 25, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0

    agreed, but i don't want to stop it all, just want to disable the camera button one.
  14. Tallica
    Offline

    Tallica Premium Member Premium Member

    Joined:
    Mar 17, 2010
    Messages:
    3,259
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Middleboro, MA
    sorry, my bad
  15. Reserved Name
    Offline

    Reserved Name New Member

    Joined:
    Mar 7, 2010
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    0
    [​IMG]
    magnets
  16. michael_campbell
    Offline

    michael_campbell New Member

    Joined:
    Apr 30, 2010
    Messages:
    328
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Atlanta suburbia.
    What are you running for /bin/sh?
  17. ASN-121
    Offline

    ASN-121 New Member

    Joined:
    Dec 27, 2009
    Messages:
    203
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Mesa
    Somebody finally referenced it. I was waiting for it!
  18. Se7enLC
    Offline

    Se7enLC New Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    0
    busybox ash
  19. creamers
    Offline

    creamers New Member

    Joined:
    Dec 30, 2009
    Messages:
    119
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Tennessee
    I would assume there is another file somewhere that takes those key combination's and maps out a shell commands like shutdown, shutdown -r, shutdown -rr

    By changing the shutdown file all your doing is editing the commands not the button remap its self.
  20. Se7enLC
    Offline

    Se7enLC New Member

    Joined:
    Nov 16, 2009
    Messages:
    1,263
    Likes Received:
    0
    Trophy Points:
    0
    Umm, yes, we know.

    Read the first post in this thread. The change between BB 0.1 and BB 0.2 to enable the hidden shutdown options was JUST adding the shutdown script. No other related file changed. That means that the key commands and resulting script calls were there all along, but there was no shutdown script to call. All pete did was add the script for them to call to make them work. Similarly, because there never was a /system/bin/shutdown file before, it's safe to say that it doesn't get called anywhere else, at least not anywhere important.

    All we are doing is modifying that script to effectively reassign those buttons to different commands (or in this case, no command at all). What that does is disables ONE of the three hidden shutdown commands.

    I'm also thinking of other possible uses for those keys. Perhaps use the power+volup/down keys to adjust the max cpu speed up and down? That would be a trivial change to implement.
Search tags for this page
adjust power shutdown samsung adndroid
,
android command line shutdown
,
android halt command
,
android script shutdown
,

android shutdown command

,
android shutdown files command
,
android shutdown options
,

android shutdown script

,
change shutdown options android
,
command to shutdown android
,
droid x2 hidden shutdown options
,
droid x2 how to change shutdown
,
hiden sutdoun
,
shutdown android command
,

shutdown command android