Android System Shutdown Process Analysis

Source: Internet
Author: User

The shutdown operation is triggered by a key. the linux kernel layer returns a key event to the android framework layer to go to the framework layer, and then executes the shutdown task of the kernel layer from the framework layer to the kernel layer.

Handler code corresponding to long buttons:

Frameworks/policies/base/phone/com/android/internal/policy/impl/PhoneWindowManager. java
Runnable mPowerLongPress;


Private final Runnable mPowerLongPress = new Runnable (){
Public void run (){
If (! MPowerKeyHandled ){
MPowerKeyHandled = true;
PerformHapticFeedbackLw (null, HapticFeedbackConstants. LONG_PRESS, false );
SendCloseSystemWindows (SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS );
ShowGlobalActionsDialog ();
}
}
};


MPowerLongPress startup shutdown dialog box

(Frameworks/policies/base/phone/com/android/internal/policy/impl/GlobalActions. java)


If we select Power OFF, ShutdownThread. shutdown will be called to start the shutdown thread to execute the shutdown action.

Frameworks/base/core/java/com/android/internal/app/ShutdownThread. java


Real shutdown process:

(1) broadcast global events, ACTION_SHUTDOWN Intent

(2) shutdown ActivityManager Service

(3) Stop the Bluetooth service

(4) Stop the telephone service (radio phone service)

(5) Stop the mount service.

(6) Call Power. shutdown () to enter the native Layer

Frameworks/base/core/java/android/OS/Power. java

 

Native implementation code of power:

Frameworks/base/core/jni/android_ OS _Power.cpp


Static void android_ OS _Power_shutdown (JNIEnv * env, jobject clazz)
{
Sync ();
# Ifdef HAVE_ANDROID_ OS
Reboot (RB_POWER_OFF );
# Endif
}
Sync and reboot are called by the linux system to go To the linux kernel shutdown process.

 


Author: LuoXianXion

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.