Shutdown sequence of Android

To power off an Android phone, keep pressing power bottom then shutdown menu is appeard. Then choose ‘Power OFF’ to power off actually.
I looked for the source code to see how to do these sequence.
(Japanese version of this page)

Showing shutdown menu

Long press of power bottom is handled here.
Runnable mPowerLongPress;

Here is the shutdown dialog.
If you choose ‘Power OFF’, it calls ShutdownThread.shutdown.

Shutdown process

Through beginShutdownSequence(), actual shutdown process is done in run().

  1. Broadcasts ACTION_SHUTDOWN Intent
  2. Calls shutdown of ActivityManager service
  3. Calls disable of Bluetooth service
  4. Calls Radio(false) of Phone service
  5. Calls shutdown of Mount service
  6. Vibrate for a while
  7. Calls Power.shutdown();

Power#shutdown is a native method.

static void android_os_Power_shutdown(JNIEnv *env, jobject clazz)

sync, reboot are system calls. They are done in Linux kernel.

About tetsu_koba

This entry was posted in Android. Bookmark the permalink.

3 Responses to Shutdown sequence of Android

  1. AR_VR says:

    The first article I have ever come across which explains the process so cleanly. I really appreciate your blog. Thanks.

  2. AR_VR says:

    I am not able to see the files

    Please let me know where I can find the respective source files. I am trying to see on what event does this dialog comes up. Can you please let me know what event should be posted by linux kernel so that the shutdown process handling begins.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s