Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android device shutdown - want "ShutdownThread->shutdown()"not "su reboot -p"

Several questions about shutting down a rooted android device have answers saying you should run "reboot -p" within an "su" shell. However, this answer says that reboot is quite low-and-dirty and doesn't do sufficient tidying up before pulling the plug. Instead it recommends using android.internal.app.ShutdownThread.shutdown(). Looking at the code I can see that this does a whole bunch of housekeeping stuff that I'd like to have, and it also has a handy "confirm" parameter that appears to let you shut down without asking for confirmation, which is nice.

My question is this - what properties does an app have to have in order to call ShutdownThread.shutdown()? Does is require a particular permission that can be set if the device is rooted, or does it have to be signed using the firmware key, or something else entirely?

like image 335
kbro Avatar asked Nov 03 '22 05:11

kbro


1 Answers

Shutting down the device requires you to hold android.permission.SHUTDOWN which is only available to system applications, or applications signed with the platform certificate.

like image 119
Kane O'Riley Avatar answered Nov 08 '22 08:11

Kane O'Riley